mirror of https://github.com/NekoX-Dev/NekoX.git
This commit is contained in:
parent
f3f6a6a3e6
commit
0c24f4a240
|
@ -46,6 +46,16 @@ object Utils {
|
|||
}
|
||||
}
|
||||
|
||||
fun decodeUrlSafe(text: String): String {
|
||||
val flags = Base64.NO_PADDING or Base64.URL_SAFE or Base64.NO_WRAP
|
||||
try {
|
||||
return Base64.decode(text, flags).toString(charset("UTF-8"))
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* base64 encode
|
||||
*/
|
||||
|
|
|
@ -134,19 +134,25 @@ class ShadowsocksRLoader {
|
|||
|
||||
runCatching {
|
||||
|
||||
bean.obfs_param = Utils.decode(httpUrl.queryParameter("obfsparam")!!)
|
||||
bean.obfs_param = Utils.decodeUrlSafe(httpUrl.queryParameter("obfsparam")!!)
|
||||
|
||||
}
|
||||
|
||||
runCatching {
|
||||
|
||||
bean.protocol_param = Utils.decode(httpUrl.queryParameter("protoparam")!!)
|
||||
bean.protocol_param = Utils.decodeUrlSafe(httpUrl.queryParameter("protoparam")!!)
|
||||
|
||||
}
|
||||
|
||||
runCatching {
|
||||
|
||||
bean.remarks = Utils.decode(httpUrl.queryParameter("remarks")!!)
|
||||
val remarks = httpUrl.queryParameter("remarks")
|
||||
|
||||
if (remarks?.isNotBlank() == true) {
|
||||
|
||||
bean.remarks = Utils.decodeUrlSafe(remarks)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -163,7 +169,7 @@ class ShadowsocksRLoader {
|
|||
Base64.encodeToString("%s".format(Locale.ENGLISH, password).toByteArray(), flags),
|
||||
Base64.encodeToString("%s".format(Locale.ENGLISH, obfs_param).toByteArray(), flags),
|
||||
Base64.encodeToString("%s".format(Locale.ENGLISH, protocol_param).toByteArray(), flags),
|
||||
Base64.encodeToString("%s".format(Locale.ENGLISH, remarks ?: "Exported From NekoX").toByteArray(), flags)).toByteArray(), flags)
|
||||
Base64.encodeToString("%s".format(Locale.ENGLISH, remarks ?: "").toByteArray(), flags)).toByteArray(), flags)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue