-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new: add basic socks, http, and https proxy support
- Loading branch information
1 parent
2d6d49a
commit 0b78d4f
Showing
4 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,7 @@ var examples = map[string][]string{ | |
"wg://server.com:5319?publicKey=verypublicKeyss&privateKey=veryprivatekey&presharedKey=verysharedkey&ip=10.0.0.1&mtu=1380&keepalive=30&udp=1&reserved=0,0,0&ifp=5-10#direct%20WireGuard", | ||
}, | ||
"warp": { | ||
"#profile-title: Hiddify WARP\nwarp://p2@auto#Remote&&detour=warp://p1@auto#Local", | ||
"warp://key@host:1234/#WARPkey", | ||
"warp://engage.cloudflareclient.com:2408#WARPnoKey", | ||
"warp://[email protected]:2408/?ifp=5-10#WARPparam", | ||
|
@@ -58,6 +59,13 @@ var examples = map[string][]string{ | |
"warp://auto&&detour=warp://auto", | ||
"vless://[email protected]:2053?encryption=none&flow=&fp=chrome&pbk=SbVKOEMjK0sIlbwg4akyBg5mL5KZwwB-ed4eEE7YnRc&security=reality&serviceName=xyz&sid=&sni=discordapp.com&type=grpc#رایگان | REALITY | @EliV2ray | FR🇫🇷 | 0️⃣1️⃣&&detour=tuic://3618921b-adeb-4bd3-a2a0-f98b72a674b1:[email protected]:23450?allow_insecure=1&alpn=h3&congestion_control=bbr&sni=www.google.com&udp_relay_mode=native#رایگان | TUIC | @V2rayCollector | CA🇨🇦 | 0️⃣1️⃣", | ||
}, | ||
"socks": { | ||
"socks://a:b@c:80?v=4", | ||
}, | ||
"http": { | ||
"phttp://a:b@c:80/?path=ssss", | ||
"phttps://a:b@c:80/?path=ssss&sni=d&insecure=1", | ||
}, | ||
"direct": { | ||
"direct://?fgsize=10-100&fgsleep=100-200", | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package ray2sing | ||
|
||
import ( | ||
C "github.com/sagernet/sing-box/constant" | ||
T "github.com/sagernet/sing-box/option" | ||
) | ||
|
||
func HttpSingbox(url string) (*T.Outbound, error) { | ||
u, err := ParseUrl(url, 0) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
out := &T.Outbound{ | ||
Type: C.TypeHTTP, | ||
Tag: u.Name, | ||
HTTPOptions: T.HTTPOutboundOptions{ | ||
ServerOptions: u.GetServerOption(), | ||
Username: u.Username, | ||
Password: u.Password, | ||
}, | ||
} | ||
if _, err := getOneOf(u.Params, "tls", "sni", "insecure"); err == nil { | ||
out.HTTPOptions.OutboundTLSOptionsContainer.TLS = &T.OutboundTLSOptions{ | ||
Enabled: true, | ||
} | ||
} | ||
if sni, err := getOneOf(u.Params, "sni"); err == nil { | ||
out.HTTPOptions.OutboundTLSOptionsContainer.TLS.ServerName = sni | ||
} | ||
if insecure, err := getOneOf(u.Params, "insecure"); err == nil { | ||
out.HTTPOptions.OutboundTLSOptionsContainer.TLS.Insecure = insecure != "0" | ||
} | ||
if path, err := getOneOf(u.Params, "path"); err == nil { | ||
out.HTTPOptions.Path = path | ||
} | ||
// if net, err := getOneOf(u.Params, "net", "network"); err == nil { | ||
// out.SocksOptions.Network= net | ||
// } | ||
return out, nil | ||
} | ||
|
||
func HttpsSingbox(url string) (*T.Outbound, error) { | ||
u, err := ParseUrl(url, 0) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
out := &T.Outbound{ | ||
Type: C.TypeHTTP, | ||
Tag: u.Name, | ||
HTTPOptions: T.HTTPOutboundOptions{ | ||
ServerOptions: u.GetServerOption(), | ||
Username: u.Username, | ||
Password: u.Password, | ||
}, | ||
} | ||
out.HTTPOptions.OutboundTLSOptionsContainer.TLS = &T.OutboundTLSOptions{ | ||
Enabled: true, | ||
} | ||
if sni, err := getOneOf(u.Params, "sni"); err == nil { | ||
out.HTTPOptions.OutboundTLSOptionsContainer.TLS.ServerName = sni | ||
} | ||
if insecure, err := getOneOf(u.Params, "insecure"); err == nil { | ||
out.HTTPOptions.OutboundTLSOptionsContainer.TLS.Insecure = insecure != "0" | ||
} | ||
|
||
if path, err := getOneOf(u.Params, "path"); err == nil { | ||
out.HTTPOptions.Path = path | ||
} | ||
|
||
// if net, err := getOneOf(u.Params, "net", "network"); err == nil { | ||
// out.SocksOptions.Network= net | ||
// } | ||
return out, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package ray2sing | ||
|
||
import ( | ||
C "github.com/sagernet/sing-box/constant" | ||
T "github.com/sagernet/sing-box/option" | ||
) | ||
|
||
func SocksSingbox(url string) (*T.Outbound, error) { | ||
u, err := ParseUrl(url, 0) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
out := &T.Outbound{ | ||
Type: C.TypeSOCKS, | ||
Tag: u.Name, | ||
SocksOptions: T.SocksOutboundOptions{ | ||
ServerOptions: u.GetServerOption(), | ||
Username: u.Username, | ||
Password: u.Password, | ||
}, | ||
} | ||
if version, err := getOneOf(u.Params, "v", "ver", "version"); err == nil { | ||
out.SocksOptions.Version = version | ||
} | ||
// if net, err := getOneOf(u.Params, "net", "network"); err == nil { | ||
// out.SocksOptions.Network= net | ||
// } | ||
return out, nil | ||
} |