diff --git a/util/genLink.go b/util/genLink.go index 2048273..54f0a8b 100644 --- a/util/genLink.go +++ b/util/genLink.go @@ -10,7 +10,7 @@ import ( "strings" ) -var InboundTypeWithLink = []string{"shadowsocks", "naive", "hysteria", "hysteria2", "anytls", "tuic", "vless", "trojan", "vmess"} +var InboundTypeWithLink = []string{"socks", "http", "mixed", "shadowsocks", "naive", "hysteria", "hysteria2", "anytls", "tuic", "vless", "trojan", "vmess"} func LinkGenerator(clientConfig json.RawMessage, i *model.Inbound, hostname string) []string { inbound, err := i.MarshalFull() @@ -61,6 +61,13 @@ func LinkGenerator(clientConfig json.RawMessage, i *model.Inbound, hostname stri } switch i.Type { + case "socks": + return socksLink(userConfig["socks"], *inbound, Addrs) + case "http": + return httpLink(userConfig["http"], *inbound, Addrs) + case "mixed": + return append( + socksLink(userConfig["socks"], *inbound, Addrs), httpLink(userConfig["http"], *inbound, Addrs)...) case "shadowsocks": return shadowsocksLink(userConfig, *inbound, Addrs) case "naive": @@ -106,6 +113,26 @@ func prepareTls(t *model.Tls) map[string]interface{} { return oTls } +func socksLink(userConfig map[string]interface{}, inbound map[string]interface{}, addrs []map[string]interface{}) []string { + var links []string + for _, addr := range addrs { + links = append(links, fmt.Sprintf("socks5://%s:%s@%s:%d", userConfig["username"], userConfig["password"], addr["server"].(string), uint(addr["server_port"].(float64)))) + } + return links +} + +func httpLink(userConfig map[string]interface{}, inbound map[string]interface{}, addrs []map[string]interface{}) []string { + var links []string + var protocol string = "http" + for _, addr := range addrs { + if addr["tls"] != nil { + protocol = "https" + } + links = append(links, fmt.Sprintf("%s://%s:%s@%s:%d", protocol, userConfig["username"], userConfig["password"], addr["server"].(string), uint(addr["server_port"].(float64)))) + } + return links +} + func shadowsocksLink( userConfig map[string]map[string]interface{}, inbound map[string]interface{}, diff --git a/util/linkToJson.go b/util/linkToJson.go index bbe22d6..683e4bf 100644 --- a/util/linkToJson.go +++ b/util/linkToJson.go @@ -481,6 +481,7 @@ func getTls(security string, q *url.Values) *map[string]interface{} { tls_sni := q.Get("sni") tls_insecure := q.Get("allowInsecure") tls_alpn := q.Get("alpn") + tls_ech := q.Get("ech") switch security { case "tls": tls["enabled"] = true @@ -507,5 +508,13 @@ func getTls(security string, q *url.Values) *map[string]interface{} { "fingerprint": tls_fp, } } + if len(tls_ech) > 0 { + tls["ech"] = map[string]interface{}{ + "enabled": true, + "config": []string{ + tls_ech, + }, + } + } return &tls }