Commit 3d69bb78 authored by Max Lv's avatar Max Lv

fix port format check

parent edeae5b3
...@@ -965,12 +965,12 @@ class Shadowsocks ...@@ -965,12 +965,12 @@ class Shadowsocks
!isTextEmpty(text, getString(R.string.proxy_empty)) !isTextEmpty(text, getString(R.string.proxy_empty))
} }
def checkNumber(key: String): Boolean = { def checkNumber(key: String, low: Boolean): Boolean = {
val text = settings.getString(key, "") val text = settings.getString(key, "")
if (isTextEmpty(text, getString(R.string.port_empty))) return false if (isTextEmpty(text, getString(R.string.port_empty))) return false
try { try {
val port: Int = Integer.valueOf(text) val port: Int = Integer.valueOf(text)
if (port <= 1024) { if (!low && port <= 1024) {
Crouton.makeText(this, R.string.port_alert, Style.ALERT).show() Crouton.makeText(this, R.string.port_alert, Style.ALERT).show()
return false return false
} }
...@@ -987,8 +987,8 @@ class Shadowsocks ...@@ -987,8 +987,8 @@ class Shadowsocks
if (!checkText(Key.proxy)) return false if (!checkText(Key.proxy)) return false
if (!checkText(Key.sitekey)) return false if (!checkText(Key.sitekey)) return false
if (!checkNumber(Key.localPort)) return false if (!checkNumber(Key.localPort, low = false)) return false
if (!checkNumber(Key.remotePort)) return false if (!checkNumber(Key.remotePort, low = true)) return false
if (bgService == null) return false if (bgService == null) return false
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment