Refine #989
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
|
||||
package com.github.shadowsocks.database
|
||||
|
||||
import java.net.URLEncoder
|
||||
import java.util.Locale
|
||||
|
||||
import android.os.Binder
|
||||
@@ -95,7 +96,8 @@ class Profile {
|
||||
var kcpcli: String = "--crypt none --mode normal --mtu 1200 --nocomp --dscp 46 --parityshard 0"
|
||||
|
||||
override def toString = "ss://" + Base64.encodeToString("%s%s:%s@%s:%d".formatLocal(Locale.ENGLISH,
|
||||
method, if (auth) "-auth" else "", password, host, remotePort).getBytes, Base64.NO_PADDING | Base64.NO_WRAP)
|
||||
method, if (auth) "-auth" else "", password, host, remotePort).getBytes, Base64.NO_PADDING | Base64.NO_WRAP) +
|
||||
'#' + URLEncoder.encode(name, "utf-8")
|
||||
|
||||
def isMethodUnsafe = "table".equalsIgnoreCase(method) || "rc4".equalsIgnoreCase(method)
|
||||
}
|
||||
|
||||
@@ -20,12 +20,14 @@
|
||||
|
||||
package com.github.shadowsocks.utils
|
||||
|
||||
import java.net.URLDecoder
|
||||
|
||||
import android.util.{Base64, Log}
|
||||
import com.github.shadowsocks.database.Profile
|
||||
|
||||
object Parser {
|
||||
val TAG = "ShadowParser"
|
||||
private val pattern = "(?i)ss://([A-Za-z0-9+-/=_]+)(#.+)?".r
|
||||
private val pattern = "(?i)ss://([A-Za-z0-9+-/=_]+)(#(.+))?".r
|
||||
private val decodedPattern = "(?i)^((.+?)(-auth)??:(.*)@(.+?):(\\d+?))$".r
|
||||
|
||||
def findAll(data: CharSequence) = pattern.findAllMatchIn(if (data == null) "" else data).map(m => try
|
||||
@@ -38,7 +40,7 @@ object Parser {
|
||||
profile.name = ss.group(5)
|
||||
profile.host = profile.name
|
||||
profile.remotePort = ss.group(6).toInt
|
||||
if (m.group(2) != null) profile.name = m.group(2).substring(1)
|
||||
if (m.group(2) != null) profile.name = URLDecoder.decode(m.group(3), "utf-8")
|
||||
profile
|
||||
case _ => null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user