diff --git a/main.go b/main.go index 6bd45b7..b724829 100644 --- a/main.go +++ b/main.go @@ -50,6 +50,7 @@ var examples = map[string][]string{ "warp://key@host:1234/#WARPkey", "warp://engage.cloudflareclient.com:2408#WARPnoKey", "warp://key@engage.cloudflareclient.com:2408/?ifp=5-10#WARPparam", + "warp://auto/#WARP_auto", }, } diff --git a/ray2sing/beepass.go b/ray2sing/beepass.go index f33bd4a..36862b8 100644 --- a/ray2sing/beepass.go +++ b/ray2sing/beepass.go @@ -59,7 +59,7 @@ func BeepassSingbox(beepassUrl string) (*T.Outbound, error) { ShadowsocksOptions: T.ShadowsocksOutboundOptions{ ServerOptions: T.ServerOptions{ Server: decoded.Server, - ServerPort: toInt16(decoded.ServerPort), + ServerPort: toInt16(decoded.ServerPort, 443), }, Method: decoded.Method, Password: decoded.Password, diff --git a/ray2sing/common.go b/ray2sing/common.go index 9827ce7..56e9495 100644 --- a/ray2sing/common.go +++ b/ray2sing/common.go @@ -207,12 +207,12 @@ func toInt(s string) int { return i } -func toInt16(s string) uint16 { +func toInt16(s string, defaultPort uint16) uint16 { val, err := strconv.ParseInt(s, 10, 17) if err != nil { // fmoption.Printf("err %v", err) // handle the error appropriately; here we return 0 - return 443 + return defaultPort } return uint16(val) } diff --git a/ray2sing/hysteria.go b/ray2sing/hysteria.go index 2675f87..c40e3fd 100644 --- a/ray2sing/hysteria.go +++ b/ray2sing/hysteria.go @@ -7,7 +7,7 @@ import ( ) func HysteriaSingbox(hysteriaURL string) (*T.Outbound, error) { - u, err := ParseUrl(hysteriaURL) + u, err := ParseUrl(hysteriaURL, 443) if err != nil { return nil, err } diff --git a/ray2sing/hysteria2.go b/ray2sing/hysteria2.go index 1f0e02c..3e5c785 100644 --- a/ray2sing/hysteria2.go +++ b/ray2sing/hysteria2.go @@ -5,7 +5,7 @@ import ( ) func Hysteria2Singbox(hysteria2Url string) (*T.Outbound, error) { - u, err := ParseUrl(hysteria2Url) + u, err := ParseUrl(hysteria2Url, 443) if err != nil { return nil, err } diff --git a/ray2sing/shadowsocks.go b/ray2sing/shadowsocks.go index 5a5aa6f..cd469ea 100644 --- a/ray2sing/shadowsocks.go +++ b/ray2sing/shadowsocks.go @@ -36,7 +36,7 @@ func parseShadowsocks(configStr string) (map[string]string, error) { } func ShadowsocksSingbox(shadowsocksUrl string) (*T.Outbound, error) { - u, err := ParseUrl(shadowsocksUrl) + u, err := ParseUrl(shadowsocksUrl, 443) if err != nil { return nil, err } diff --git a/ray2sing/ssh.go b/ray2sing/ssh.go index 9c3d95f..5fe960d 100644 --- a/ray2sing/ssh.go +++ b/ray2sing/ssh.go @@ -7,7 +7,7 @@ import ( ) func SSHSingbox(sshURL string) (*T.Outbound, error) { - u, err := ParseUrl(sshURL) + u, err := ParseUrl(sshURL, 22) if err != nil { return nil, err } diff --git a/ray2sing/trojan.go b/ray2sing/trojan.go index 56aef1c..f313421 100644 --- a/ray2sing/trojan.go +++ b/ray2sing/trojan.go @@ -5,7 +5,7 @@ import ( ) func TrojanSingbox(trojanURL string) (*T.Outbound, error) { - u, err := ParseUrl(trojanURL) + u, err := ParseUrl(trojanURL, 443) if err != nil { return nil, err } diff --git a/ray2sing/tuic.go b/ray2sing/tuic.go index 33872f7..3d0a4c1 100644 --- a/ray2sing/tuic.go +++ b/ray2sing/tuic.go @@ -7,7 +7,7 @@ import ( ) func TuicSingbox(tuicUrl string) (*T.Outbound, error) { - u, err := ParseUrl(tuicUrl) + u, err := ParseUrl(tuicUrl, 443) if err != nil { return nil, err } diff --git a/ray2sing/url_schema.go b/ray2sing/url_schema.go index fcf76a9..81813c4 100644 --- a/ray2sing/url_schema.go +++ b/ray2sing/url_schema.go @@ -30,13 +30,13 @@ func (u UrlSchema) GetRelayOptions() (*T.TurnRelayOptions, error) { } // parseHysteria2 parses a given URL and returns a HysteriaURLData struct. -func ParseUrl(inputURL string) (*UrlSchema, error) { +func ParseUrl(inputURL string, defaultPort uint16) (*UrlSchema, error) { parsedURL, err := url.Parse(inputURL) if err != nil { return nil, err } - port := toInt16(parsedURL.Port()) + port := toInt16(parsedURL.Port(), defaultPort) data := &UrlSchema{ Scheme: parsedURL.Scheme, diff --git a/ray2sing/vless.go b/ray2sing/vless.go index 8f817a3..52e77c5 100644 --- a/ray2sing/vless.go +++ b/ray2sing/vless.go @@ -5,7 +5,7 @@ import ( ) func VlessSingbox(vlessURL string) (*T.Outbound, error) { - u, err := ParseUrl(vlessURL) + u, err := ParseUrl(vlessURL, 443) if err != nil { return nil, err } diff --git a/ray2sing/vmess.go b/ray2sing/vmess.go index bfc9b59..4bad875 100644 --- a/ray2sing/vmess.go +++ b/ray2sing/vmess.go @@ -50,7 +50,7 @@ func VmessSingbox(vmessURL string) (*T.Outbound, error) { return nil, err } - port := toInt16(decoded["port"]) + port := toInt16(decoded["port"], 443) transportOptions, err := getTransportOptions(decoded) if err != nil { return nil, err diff --git a/ray2sing/warp.go b/ray2sing/warp.go index 7a42cf3..dde8769 100644 --- a/ray2sing/warp.go +++ b/ray2sing/warp.go @@ -5,10 +5,11 @@ import ( ) func WarpSingbox(url string) (*T.Outbound, error) { - u, err := ParseUrl(url) + u, err := ParseUrl(url, 0) if err != nil { return nil, err } + out := &T.Outbound{ Type: "custom", Tag: u.Name, diff --git a/ray2sing/wireguard.go b/ray2sing/wireguard.go index 0d717f8..897cf12 100644 --- a/ray2sing/wireguard.go +++ b/ray2sing/wireguard.go @@ -9,7 +9,7 @@ import ( ) func WiregaurdSingbox(url string) (*T.Outbound, error) { - u, err := ParseUrl(url) + u, err := ParseUrl(url, 0) if err != nil { return nil, err } @@ -22,6 +22,7 @@ func WiregaurdSingbox(url string) (*T.Outbound, error) { PrivateKey: u.Params["pk"], PeerPublicKey: u.Params["peer_pk"], PreSharedKey: u.Params["pre_shared_key"], + FakePackets: u.Params["ifp"], }, }