diff --git a/src/generator/config/subexport.cpp b/src/generator/config/subexport.cpp index fe946ac..a6b4ba1 100644 --- a/src/generator/config/subexport.cpp +++ b/src/generator/config/subexport.cpp @@ -391,6 +391,17 @@ void proxyToClash(std::vector &nodes, YAML::Node &yamlnode, const string_ if(x.Edge.size()) singleproxy["http-opts"]["headers"]["Edge"].push_back(x.Edge); break; + case "h2"_hash: + singleproxy["network"] = x.TransferProtocol; + singleproxy["h2-opts"]["path"] = x.Path; + if(x.Host.size()) + singleproxy["h2-opts"]["host"].push_back(x.Host); + break; + case "grpc"_hash: + singleproxy["network"] = x.TransferProtocol; + singleproxy["servername"] = x.Host; + singleproxy["grpc-opts"]["grpc-service-name"] = x.Path; + break; default: continue; } diff --git a/src/parser/subparser.cpp b/src/parser/subparser.cpp index 574971a..487a29f 100644 --- a/src/parser/subparser.cpp +++ b/src/parser/subparser.cpp @@ -960,17 +960,28 @@ void explodeClash(Node yamlnode, std::vector &nodes) singleproxy["alterId"] >>= aid; singleproxy["cipher"] >>= cipher; net = singleproxy["network"].IsDefined() ? safe_as(singleproxy["network"]) : "tcp"; - if(net == "http") + switch(hash_(net)) { + case "http"_hash: singleproxy["http-opts"]["path"][0] >>= path; singleproxy["http-opts"]["headers"]["Host"][0] >>= host; edge.clear(); - } - else - { + break; + case "ws"_hash: path = singleproxy["ws-path"].IsDefined() ? safe_as(singleproxy["ws-path"]) : "/"; singleproxy["ws-headers"]["Host"] >>= host; singleproxy["ws-headers"]["Edge"] >>= edge; + break; + case "h2"_hash: + singleproxy["h2-opts"]["path"] >>= path; + singleproxy["h2-opts"]["host"][0] >>= host; + edge.clear(); + break; + case "grpc"_hash: + singleproxy["servername"] >>= host; + singleproxy["grpc-opts"]["grpc-service-name"] >>= path; + edge.clear(); + break; } tls = safe_as(singleproxy["tls"]) == "true" ? "tls" : "";