Skip to content

Commit

Permalink
More fixes based on feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Pururun committed Sep 2, 2024
1 parent 92226fc commit 0069f22
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ val WIREGUARD_PRESET_PORTS = listOf(Port(51820), Port(53))
val UDP2TCP_PRESET_PORTS = listOf(Port(80), Port(5001))
val SHADOWSOCKS_PRESET_PORTS = emptyList<Port>()
val SHADOWSOCKS_AVAILABLE_PORTS =
listOf(PortRange(IntRange(0, 65535))) // Currently we consider all ports to be available
// Currently we consider all ports to be available
listOf(PortRange(IntRange(Port.MIN_VALUE, Port.MAX_VALUE)))
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ShadowsocksSettingsViewModel(
val initialSettings = settingsRepository.settingsUpdates.filterNotNull().first()
customPort.update {
val initialPort = initialSettings.getShadowSocksPort()
if (SHADOWSOCKS_PRESET_PORTS.contains(initialPort.getOrNull()).not()) {
if (initialPort.getOrNull() !in SHADOWSOCKS_PRESET_PORTS) {
initialPort.getOrNull()
} else {
null
Expand All @@ -65,10 +65,7 @@ class ShadowsocksSettingsViewModel(
.setCustomShadowsocksObfuscationPort(port)
.onLeft { Logger.e("Select shadowsocks port error $it") }
.onRight {
if (
port is Constraint.Only &&
SHADOWSOCKS_PRESET_PORTS.contains(port.value).not()
) {
if (port is Constraint.Only && port.value !in SHADOWSOCKS_PRESET_PORTS) {
customPort.update { port.getOrNull() }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class VpnSettingsViewModel(
val initialSettings = repository.settingsUpdates.filterNotNull().first()
customPort.update {
val initialPort = initialSettings.getWireguardPort()
if (WIREGUARD_PRESET_PORTS.contains(initialPort.getOrNull()).not()) {
if (initialPort.getOrNull() !in WIREGUARD_PRESET_PORTS) {
initialPort.getOrNull()
} else {
null
Expand Down Expand Up @@ -223,7 +223,7 @@ class VpnSettingsViewModel(
}

fun onWireguardPortSelected(port: Constraint<Port>) {
if (port is Constraint.Only && WIREGUARD_PRESET_PORTS.contains(port.value).not()) {
if (port is Constraint.Only && port.value !in WIREGUARD_PRESET_PORTS) {
customPort.update { port.value }
}
viewModelScope.launch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ value class Port(val value: Int) : Parcelable {
Port(number)
}

private const val MIN_VALUE = 0
private const val MAX_VALUE = 65535
const val MIN_VALUE = 0
const val MAX_VALUE = 65535
}
}

Expand Down

0 comments on commit 0069f22

Please sign in to comment.