mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-26 05:24:43 +00:00
validity of host
This commit is contained in:
+5
-1
@@ -290,6 +290,7 @@ fun SocksProxySettings(
|
||||
) ||
|
||||
!validCredential(usernameUnsaved.value.text) ||
|
||||
!validCredential(passwordUnsaved.value.text) ||
|
||||
!validHost(hostUnsaved.value.text) ||
|
||||
!validPort(portUnsaved.value.text)
|
||||
val resetDisabled = hostUnsaved.value.text.trim() == "localhost" && portUnsaved.value.text.trim() == "9050" && proxyAuthRandomUnsaved.value && onionHosts.value == NetCfg.defaults.onionHosts
|
||||
ModalView(
|
||||
@@ -316,7 +317,7 @@ fun SocksProxySettings(
|
||||
hostUnsaved,
|
||||
stringResource(MR.strings.host_verb),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
isValid = { true },
|
||||
isValid = ::validHost,
|
||||
keyboardActions = KeyboardActions(onNext = { defaultKeyboardAction(ImeAction.Next) }),
|
||||
keyboardType = KeyboardType.Text,
|
||||
)
|
||||
@@ -483,6 +484,9 @@ fun SessionModePicker(
|
||||
)
|
||||
}
|
||||
|
||||
private fun validHost(s: String): Boolean =
|
||||
!s.contains('@')
|
||||
|
||||
// https://ihateregex.io/expr/port/
|
||||
fun validPort(s: String): Boolean {
|
||||
val validPort = Regex("^(6553[0-5])|(655[0-2][0-9])|(65[0-4][0-9]{2})|(6[0-4][0-9]{3})|([1-5][0-9]{4})|([0-5]{0,5})|([0-9]{1,4})$")
|
||||
|
||||
Reference in New Issue
Block a user