mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2025-12-10 21:22:22 +00:00
Fix error in parsing ShadowsocksR configurations
Fix code style.
This commit is contained in:
@@ -528,7 +528,7 @@ void explodeSSConf(std::string content, std::vector<Proxy> &nodes)
|
||||
void explodeSSR(std::string ssr, Proxy &node)
|
||||
{
|
||||
std::string strobfs;
|
||||
std::string remarks, group, server, port, method, password, protocol, protoparam, obfs, obfsparam, remarks_base64;
|
||||
std::string remarks, group, server, port, method, password, protocol, protoparam, obfs, obfsparam;
|
||||
ssr = replaceAllDistinct(ssr.substr(6), "\r", "");
|
||||
ssr = urlSafeBase64Decode(ssr);
|
||||
if(strFind(ssr, "/?"))
|
||||
@@ -537,7 +537,6 @@ void explodeSSR(std::string ssr, Proxy &node)
|
||||
ssr = ssr.substr(0, ssr.find("/?"));
|
||||
group = urlSafeBase64Decode(getUrlArg(strobfs, "group"));
|
||||
remarks = urlSafeBase64Decode(getUrlArg(strobfs, "remarks"));
|
||||
remarks_base64 = urlSafeBase64Reverse(getUrlArg(strobfs, "remarks"));
|
||||
obfsparam = regReplace(urlSafeBase64Decode(getUrlArg(strobfs, "obfsparam")), "\\s", "");
|
||||
protoparam = regReplace(urlSafeBase64Decode(getUrlArg(strobfs, "protoparam")), "\\s", "");
|
||||
}
|
||||
@@ -551,10 +550,7 @@ void explodeSSR(std::string ssr, Proxy &node)
|
||||
if(group.empty())
|
||||
group = SSR_DEFAULT_GROUP;
|
||||
if(remarks.empty())
|
||||
{
|
||||
remarks = server + ":" + port;
|
||||
remarks_base64 = base64Encode(remarks);
|
||||
}
|
||||
|
||||
if(find(ss_ciphers.begin(), ss_ciphers.end(), method) != ss_ciphers.end() && (obfs.empty() || obfs == "plain") && (protocol.empty() || protocol == "origin"))
|
||||
{
|
||||
@@ -570,7 +566,7 @@ void explodeSSRConf(std::string content, std::vector<Proxy> &nodes)
|
||||
{
|
||||
Proxy node;
|
||||
Document json;
|
||||
std::string remarks, remarks_base64, group, server, port, method, password, protocol, protoparam, obfs, obfsparam, plugin, pluginopts;
|
||||
std::string remarks, group, server, port, method, password, protocol, protoparam, obfs, obfsparam, plugin, pluginopts;
|
||||
int index = nodes.size();
|
||||
|
||||
json.Parse(content.data());
|
||||
@@ -615,7 +611,6 @@ void explodeSSRConf(std::string content, std::vector<Proxy> &nodes)
|
||||
if(remarks.empty())
|
||||
remarks = server + ":" + port;
|
||||
|
||||
remarks_base64 = GetMember(json["configs"][i], "remarks_base64"); // electron-ssr does not contain this field
|
||||
password = GetMember(json["configs"][i], "password");
|
||||
method = GetMember(json["configs"][i], "method");
|
||||
|
||||
@@ -624,7 +619,7 @@ void explodeSSRConf(std::string content, std::vector<Proxy> &nodes)
|
||||
obfs = GetMember(json["configs"][i], "obfs");
|
||||
obfsparam = GetMember(json["configs"][i], "obfsparam");
|
||||
|
||||
ssrConstruct(node, group, remarks, remarks_base64, server, port, protocol, method, obfs, password, obfsparam, protoparam);
|
||||
ssrConstruct(node, group, remarks, server, port, protocol, method, obfs, password, obfsparam, protoparam);
|
||||
node.Id = index;
|
||||
nodes.emplace_back(std::move(node));
|
||||
node = Proxy();
|
||||
|
||||
@@ -37,7 +37,7 @@ struct script_info
|
||||
|
||||
int timeout_checker(JSRuntime *rt, void *opaque)
|
||||
{
|
||||
script_info info = *((script_info*)opaque);
|
||||
script_info info = *static_cast<script_info*>(opaque);
|
||||
if(info.timeout != 0 && time(NULL) >= info.begin_time + info.timeout) /// timeout reached
|
||||
{
|
||||
writeLog(0, "Script '" + info.name + "' has exceeded timeout " + std::to_string(info.timeout) + ", terminate now.", LOG_LEVEL_WARNING);
|
||||
|
||||
@@ -227,7 +227,7 @@ public:
|
||||
qjs_fetch_Headers headers;
|
||||
std::string cookies;
|
||||
std::string postdata;
|
||||
qjs_fetch_Request(const std::string &url) : url(url) {}
|
||||
explicit qjs_fetch_Request(const std::string &url) : url(url) {}
|
||||
};
|
||||
|
||||
class qjs_fetch_Response
|
||||
@@ -390,14 +390,12 @@ void script_runtime_init(qjs::Runtime &runtime)
|
||||
JS_SetModuleLoaderFunc(runtime.rt, nullptr, js_module_loader, nullptr);
|
||||
}
|
||||
|
||||
int ShowMsgbox(std::string title, std::string content, uint16_t type = 0)
|
||||
int ShowMsgbox(const std::string &title, std::string content, uint16_t type = 0)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if(!type)
|
||||
type = MB_ICONINFORMATION;
|
||||
title = utf8ToACP(title);
|
||||
content = utf8ToACP(content);
|
||||
return MessageBoxA(NULL, content.c_str(), title.c_str(), type);
|
||||
return MessageBoxA(NULL, utf8ToACP(content).c_str(), utf8ToACP(title).c_str(), type);
|
||||
#else
|
||||
return -1;
|
||||
#endif // _WIN32
|
||||
|
||||
@@ -71,30 +71,3 @@ std::string utf8ToACP(const std::string &str_src)
|
||||
return str_src;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// std::string to wstring
|
||||
void stringToWstring(std::wstring& szDst, const std::string &str)
|
||||
{
|
||||
std::string temp = str;
|
||||
int len = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)temp.c_str(), -1, NULL,0);
|
||||
wchar_t* wszUtf8 = new wchar_t[len + 1];
|
||||
memset(wszUtf8, 0, len * 2 + 2);
|
||||
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)temp.c_str(), -1, (LPWSTR)wszUtf8, len);
|
||||
szDst = wszUtf8;
|
||||
//std::wstring r = wszUtf8;
|
||||
delete[] wszUtf8;
|
||||
}
|
||||
|
||||
std::string wstringToString(LPWSTR str)
|
||||
{
|
||||
std::string result;
|
||||
size_t srclen = wcslen(str);
|
||||
size_t len = WideCharToMultiByte(CP_ACP, 0, str, srclen, 0, 0, 0, 0);
|
||||
result.resize(len);
|
||||
WideCharToMultiByte(CP_ACP, 0, str, srclen, result.data(), len, 0, 0);
|
||||
return result;
|
||||
}
|
||||
#else
|
||||
/* Unimplemented: std::codecvt_utf8 */
|
||||
#endif // _WIN32
|
||||
|
||||
@@ -391,7 +391,8 @@ namespace md5 {
|
||||
message_length[0] = 0;
|
||||
message_length[1] = 0;
|
||||
stored_size = 0;
|
||||
memset(&stored, 0, BLOCK_SIZE * 2);
|
||||
memset(stored, 0, BLOCK_SIZE * 2);
|
||||
memset(signature, 0, MD5_SIZE);
|
||||
|
||||
finished = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user