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,34 +8,29 @@
|
|||||||
namespace Configs {
|
namespace Configs {
|
||||||
bool shadowsocks::ParseFromLink(const QString& link)
|
bool shadowsocks::ParseFromLink(const QString& link)
|
||||||
{
|
{
|
||||||
auto url = QUrl(link);
|
QUrl url;
|
||||||
if (!url.isValid()) return false;
|
|
||||||
auto query = QUrlQuery(url.query(QUrl::ComponentFormattingOption::FullyDecoded));
|
|
||||||
|
|
||||||
outbound::ParseFromLink(link);
|
|
||||||
|
|
||||||
if (SubStrBefore(link, "#").contains("@")) {
|
if (SubStrBefore(link, "#").contains("@")) {
|
||||||
// Traditional SS format
|
url = QUrl(link);
|
||||||
if (url.password().isEmpty()) {
|
|
||||||
// Traditional format: method:password base64 encoded in username
|
|
||||||
auto method_password = DecodeB64IfValid(url.userName(), QByteArray::Base64Option::Base64UrlEncoding);
|
|
||||||
if (method_password.isEmpty()) return false;
|
|
||||||
method = SubStrBefore(method_password, ":");
|
|
||||||
password = SubStrAfter(method_password, ":");
|
|
||||||
} else {
|
|
||||||
// 2022 format: method in username, password in password
|
|
||||||
method = url.userName();
|
|
||||||
password = url.password();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// v2rayN format: base64 encoded full URL
|
// v2rayN format: base64 encoded full URL
|
||||||
QString linkN = DecodeB64IfValid(SubStrBefore(SubStrAfter(link, "://"), "#"), QByteArray::Base64Option::Base64UrlEncoding);
|
QString linkN = DecodeB64IfValid(SubStrBefore(SubStrAfter(link, "://"), "#"), QByteArray::Base64Option::Base64UrlEncoding);
|
||||||
if (linkN.isEmpty()) return false;
|
if (linkN.isEmpty()) return false;
|
||||||
if (link.contains("#")) linkN += "#" + SubStrAfter(link, "#");
|
if (link.contains("#")) linkN += "#" + SubStrAfter(link, "#");
|
||||||
url = QUrl("https://" + linkN);
|
url = QUrl("https://" + linkN);
|
||||||
if (!url.isValid()) return false;
|
}
|
||||||
query = QUrlQuery(url.query(QUrl::ComponentFormattingOption::FullyDecoded));
|
if (!url.isValid()) return false;
|
||||||
outbound::ParseFromLink(url.toString());
|
auto query = QUrlQuery(url.query(QUrl::ComponentFormattingOption::FullyDecoded));
|
||||||
|
outbound::ParseFromLink(url.toString());
|
||||||
|
|
||||||
|
// Traditional SS format
|
||||||
|
if (url.password().isEmpty()) {
|
||||||
|
// Traditional format: method:password base64 encoded in username
|
||||||
|
auto method_password = DecodeB64IfValid(url.userName(), QByteArray::Base64Option::Base64UrlEncoding);
|
||||||
|
if (method_password.isEmpty()) return false;
|
||||||
|
method = SubStrBefore(method_password, ":");
|
||||||
|
password = SubStrAfter(method_password, ":");
|
||||||
|
} else {
|
||||||
|
// 2022 format: method in username, password in password
|
||||||
method = url.userName();
|
method = url.userName();
|
||||||
password = url.password();
|
password = url.password();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user