Compare commits

...

3 Commits

Author SHA1 Message Date
asdlokj1qpi23
57ed33f96c fix error
Some checks failed
GitHub CI / Linux aarch64 Build (push) Failing after 43s
GitHub CI / Linux amd64 Build (push) Failing after 20s
GitHub CI / Linux armv7 Build (push) Failing after 32s
GitHub CI / Linux x86 Build (push) Failing after 18s
Publish Docker Image / Build linux/386 Image (push) Failing after 6m32s
Publish Docker Image / Build linux/amd64 Image (push) Failing after 27m34s
Publish Docker Image / Build linux/arm/v7 Image (push) Failing after 31m23s
Publish Docker Image / Build linux/arm64 Image (push) Failing after 34m18s
Publish Docker Image / Merge (push) Has been skipped
GitHub CI / macOS arm Build (push) Has been cancelled
GitHub CI / macOS x86 Build (push) Has been cancelled
GitHub CI / Windows amd64 Build (push) Has been cancelled
GitHub CI / Windows x86 Build (push) Has been cancelled
2025-04-18 17:07:25 +08:00
asdlokj1qpi23
eab18a9568 support hy2 and vless for mixed (#2) (#23) (#9) 2025-04-18 17:04:22 +08:00
asdlokj1qpi23
c242e631ba support vless reality for Loon,(#22) 2025-04-18 15:04:42 +08:00
4 changed files with 535 additions and 500 deletions

View File

@@ -1181,22 +1181,24 @@ std::string proxyToSurge(std::vector<Proxy> &nodes, const std::string &base_conf
}
std::string proxyToSingle(std::vector<Proxy> &nodes, int types, extra_settings &ext) {
/// types: SS=1 SSR=2 VMess=4 Trojan=8
/// types: SS=1 SSR=2 VMess=4 Trojan=8,hysteria2=16,vless=32
std::string proxyStr, allLinks;
bool ss = GETBIT(types, 1), ssr = GETBIT(types, 2), vmess = GETBIT(types, 3), trojan = GETBIT(types, 4);
bool ss = GETBIT(types, 1), ssr = GETBIT(types, 2), vmess = GETBIT(types, 3), trojan = GETBIT(types, 4), hysteria2 =
GETBIT(types, 5), vless = GETBIT(types, 6);
for (Proxy &x: nodes) {
std::string remark = x.Remark;
std::string &hostname = x.Hostname, &sni = x.ServerName, &password = x.Password, &method = x.EncryptMethod, &
plugin = x.Plugin, &pluginopts = x.PluginOption, &protocol = x.Protocol, &protoparam = x.
ProtocolParam,
&obfs = x.OBFS, &obfsparam = x.OBFSParam, &id = x.UserId, &transproto = x.TransferProtocol, &host = x.
Host, &
path = x.Path, &faketype = x.FakeType;
ProtocolParam, &flow = x.Flow, &pbk = x.PublicKey, &sid = x.ShortId, &fp = x.Fingerprint,
&packet_encoding = x.PacketEncoding, &fake_type = x.FakeType, &mode = x.GRPCMode,
&obfs = x.OBFS, &obfsparam = x.OBFSParam, &obfsPassword = x.OBFSPassword, &id = x.UserId, &transproto =
x.TransferProtocol, &host = x.
Host, &tls = x.TLSStr, &path = x.Path, &faketype = x.FakeType, &ports = x.Ports;
bool &tlssecure = x.TLSSecure;
std::vector<string> alpns = x.AlpnList;
std::string port = std::to_string(x.Port);
std::string aid = std::to_string(x.AlterId);
switch (x.Type) {
case ProxyType::Shadowsocks:
if (ss) {
@@ -1242,6 +1244,88 @@ std::string proxyToSingle(std::vector<Proxy> &nodes, int types, extra_settings &
vmessLinkConstruct(remark, hostname, port, faketype, id, aid, transproto, path, host,
tlssecure ? "tls" : ""));
break;
case ProxyType::Hysteria2:
if (!hysteria2)
continue;
proxyStr = "hysteria2://" + password + "@" + hostname + ":" + port + (ports.empty() ? "" : "," + ports)
+ "?insecure=" +
(x.AllowInsecure.get() ? "1" : "0");
if (!obfsparam.empty()) {
proxyStr += "&obfs=" + obfsparam;
if (!obfsPassword.empty()) {
proxyStr += "&obfs-password=" + obfsparam;
}
}
if (!sni.empty()) {
proxyStr += "&sni=" + sni;
}
proxyStr += "#" + urlEncode(remark);
break;
case ProxyType::VLESS:
if (!vless)
continue;
// tls = getUrlArg(addition, "security");
// net = getUrlArg(addition, "type");
// flow = getUrlArg(addition, "flow");
// pbk = getUrlArg(addition, "pbk");
// sid = getUrlArg(addition, "sid");
// fp = getUrlArg(addition, "fp");
// std::string packet_encoding = getUrlArg(addition, "packet-encoding");
// std::string alpn = getUrlArg(addition, "alpn");
proxyStr = "vless://" + id.empty()
? "00000000-0000-0000-0000-000000000000"
: id + "@" + hostname + ":" + port;
if (!tls.empty()) {
proxyStr += "&security=" + tls;
}
if (!flow.empty()) {
proxyStr += "&flow=" + flow;
}
if (!pbk.empty()) {
proxyStr += "&pbk=" + flow;
}
if (!sid.empty()) {
proxyStr += "&sid=" + flow;
}
if (!fp.empty()) {
proxyStr += "&fp=" + flow;
}
if (!packet_encoding.empty()) {
proxyStr += "&packet-encoding=" + flow;
}
if (!alpns.empty()) {
proxyStr += "&alpn=" + alpns[0];
}
if (!sni.empty()) {
proxyStr += "&sni=" + sni;
}
if (!transproto.empty()) {
proxyStr += "&type=" + transproto;
switch (hash_(transproto)) {
case "tcp"_hash:
case "ws"_hash:
case "h2"_hash:
proxyStr += "&headerType=" + fake_type;
if (!host.empty()) {
proxyStr += "&host=" + host;
}
proxyStr += "&path=" + urlEncode(path.empty() ? "/" : path);
break;
case "grpc"_hash:
proxyStr += "&serviceName=" + path;
proxyStr += "&mode=" + mode;
break;
case "quic"_hash:
proxyStr += "&headerType=" + fake_type;
proxyStr += "&quicSecurity=" + host.empty() ? sni : host;
proxyStr += "&key=" + path;
break;
default:
break;
}
}
proxyStr += "#" + urlEncode(remark);
break;
case ProxyType::Trojan:
if (!trojan)
continue;
@@ -2107,13 +2191,13 @@ proxyToLoon(std::vector<Proxy> &nodes, const std::string &base_conf,
std::string &hostname = x.Hostname, &username = x.Username, &password = x.Password, &method = x.EncryptMethod, &
plugin = x.Plugin, &pluginopts = x.PluginOption, &id = x.UserId, &transproto = x.TransferProtocol, &host
= x.Host, &path = x.Path, &protocol = x.Protocol, &protoparam = x.ProtocolParam, &obfs = x.OBFS, &
obfsparam = x.OBFSParam;
obfsparam = x.OBFSParam, flow = x.Flow, pk = x.PublicKey, shortId = x.ShortId, sni = x.ServerName;
std::string port = std::to_string(x.Port), aid = std::to_string(x.AlterId);
bool &tlssecure = x.TLSSecure;
tribool scv = ext.skip_cert_verify;
scv.define(x.AllowInsecure);
tribool udp = x.UDP.is_undef() ? ext.udp.is_undef() ? false : ext.udp.get() : x.UDP.get();
std::string proxy;
switch (x.Type) {
@@ -2148,6 +2232,24 @@ proxyToLoon(std::vector<Proxy> &nodes, const std::string &base_conf,
if (!scv.is_undef())
proxy += ",skip-cert-verify=" + std::string(scv.get() ? "true" : "false");
break;
case ProxyType::VLESS:
if (flow != "xtls-rprx-vision") {
continue;
}
proxy = "VLESS," + hostname + "," + port + ",\"" + id + "\",flow=" + flow + ",public-key=\"" + pk +
"\",shortid=" + shortId + ",udp=" + (udp.get() ? "true" : "false") + ",over-tls=" + (
tlssecure ? "true" : "false") + ",sni=" + sni;
switch (hash_(transproto)) {
case "tcp"_hash:
proxy += ",transport=tcp";
break;
default:
continue;
}
if (!scv.is_undef())
proxy += ",skip-cert-verify=" + std::string(scv.get() ? "true" : "false");
break;
case ProxyType::ShadowsocksR:
proxy = "ShadowsocksR," + hostname + "," + port + "," + method + ",\"" + password + "\",protocol=" +
protocol + ",protocol-param=" + protoparam + ",obfs=" + obfs + ",obfs-param=" + obfsparam;

File diff suppressed because it is too large Load Diff

View File

@@ -90,6 +90,7 @@ struct Proxy {
uint16_t IdleSessionCheckInterval=30;
uint16_t IdleSessionTimeout=30;
uint16_t MinIdleSession=0;
String TLSStr;
bool TLSSecure = false;
String Host;

View File

@@ -251,6 +251,7 @@ void vlessConstruct(Proxy &node, const std::string &group, const std::string &re
node.ServerName = sni;
node.AlpnList = alpnList;
node.PacketEncoding = packet_encoding;
node.TLSStr = tls;
switch (hash_(net)) {
case "grpc"_hash:
node.Host = host;
@@ -258,7 +259,7 @@ void vlessConstruct(Proxy &node, const std::string &group, const std::string &re
node.GRPCServiceName = path.empty() ? "/" : urlEncode(urlDecode(trim(path)));
break;
case "quic"_hash:
node.QUICSecure = host;
node.Host = host;
node.QUICSecret = path.empty() ? "/" : trim(path);
break;
default: