Chore: rename proxy Type() to Proto()

This commit is contained in:
xjasonlyu
2021-02-07 10:38:07 +08:00
parent a3ff3a5a15
commit ee00315894
8 changed files with 38 additions and 15 deletions
+1 -1
View File
@@ -121,7 +121,7 @@ func (e *Engine) setStack() error {
log.Infof(
"[STACK] %s://%s <-> %s://%s",
e.device.Type(), e.device.Name(),
e.proxy.Type(), e.proxy.Addr(),
e.proxy.Proto(), e.proxy.Addr(),
)
return nil
}
+4 -5
View File
@@ -33,9 +33,8 @@ func parseDevice(s string, mtu uint32) (device.Device, error) {
}
func parseProxy(s string) (proxy.Proxy, error) {
const defaultProto = "socks5"
if !strings.Contains(s, "://") {
s = defaultProto + "://" + s
s = proxy.Socks5Proto.String() + "://" + s /* default protocol */
}
u, err := url.Parse(s)
@@ -46,11 +45,11 @@ func parseProxy(s string) (proxy.Proxy, error) {
proto := strings.ToLower(u.Scheme)
switch proto {
case "direct":
case proxy.DirectProto.String():
return proxy.NewDirect(), nil
case "socks5":
case proxy.Socks5Proto.String():
return proxy.NewSocks5(parseSocks(u))
case "ss":
case proxy.ShadowsocksProto.String():
return proxy.NewShadowsocks(parseShadowsocks(u))
default:
return nil, fmt.Errorf("unsupported protocol: %s", proto)