Fix issues about SIP002
This commit is contained in:
@@ -96,12 +96,12 @@ class Profile {
|
||||
def toUri: Uri = {
|
||||
val builder = new Uri.Builder()
|
||||
.scheme("ss")
|
||||
.authority("%s@%s:%d".formatLocal(Locale.ENGLISH,
|
||||
.encodedAuthority("%s@%s:%d".formatLocal(Locale.ENGLISH,
|
||||
Base64.encodeToString("%s:%s".formatLocal(Locale.ENGLISH, method, password).getBytes,
|
||||
Base64.NO_PADDING | Base64.NO_WRAP | Base64.URL_SAFE), host, remotePort))
|
||||
val configuration = new PluginConfiguration(plugin)
|
||||
if (configuration.selected.nonEmpty)
|
||||
builder.appendQueryParameter(Key.plugin, configuration.selectedOptions.toString)
|
||||
builder.appendQueryParameter(Key.plugin, configuration.selectedOptions.toString(false))
|
||||
if (!nameIsEmpty) builder.fragment(name)
|
||||
builder.build()
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
package com.github.shadowsocks.utils
|
||||
|
||||
import android.net.Uri
|
||||
import android.util.Log
|
||||
import android.util.{Base64, Log}
|
||||
import com.github.shadowsocks.database.Profile
|
||||
|
||||
object Parser {
|
||||
@@ -48,18 +48,21 @@ object Parser {
|
||||
Log.e(TAG, "Unrecognized URI: " + m.matched)
|
||||
null
|
||||
}
|
||||
case userInfoPattern(method, password) =>
|
||||
val profile = new Profile
|
||||
profile.method = method
|
||||
profile.password = password
|
||||
profile.host = uri.getHost
|
||||
profile.remotePort = uri.getPort
|
||||
profile.plugin = uri.getQueryParameter(Key.plugin)
|
||||
profile.name = uri.getFragment
|
||||
profile
|
||||
case _ =>
|
||||
Log.e(TAG, "Unknown user info: " + m.matched)
|
||||
null
|
||||
case userInfo =>
|
||||
new String(Base64.decode(userInfo, Base64.NO_PADDING | Base64.NO_WRAP | Base64.URL_SAFE)) match {
|
||||
case userInfoPattern(method, password) =>
|
||||
val profile = new Profile
|
||||
profile.method = method
|
||||
profile.password = password
|
||||
profile.host = uri.getHost
|
||||
profile.remotePort = uri.getPort
|
||||
profile.plugin = uri.getQueryParameter(Key.plugin)
|
||||
profile.name = uri.getFragment
|
||||
profile
|
||||
case _ =>
|
||||
Log.e(TAG, "Unknown user info: " + m.matched)
|
||||
null
|
||||
}
|
||||
}
|
||||
}).filter(_ != null)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user