Merge pull request #943 from throneproj/bugfix-942

fix: fix shadowsocks parser
This commit is contained in:
parhelia512 2025-11-23 14:45:18 +08:00 committed by GitHub
commit bfd7e438aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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");