Fix issues about SIP002

This commit is contained in:
Mygod
2017-02-08 11:58:15 +08:00
committed by Max Lv
parent 212c3f666b
commit be5036183d
2 changed files with 18 additions and 15 deletions
@@ -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)
}