mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-05 03:02:06 +00:00
add support anytls for singbox, add support mieru for clash
This commit is contained in:
1 parent
ebf6a08449
commit
e4b3ee816d
4 files changed
+104
-6
No files matched your search
@@ -573,6 +573,25 @@ proxyToClash(std::vector<Proxy> &nodes, YAML::Node &yamlnode, const ProxyGroupCo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ProxyType::Mieru:
|
||||||
|
singleproxy["type"] = "mieru";
|
||||||
|
if (!x.Password.empty()) {
|
||||||
|
singleproxy["password"] = x.Password;
|
||||||
|
}
|
||||||
|
if (!x.Username.empty()) {
|
||||||
|
singleproxy["username"] = x.Username;
|
||||||
|
}
|
||||||
|
if (!x.Multiplexing.empty()) {
|
||||||
|
singleproxy["multiplexing"] = x.Multiplexing;
|
||||||
|
}
|
||||||
|
if (!x.TransferProtocol.empty()) {
|
||||||
|
singleproxy["transport"] = x.TransferProtocol;
|
||||||
|
}
|
||||||
|
if (!x.Ports.empty()) {
|
||||||
|
singleproxy["port-range"] = x.Ports;
|
||||||
|
singleproxy.remove("port");
|
||||||
|
}
|
||||||
|
break;
|
||||||
case ProxyType::VLESS:
|
case ProxyType::VLESS:
|
||||||
singleproxy["type"] = "vless";
|
singleproxy["type"] = "vless";
|
||||||
singleproxy["uuid"] = x.UserId;
|
singleproxy["uuid"] = x.UserId;
|
||||||
@@ -2709,6 +2728,29 @@ proxyToSingBox(std::vector<Proxy> &nodes, rapidjson::Document &json,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ProxyType::AnyTLS: {
|
||||||
|
addSingBoxCommonMembers(proxy, x, "anytls", allocator);
|
||||||
|
proxy.AddMember("password", rapidjson::StringRef(x.Password.c_str()), allocator);
|
||||||
|
rapidjson::Value tls(rapidjson::kObjectType);
|
||||||
|
tls.AddMember("enabled", true, allocator);
|
||||||
|
if (!scv.is_undef()) {
|
||||||
|
tls.AddMember("insecure", buildBooleanValue(scv), allocator);
|
||||||
|
}
|
||||||
|
if (!x.SNI.empty())
|
||||||
|
tls.AddMember("server_name", rapidjson::StringRef(x.SNI.c_str()), allocator);
|
||||||
|
if (!x.AlpnList.empty()) {
|
||||||
|
auto alpns = vectorToJsonArray(x.AlpnList, allocator);
|
||||||
|
tls.AddMember("alpn", alpns, allocator);
|
||||||
|
}
|
||||||
|
if (!x.Fingerprint.empty()) {
|
||||||
|
rapidjson::Value utls(rapidjson::kObjectType);
|
||||||
|
utls.AddMember("enabled", true, allocator);
|
||||||
|
utls.AddMember("fingerprint", rapidjson::StringRef(x.Fingerprint.c_str()), allocator);
|
||||||
|
proxy.AddMember("utls", utls, allocator);
|
||||||
|
}
|
||||||
|
proxy.AddMember("tls", tls, allocator);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ enum class ProxyType
|
|||||||
Hysteria,
|
Hysteria,
|
||||||
Hysteria2,
|
Hysteria2,
|
||||||
TUIC,
|
TUIC,
|
||||||
AnyTLS
|
AnyTLS,
|
||||||
|
Mieru
|
||||||
};
|
};
|
||||||
|
|
||||||
inline String getProxyTypeName(ProxyType type) {
|
inline String getProxyTypeName(ProxyType type) {
|
||||||
@@ -142,6 +143,7 @@ struct Proxy {
|
|||||||
String UnderlyingProxy;
|
String UnderlyingProxy;
|
||||||
std::vector<String> AlpnList;
|
std::vector<String> AlpnList;
|
||||||
String PacketEncoding;
|
String PacketEncoding;
|
||||||
|
String Multiplexing;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SS_DEFAULT_GROUP "SSProvider"
|
#define SS_DEFAULT_GROUP "SSProvider"
|
||||||
@@ -157,4 +159,5 @@ struct Proxy {
|
|||||||
#define HYSTERIA2_DEFAULT_GROUP "Hysteria2Provider"
|
#define HYSTERIA2_DEFAULT_GROUP "Hysteria2Provider"
|
||||||
#define TUIC_DEFAULT_GROUP "TuicProvider"
|
#define TUIC_DEFAULT_GROUP "TuicProvider"
|
||||||
#define ANYTLS_DEFAULT_GROUP "AnyTLSProvider"
|
#define ANYTLS_DEFAULT_GROUP "AnyTLSProvider"
|
||||||
|
#define MIERU_DEFAULT_GROUP "MieruProvider"
|
||||||
#endif // PROXY_H_INCLUDED
|
#endif // PROXY_H_INCLUDED
|
||||||
@@ -201,7 +201,7 @@ void anyTlSConstruct(Proxy &node, const std::string &group, const std::string &r
|
|||||||
tribool tfo, tribool scv,
|
tribool tfo, tribool scv,
|
||||||
tribool tls13, const std::string &underlying_proxy, uint16_t idleSessionCheckInterval,
|
tribool tls13, const std::string &underlying_proxy, uint16_t idleSessionCheckInterval,
|
||||||
uint16_t idleSessionTimeout, uint16_t minIdleSession) {
|
uint16_t idleSessionTimeout, uint16_t minIdleSession) {
|
||||||
commonConstruct(node, ProxyType::AnyTLS, group, remarks, host, port, udp, tfo, scv, tls13, underlying_proxy);
|
commonConstruct(node, ProxyType::Mieru, group, remarks, host, port, udp, tfo, scv, tls13, underlying_proxy);
|
||||||
node.Host = trim(host);
|
node.Host = trim(host);
|
||||||
node.Password = password;
|
node.Password = password;
|
||||||
node.AlpnList = AlpnList;
|
node.AlpnList = AlpnList;
|
||||||
@@ -212,6 +212,21 @@ void anyTlSConstruct(Proxy &node, const std::string &group, const std::string &r
|
|||||||
node.MinIdleSession = minIdleSession;
|
node.MinIdleSession = minIdleSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mieruConstruct(Proxy &node, const std::string &group, const std::string &remarks,
|
||||||
|
const std::string &port, const std::string &password,
|
||||||
|
const std::string &host, const std::string &ports,
|
||||||
|
const std::string &username, const std::string &multiplexing,
|
||||||
|
const std::string &transfer_protocol, tribool udp,
|
||||||
|
tribool tfo, tribool scv,
|
||||||
|
tribool tls13, const std::string &underlying_proxy) {
|
||||||
|
commonConstruct(node, ProxyType::AnyTLS, group, remarks, host, port, udp, tfo, scv, tls13, underlying_proxy);
|
||||||
|
node.Host = trim(host);
|
||||||
|
node.Password = password;
|
||||||
|
node.Ports = ports;
|
||||||
|
node.TransferProtocol = transfer_protocol;
|
||||||
|
node.Username = username;
|
||||||
|
node.Multiplexing = multiplexing.empty() ? "MULTIPLEXING_LOW" : trim(multiplexing);
|
||||||
|
}
|
||||||
|
|
||||||
void vlessConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &add,
|
void vlessConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &add,
|
||||||
const std::string &port, const std::string &type, const std::string &id, const std::string &aid,
|
const std::string &port, const std::string &type, const std::string &id, const std::string &aid,
|
||||||
@@ -1144,7 +1159,7 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes) {
|
|||||||
string_array dns_server;
|
string_array dns_server;
|
||||||
std::vector<String> alpns;
|
std::vector<String> alpns;
|
||||||
String alpn2;
|
String alpn2;
|
||||||
std::string fingerprint;
|
std::string fingerprint, multiplexing, transfer_protocol;
|
||||||
tribool udp, tfo, scv;
|
tribool udp, tfo, scv;
|
||||||
bool reduceRtt, disableSni; //tuic
|
bool reduceRtt, disableSni; //tuic
|
||||||
std::vector<std::string> alpnList;
|
std::vector<std::string> alpnList;
|
||||||
@@ -1480,7 +1495,7 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes) {
|
|||||||
singleproxy["password"] >>= password;
|
singleproxy["password"] >>= password;
|
||||||
singleproxy["sni"] >>= sni;
|
singleproxy["sni"] >>= sni;
|
||||||
|
|
||||||
if (!singleproxy["alpn"].IsNull()&& singleproxy["alpn"].size() >= 1) {
|
if (!singleproxy["alpn"].IsNull() && singleproxy["alpn"].size() >= 1) {
|
||||||
singleproxy["alpn"][0] >>= alpn;
|
singleproxy["alpn"][0] >>= alpn;
|
||||||
alpns.push_back(alpn);
|
alpns.push_back(alpn);
|
||||||
if (singleproxy["alpn"].size() >= 2 && !singleproxy["alpn"][1].IsNull()) {
|
if (singleproxy["alpn"].size() >= 2 && !singleproxy["alpn"][1].IsNull()) {
|
||||||
@@ -1491,7 +1506,24 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes) {
|
|||||||
singleproxy["client-fingerprint"] >>= fingerprint;
|
singleproxy["client-fingerprint"] >>= fingerprint;
|
||||||
anyTlSConstruct(node, ANYTLS_DEFAULT_GROUP, ps, port, password, server, alpns, fingerprint, sni,
|
anyTlSConstruct(node, ANYTLS_DEFAULT_GROUP, ps, port, password, server, alpns, fingerprint, sni,
|
||||||
udp,
|
udp,
|
||||||
tribool(), scv, tribool(),"",30,30,0);
|
tribool(), scv, tribool(), "", 30, 30, 0);
|
||||||
|
break;
|
||||||
|
case "mieru"_hash:
|
||||||
|
group = MIERU_DEFAULT_GROUP;
|
||||||
|
singleproxy["password"] >>= password;
|
||||||
|
singleproxy["username"] >>= user;
|
||||||
|
singleproxy["port-range"] >>= ports;
|
||||||
|
if (!singleproxy["multiplexing"].IsNull()) {
|
||||||
|
singleproxy["multiplexing"] >>= multiplexing;
|
||||||
|
}
|
||||||
|
transfer_protocol = "TCP";
|
||||||
|
if (!singleproxy["transport"].IsNull()) {
|
||||||
|
singleproxy["transport"] >>= transfer_protocol;
|
||||||
|
}
|
||||||
|
mieruConstruct(node, MIERU_DEFAULT_GROUP, ps, port, password, server, ports, user, multiplexing,
|
||||||
|
transfer_protocol,
|
||||||
|
udp,
|
||||||
|
tribool(), scv, tribool(), "");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
@@ -2751,6 +2783,7 @@ void explodeSingbox(rapidjson::Value &outbounds, std::vector<Proxy> &nodes) {
|
|||||||
std::string auth, up, down, obfsParam, insecure, alpn; //hysteria
|
std::string auth, up, down, obfsParam, insecure, alpn; //hysteria
|
||||||
std::string obfsPassword; //hysteria2
|
std::string obfsPassword; //hysteria2
|
||||||
string_array dns_server;
|
string_array dns_server;
|
||||||
|
std::string fingerprint;
|
||||||
std::string congestion_control, udp_relay_mode; //quic
|
std::string congestion_control, udp_relay_mode; //quic
|
||||||
tribool udp, tfo, scv, rrt, disableSni;
|
tribool udp, tfo, scv, rrt, disableSni;
|
||||||
rapidjson::Value singboxNode = outbounds[i].GetObject();
|
rapidjson::Value singboxNode = outbounds[i].GetObject();
|
||||||
@@ -2800,6 +2833,12 @@ void explodeSingbox(rapidjson::Value &outbounds, std::vector<Proxy> &nodes) {
|
|||||||
sid = reality["short_id"].GetString();
|
sid = reality["short_id"].GetString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (tlsObj.HasMember("utls") && tlsObj["utls"].IsObject()) {
|
||||||
|
if (rapidjson::Value reality = tlsObj["utls"].GetObject();
|
||||||
|
reality.HasMember("fingerprint") && reality["fingerprint"].IsString()) {
|
||||||
|
fingerprint = reality["fingerprint"].GetString();
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
tls = "false";
|
tls = "false";
|
||||||
}
|
}
|
||||||
@@ -2919,6 +2958,14 @@ void explodeSingbox(rapidjson::Value &outbounds, std::vector<Proxy> &nodes) {
|
|||||||
obfsParam, insecure, ports, sni,
|
obfsParam, insecure, ports, sni,
|
||||||
udp, tfo, scv);
|
udp, tfo, scv);
|
||||||
break;
|
break;
|
||||||
|
case "anytls"_hash:
|
||||||
|
group = ANYTLS_DEFAULT_GROUP;
|
||||||
|
password = GetMember(singboxNode, "password");
|
||||||
|
anyTlSConstruct(node, ANYTLS_DEFAULT_GROUP, ps, port, password, server, alpnList, fingerprint,
|
||||||
|
sni,
|
||||||
|
udp,
|
||||||
|
tribool(), scv, tribool(), "", 30, 30, 0);
|
||||||
|
break;
|
||||||
case "hysteria2"_hash:
|
case "hysteria2"_hash:
|
||||||
group = HYSTERIA2_DEFAULT_GROUP;
|
group = HYSTERIA2_DEFAULT_GROUP;
|
||||||
password = GetMember(singboxNode, "password");
|
password = GetMember(singboxNode, "password");
|
||||||
|
|||||||
@@ -95,7 +95,13 @@ void tuicConstruct(Proxy &node, const std::string &group, const std::string &rem
|
|||||||
tribool udp = tribool(), tribool tfo = tribool(),
|
tribool udp = tribool(), tribool tfo = tribool(),
|
||||||
tribool scv = tribool(), tribool reduceRtt = tribool(), tribool disableSni = tribool(),
|
tribool scv = tribool(), tribool reduceRtt = tribool(), tribool disableSni = tribool(),
|
||||||
uint16_t request_timeout = 15000,const std::string& underlying_proxy="");
|
uint16_t request_timeout = 15000,const std::string& underlying_proxy="");
|
||||||
|
void mieruConstruct(Proxy &node, const std::string &group, const std::string &remarks,
|
||||||
|
const std::string &port, const std::string &password,
|
||||||
|
const std::string &host, const std::string &ports,
|
||||||
|
const std::string &username,const std::string &multiplexing,
|
||||||
|
const std::string &transfer_protocol, tribool udp,
|
||||||
|
tribool tfo, tribool scv,
|
||||||
|
tribool tls13, const std::string &underlying_proxy);
|
||||||
void explodeVmess(std::string vmess, Proxy &node);
|
void explodeVmess(std::string vmess, Proxy &node);
|
||||||
|
|
||||||
void explodeSSR(std::string ssr, Proxy &node);
|
void explodeSSR(std::string ssr, Proxy &node);
|
||||||
|
|||||||
Reference in new issue
Block a user