Commit be503618 authored by Mygod's avatar Mygod Committed by Max Lv

Fix issues about SIP002

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