fix surge error,(#27) (#28)

This commit is contained in:
asdlokj1qpi23
2025-04-27 11:13:36 +08:00
parent 97192f9e5d
commit 4787d821bd

View File

@@ -37,6 +37,15 @@ const string_array clash_ssr_ciphers = {
"rc4-md5", "aes-128-ctr", "aes-192-ctr", "aes-256-ctr", "aes-128-cfb",
"aes-192-cfb", "aes-256-cfb", "chacha20-ietf", "xchacha20", "none"
};
bool isNumeric(const std::string &str) {
for (char c: str) {
if (!std::isdigit(static_cast<unsigned char>(c))) {
return false;
}
}
return true;
}
std::string
vmessLinkConstruct(const std::string &remarks, const std::string &add, const std::string &port, const std::string &type,
@@ -930,6 +939,7 @@ std::string proxyToSurge(std::vector<Proxy> &nodes, const std::string &base_conf
std::string proxy, section, real_section;
string_array args, headers;
std::string search = " Mbps";
switch (x.Type) {
case ProxyType::Shadowsocks:
@@ -1059,8 +1069,15 @@ std::string proxyToSurge(std::vector<Proxy> &nodes, const std::string &base_conf
if (surge_ver < 4)
continue;
proxy = "hysteria, " + hostname + ", " + port + ", password=" + password;
if (x.DownSpeed)
proxy += ", download-bandwidth=" + x.DownSpeed;
if (!x.DownMbps.empty()) {
if (!isNumeric(x.DownMbps)) {
size_t pos = x.DownMbps.find(search);
if (pos != std::string::npos) {
x.DownMbps.replace(pos, search.length(), "");
}
}
proxy += ", download-bandwidth=" +x.DownMbps;
}
if (!scv.is_undef())
proxy += ",skip-cert-verify=" + std::string(scv.get() ? "true" : "false");
@@ -2517,15 +2534,6 @@ vectorToJsonArray(const std::vector<std::string> &array, rapidjson::MemoryPoolAl
return result;
}
bool isNumeric(const std::string &str) {
for (char c: str) {
if (!std::isdigit(static_cast<unsigned char>(c))) {
return false;
}
}
return true;
}
void
proxyToSingBox(std::vector<Proxy> &nodes, rapidjson::Document &json,
std::vector<RulesetContent> &ruleset_content_array,