diff --git a/engine/parse.go b/engine/parse.go index 0ae5999..d169824 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 = tun.Driver + "://" + s /* default driver */ - } - 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 = proto.Socks5.String() + "://" + s /* default protocol */ - } - 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 {