diff options
| -rw-r--r-- | gui/src/main/daemon-rpc.ts | 1 | ||||
| -rw-r--r-- | gui/src/main/index.ts | 62 | ||||
| -rw-r--r-- | gui/src/renderer/app.tsx | 4 | ||||
| -rw-r--r-- | gui/src/renderer/components/LocationList.tsx | 1 | ||||
| -rw-r--r-- | gui/src/renderer/components/RelayRow.tsx | 5 | ||||
| -rw-r--r-- | gui/src/renderer/redux/settings/reducers.ts | 1 | ||||
| -rw-r--r-- | gui/src/shared/daemon-rpc-types.ts | 1 |
7 files changed, 42 insertions, 33 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts index 25f0d32748..1ce4450af3 100644 --- a/gui/src/main/daemon-rpc.ts +++ b/gui/src/main/daemon-rpc.ts @@ -137,6 +137,7 @@ const relayListSchema = partialObject({ hostname: string, ipv4_addr_in: string, include_in_country: boolean, + active: boolean, weight: number, bridges: maybe( partialObject({ diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index ac583f4300..05edd6af6c 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -13,10 +13,10 @@ import { IAppVersionInfo, ILocation, IRelayList, - IRelayListHostname, ISettings, IWireguardPublicKey, KeygenEvent, + liftConstraint, RelayLocation, RelaySettings, RelaySettingsUpdate, @@ -663,42 +663,44 @@ class ApplicationMain { relayList: IRelayList, relaySettings: RelaySettings, ): IRelayList { - // TODO: once wireguard is stable, by default we should only filter by - // hasToHaveOpenvpn || hasToHaveWg, until then, only filter wireguard - // relays if tunnel constraints specify wireguard tunnels. - const hasOpenVpnTunnels = (relay: IRelayListHostname): boolean => { - if (relay.tunnels) { - return relay.tunnels.openvpn.length > 0; - } else { - return false; - } - }; - const hasWireguardTunnels = (relay: IRelayListHostname): boolean => { - if (relay.tunnels) { - return relay.tunnels.wireguard.length > 0; - } else { - return false; - } - }; - let fnHasWantedTunnels = hasOpenVpnTunnels; + const tunnelProtocol = + 'normal' in relaySettings ? liftConstraint(relaySettings.normal.tunnelProtocol) : undefined; - if ('normal' in relaySettings) { - const tunnelConstraints = relaySettings.normal.tunnelProtocol; - if (tunnelConstraints !== 'any' && 'wireguard' === tunnelConstraints.only) { - fnHasWantedTunnels = hasWireguardTunnels; - } - } - - return { - countries: relayList.countries.map((country) => ({ + const filteredCountries = relayList.countries + .map((country) => ({ ...country, cities: country.cities .map((city) => ({ ...city, - relays: city.relays.filter(fnHasWantedTunnels), + relays: city.relays.filter((relay) => { + if (relay.tunnels) { + switch (tunnelProtocol) { + case 'openvpn': + return relay.tunnels.openvpn.length > 0; + + case 'wireguard': + return relay.tunnels.wireguard.length > 0; + + case 'any': + // TODO: once wireguard is stable, by default we should only filter by + // hasToHaveOpenvpn || hasToHaveWg, until then, only filter wireguard + // relays if tunnel constraints specify wireguard tunnels. + return relay.tunnels.openvpn.length > 0; + + default: + return false; + } + } else { + return false; + } + }), })) .filter((city) => city.relays.length > 0), - })), + })) + .filter((country) => country.cities.length > 0); + + return { + countries: filteredCountries, }; } diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx index 6f54281f3c..c8027223a0 100644 --- a/gui/src/renderer/app.tsx +++ b/gui/src/renderer/app.tsx @@ -555,14 +555,14 @@ export default class AppRenderer { .map((country) => ({ name: country.name, code: country.code, - hasActiveRelays: country.cities.some((city) => city.relays.length > 0), + hasActiveRelays: country.cities.some((city) => city.relays.some((relay) => relay.active)), cities: country.cities .map((city) => ({ name: city.name, code: city.code, latitude: city.latitude, longitude: city.longitude, - hasActiveRelays: city.relays.length > 0, + hasActiveRelays: city.relays.some((relay) => relay.active), relays: city.relays, })) .sort((cityA, cityB) => cityA.name.localeCompare(cityB.name)), diff --git a/gui/src/renderer/components/LocationList.tsx b/gui/src/renderer/components/LocationList.tsx index 418da66e94..72a3b64f75 100644 --- a/gui/src/renderer/components/LocationList.tsx +++ b/gui/src/renderer/components/LocationList.tsx @@ -84,6 +84,7 @@ export default class LocationList extends Component<IProps, IState> { return ( <RelayRow key={getLocationKey(relayLocation)} + active={relay.active} hostname={relay.hostname} onSelect={this.handleSelection} {...this.getCommonCellProps(relayLocation)} diff --git a/gui/src/renderer/components/RelayRow.tsx b/gui/src/renderer/components/RelayRow.tsx index 69f632e04e..5dff0a33f1 100644 --- a/gui/src/renderer/components/RelayRow.tsx +++ b/gui/src/renderer/components/RelayRow.tsx @@ -7,6 +7,7 @@ import RelayStatusIndicator from './RelayStatusIndicator'; interface IProps { location: RelayLocation; + active: boolean; hostname: string; selected: boolean; onSelect?: (location: RelayLocation) => void; @@ -30,6 +31,7 @@ export default class RelayRow extends Component<IProps> { return ( oldProps.hostname === nextProps.hostname && oldProps.selected === nextProps.selected && + oldProps.active === nextProps.active && compareRelayLocation(oldProps.location, nextProps.location) ); } @@ -43,8 +45,9 @@ export default class RelayRow extends Component<IProps> { <Cell.CellButton onPress={this.handlePress} cellHoverStyle={this.props.selected ? styles.selected : undefined} + disabled={!this.props.active} style={[styles.base, this.props.selected ? styles.selected : undefined]}> - <RelayStatusIndicator isActive={true} isSelected={this.props.selected} /> + <RelayStatusIndicator isActive={this.props.active} isSelected={this.props.selected} /> <Cell.Label>{this.props.hostname}</Cell.Label> </Cell.CellButton> diff --git a/gui/src/renderer/redux/settings/reducers.ts b/gui/src/renderer/redux/settings/reducers.ts index 80cc2ee5c9..fed04b38e4 100644 --- a/gui/src/renderer/redux/settings/reducers.ts +++ b/gui/src/renderer/redux/settings/reducers.ts @@ -47,6 +47,7 @@ export interface IRelayLocationRelayRedux { hostname: string; ipv4AddrIn: string; includeInCountry: boolean; + active: boolean; weight: number; } diff --git a/gui/src/shared/daemon-rpc-types.ts b/gui/src/shared/daemon-rpc-types.ts index 86dd5ab9b2..346b766e1b 100644 --- a/gui/src/shared/daemon-rpc-types.ts +++ b/gui/src/shared/daemon-rpc-types.ts @@ -198,6 +198,7 @@ export interface IRelayListHostname { hostname: string; ipv4AddrIn: string; includeInCountry: boolean; + active: boolean; weight: number; tunnels?: IRelayTunnels; bridges?: IRelayBridges; |
