mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-18 20:50:09 +08:00
Merge pull request #943 from throneproj/bugfix-942
fix: fix shadowsocks parser
This commit is contained in:
commit
bfd7e438aa
@ -8,13 +8,20 @@
|
||||
namespace Configs {
|
||||
bool shadowsocks::ParseFromLink(const QString& link)
|
||||
{
|
||||
auto url = QUrl(link);
|
||||
QUrl url;
|
||||
if (SubStrBefore(link, "#").contains("@")) {
|
||||
url = QUrl(link);
|
||||
} else {
|
||||
// v2rayN format: base64 encoded full URL
|
||||
QString linkN = DecodeB64IfValid(SubStrBefore(SubStrAfter(link, "://"), "#"), QByteArray::Base64Option::Base64UrlEncoding);
|
||||
if (linkN.isEmpty()) return false;
|
||||
if (link.contains("#")) linkN += "#" + SubStrAfter(link, "#");
|
||||
url = QUrl("https://" + linkN);
|
||||
}
|
||||
if (!url.isValid()) return false;
|
||||
auto query = QUrlQuery(url.query(QUrl::ComponentFormattingOption::FullyDecoded));
|
||||
outbound::ParseFromLink(url.toString());
|
||||
|
||||
outbound::ParseFromLink(link);
|
||||
|
||||
if (SubStrBefore(link, "#").contains("@")) {
|
||||
// Traditional SS format
|
||||
if (url.password().isEmpty()) {
|
||||
// Traditional format: method:password base64 encoded in username
|
||||
@ -27,18 +34,6 @@ namespace Configs {
|
||||
method = url.userName();
|
||||
password = url.password();
|
||||
}
|
||||
} else {
|
||||
// v2rayN format: base64 encoded full URL
|
||||
QString linkN = DecodeB64IfValid(SubStrBefore(SubStrAfter(link, "://"), "#"), QByteArray::Base64Option::Base64UrlEncoding);
|
||||
if (linkN.isEmpty()) return false;
|
||||
if (link.contains("#")) linkN += "#" + SubStrAfter(link, "#");
|
||||
url = QUrl("https://" + linkN);
|
||||
if (!url.isValid()) return false;
|
||||
query = QUrlQuery(url.query(QUrl::ComponentFormattingOption::FullyDecoded));
|
||||
outbound::ParseFromLink(url.toString());
|
||||
method = url.userName();
|
||||
password = url.password();
|
||||
}
|
||||
|
||||
plugin = query.queryItemValue("plugin").replace("simple-obfs;", "obfs-local;");
|
||||
if (query.hasQueryItem("plugin-opts")) plugin_opts = query.queryItemValue("plugin-opts");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user