Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
raksooo committed Apr 5, 2024
1 parent 47215e3 commit 6e56d99
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 38 deletions.
16 changes: 11 additions & 5 deletions gui/src/renderer/components/ConnectionPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { colors } from '../../config.json';
import {
EndpointObfuscationType,
ProxyType,
proxyTypeToString,
RelayProtocol,
TunnelType,
tunnelTypeToString,
Expand Down Expand Up @@ -164,10 +163,9 @@ export default class ConnectionPanel extends React.Component<IProps> {
entry: this.props.entryHostname,
},
);
} else if (this.props.bridgeInfo?.ip) {
return sprintf(messages.pgettext('connection-info', '%(relay)s via %(entry)s'), {
} else if (this.props.bridgeInfo !== undefined) {
return sprintf(messages.pgettext('connection-info', '%(relay)s via Custom bridge'), {
relay: this.props.hostname,
entry: this.props.bridgeInfo.ip,
});
} else {
return this.props.hostname || '';
Expand All @@ -181,7 +179,7 @@ export default class ConnectionPanel extends React.Component<IProps> {
const tunnelType = tunnelTypeToString(inAddress.tunnelType);

if (bridgeInfo) {
const bridgeType = proxyTypeToString(bridgeInfo.bridgeType);
const bridgeType = this.bridgeType();

return sprintf(
// TRANSLATORS: The tunnel type line displayed below the hostname line on the main screen
Expand All @@ -201,4 +199,12 @@ export default class ConnectionPanel extends React.Component<IProps> {
return '';
}
}

private bridgeType() {
if (this.props.bridgeHostname && this.props.bridgeInfo?.bridgeType === 'shadowsocks') {
return 'Shadowsocks bridge';
} else {
return 'Custom bridge';
}
}
}
4 changes: 3 additions & 1 deletion gui/src/renderer/components/EditCustomBridge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ function CustomBridgeForm() {

const onSave = useCallback(
(newBridge: CustomProxy) => {
void updateBridgeSettings(convertToBridgeSettings({ ...bridgeSettings, custom: newBridge }));
void updateBridgeSettings(
convertToBridgeSettings({ ...bridgeSettings, custom: newBridge, type: 'custom' }),
);
history.pop();
},
[bridgeSettings, history.pop],
Expand Down
16 changes: 8 additions & 8 deletions gui/src/renderer/components/OpenVpnSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { useHistory } from '../lib/history';
import { formatHtml } from '../lib/html-formatter';
import { useBoolean } from '../lib/utilityHooks';
import { useSelector } from '../redux/store';
import * as AppButton from './AppButton';
import { AriaDescription, AriaInput, AriaInputGroup, AriaLabel } from './AriaGroup';
import * as Cell from './cell';
import Selector, { SelectorItem } from './cell/Selector';
Expand All @@ -33,6 +32,7 @@ import {
TitleBarItem,
} from './NavigationBar';
import SettingsHeader, { HeaderTitle } from './SettingsHeader';
import { SmallButton } from './SmallButton';

const MIN_MSSFIX_VALUE = 1000;
const MAX_MSSFIX_VALUE = 1450;
Expand Down Expand Up @@ -359,13 +359,13 @@ function BridgeModeSelector() {
type={ModalAlertType.caution}
title={messages.pgettext('openvpn-settings-view', 'Enable bridge mode?')}
message={messages.gettext('This setting increases latency. Use only if needed.')}
buttons={[
<AppButton.RedButton key="confirm" onClick={confirmBridgeState}>
{messages.gettext('Enable anyway')}
</AppButton.RedButton>,
<AppButton.BlueButton key="back" onClick={hideConfirmationDialog}>
{messages.gettext('Back')}
</AppButton.BlueButton>,
gridButtons={[
<SmallButton key="cancel" onClick={hideConfirmationDialog}>
{messages.gettext('Cancel')}
</SmallButton>,
<SmallButton key="confirm" onClick={confirmBridgeState}>
{messages.gettext('Enable')}
</SmallButton>,
]}
close={hideConfirmationDialog}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ function SelectLocationContent() {
label: messages.pgettext('select-location-view', 'Custom bridge'),
value: SpecialBridgeLocationType.custom,
selected: bridgeSettings?.type === 'custom',
disabled: bridgeSettings?.custom === undefined,
component: CustomBridgeLocationRow,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export function CustomBridgeLocationRow(
const navigate = useCallback(() => history.push(RoutePath.editCustomBridge), [history.push]);

return (
<StyledLocationRowContainerWithMargin ref={selectedRef}>
<StyledLocationRowContainerWithMargin ref={selectedRef} disabled={props.source.disabled}>
<StyledLocationRowButton
as="button"
onClick={props.onSelect}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,22 @@ export function useOnSelectBridgeLocation() {
[bridgeSettings],
);

const onSelectSpecial = useCallback((location: SpecialBridgeLocationType) => {
switch (location) {
default: // TODO
case SpecialBridgeLocationType.closestToExit:
return setLocation({
...bridgeSettings,
type: 'normal',
normal: { ...bridgeSettings.normal, location: 'any' },
});
case SpecialBridgeLocationType.custom:
return setLocation(convertToBridgeSettings({ ...bridgeSettings, type: 'custom' }));
}
}, []);
const onSelectSpecial = useCallback(
(location: SpecialBridgeLocationType) => {
switch (location) {
default: // TODO
case SpecialBridgeLocationType.closestToExit:
return setLocation({
...bridgeSettings,
type: 'normal',
normal: { ...bridgeSettings.normal, location: 'any' },
});
case SpecialBridgeLocationType.custom:
return setLocation(convertToBridgeSettings({ ...bridgeSettings, type: 'custom' }));
}
},
[bridgeSettings],
);

return [onSelectRelay, onSelectSpecial] as const;
}
10 changes: 0 additions & 10 deletions gui/src/shared/daemon-rpc-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,6 @@ export function wrapConstraint<T>(
}

export type ProxyType = 'shadowsocks' | 'custom';
export function proxyTypeToString(proxy: ProxyType): string {
switch (proxy) {
case 'shadowsocks':
return 'Shadowsocks bridge';
case 'custom':
return 'custom bridge';
default:
return '';
}
}

export enum Ownership {
any,
Expand Down

0 comments on commit 6e56d99

Please sign in to comment.