mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-05 03:02:06 +00:00
Fix bug.(#30)
This commit is contained in:
1 parent
e22f043213
commit
c4aa8c5b5e
2 files changed
+33
-1
No files matched your search
@@ -534,11 +534,14 @@ proxyToClash(std::vector<Proxy> &nodes, YAML::Node &yamlnode, const ProxyGroupCo
|
|||||||
if (!x.ServerName.empty())
|
if (!x.ServerName.empty())
|
||||||
singleproxy["servername"] = x.ServerName;
|
singleproxy["servername"] = x.ServerName;
|
||||||
if (!x.ShortId.empty()) {
|
if (!x.ShortId.empty()) {
|
||||||
singleproxy["reality-opts"]["short-id"] = x.ShortId;
|
singleproxy["reality-opts"]["short-id"] = ""+x.ShortId;
|
||||||
}
|
}
|
||||||
if (!x.PublicKey.empty() || x.Flow == "xtls-rprx-vision") {
|
if (!x.PublicKey.empty() || x.Flow == "xtls-rprx-vision") {
|
||||||
singleproxy["client-fingerprint"] = "chrome";
|
singleproxy["client-fingerprint"] = "chrome";
|
||||||
}
|
}
|
||||||
|
if(!x.Fingerprint.empty()){
|
||||||
|
singleproxy["client-fingerprint"] = x.Fingerprint;
|
||||||
|
}
|
||||||
switch (hash_(x.TransferProtocol)) {
|
switch (hash_(x.TransferProtocol)) {
|
||||||
case "tcp"_hash:
|
case "tcp"_hash:
|
||||||
singleproxy["network"] = x.TransferProtocol;
|
singleproxy["network"] = x.TransferProtocol;
|
||||||
@@ -678,6 +681,33 @@ proxyToClash(std::vector<Proxy> &nodes, YAML::Node &yamlnode, const ProxyGroupCo
|
|||||||
yamlnode["Proxy Group"] = original_groups;
|
yamlnode["Proxy Group"] = original_groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void formatterShortId(std::string &input){
|
||||||
|
std::string target = "short-id:";
|
||||||
|
size_t startPos = input.find(target);
|
||||||
|
|
||||||
|
while (startPos != std::string::npos) {
|
||||||
|
// 查找对应实例的结束位置
|
||||||
|
size_t endPos = input.find("}", startPos);
|
||||||
|
|
||||||
|
if (endPos != std::string::npos) {
|
||||||
|
// 提取原始id
|
||||||
|
std::string originalId = input.substr(startPos + target.length(), endPos - startPos - target.length());
|
||||||
|
|
||||||
|
// 去除原始id中的空格
|
||||||
|
originalId.erase(remove_if(originalId.begin(), originalId.end(), ::isspace), originalId.end());
|
||||||
|
|
||||||
|
// 添加引号
|
||||||
|
std::string modifiedId = "\"" + originalId + "\"";
|
||||||
|
|
||||||
|
// 替换原始id为修改后的id
|
||||||
|
input.replace(startPos + target.length(), endPos - startPos - target.length(), modifiedId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 继续查找下一个实例
|
||||||
|
startPos = input.find(target, startPos + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
std::string proxyToClash(std::vector<Proxy> &nodes, const std::string &base_conf,
|
std::string proxyToClash(std::vector<Proxy> &nodes, const std::string &base_conf,
|
||||||
std::vector<RulesetContent> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group,
|
std::vector<RulesetContent> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group,
|
||||||
bool clashR, extra_settings &ext) {
|
bool clashR, extra_settings &ext) {
|
||||||
@@ -725,6 +755,7 @@ std::string proxyToClash(std::vector<Proxy> &nodes, const std::string &base_conf
|
|||||||
//rulesetToClash(yamlnode, ruleset_content_array, ext.overwrite_original_rules, ext.clash_new_field_name);
|
//rulesetToClash(yamlnode, ruleset_content_array, ext.overwrite_original_rules, ext.clash_new_field_name);
|
||||||
//std::string output_content = YAML::Dump(yamlnode);
|
//std::string output_content = YAML::Dump(yamlnode);
|
||||||
replaceAll(output_content, "!<str> ", "");
|
replaceAll(output_content, "!<str> ", "");
|
||||||
|
formatterShortId(output_content);
|
||||||
return output_content;
|
return output_content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1342,6 +1342,7 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes) {
|
|||||||
singleproxy["reality-opts"]["short-id"] >>= sid;
|
singleproxy["reality-opts"]["short-id"] >>= sid;
|
||||||
}
|
}
|
||||||
singleproxy["flow"] >>= flow;
|
singleproxy["flow"] >>= flow;
|
||||||
|
singleproxy["client-fingerprint"] >>= fp;
|
||||||
|
|
||||||
vlessConstruct(node, XRAY_DEFAULT_GROUP, ps, server, port, type, id, aid, net, "auto", flow, mode, path,
|
vlessConstruct(node, XRAY_DEFAULT_GROUP, ps, server, port, type, id, aid, net, "auto", flow, mode, path,
|
||||||
host, "", tls, pbk, sid, fp, sni);
|
host, "", tls, pbk, sid, fp, sni);
|
||||||
|
|||||||
Reference in new issue
Block a user