diff --git a/engine/parse.go b/engine/parse.go index d169824..ff64bfd 100644 --- a/engine/parse.go +++ b/engine/parse.go @@ -13,15 +13,15 @@ import ( ) func parseDevice(s string, mtu uint32) (device.Device, error) { + if !strings.Contains(s, "://") { + s = fmt.Sprintf("%s://%s", tun.Driver /* default driver */, s) + } + u, err := url.Parse(s) if err != nil { return nil, err } - if u.Scheme == "" { - u.Scheme = tun.Driver /* default driver */ - } - name := u.Host driver := strings.ToLower(u.Scheme) @@ -34,15 +34,15 @@ func parseDevice(s string, mtu uint32) (device.Device, error) { } func parseProxy(s string) (proxy.Proxy, error) { + if !strings.Contains(s, "://") { + s = fmt.Sprintf("%s://%s", proto.Socks5 /* default protocol */, s) + } + u, err := url.Parse(s) if err != nil { return nil, err } - if u.Scheme == "" { - u.Scheme = proto.Socks5.String() /* default protocol */ - } - protocol := strings.ToLower(u.Scheme) switch protocol {