Chore: update engine log of proxy & device

This commit is contained in:
xjasonlyu
2021-02-06 18:58:27 +08:00
parent a84eebe284
commit 9caf06760d
2 changed files with 10 additions and 4 deletions
+9 -3
View File
@@ -20,6 +20,7 @@ type Engine struct {
rawProxy string
rawDevice string
proxy proxy.Proxy
device device.Device
}
@@ -90,11 +91,12 @@ func (e *Engine) setProxy() error {
return errors.New("empty proxy")
}
d, err := parseProxy(e.rawProxy)
p, err := parseProxy(e.rawProxy)
if err != nil {
return err
}
proxy.SetDialer(d)
e.proxy = p
proxy.SetDialer(p)
return nil
}
@@ -116,6 +118,10 @@ func (e *Engine) setStack() error {
if _, err := stack.New(e.device, handler, stack.WithDefault()); err != nil {
return err
}
log.Infof("[STACK] %s <-> %s", e.rawDevice, e.rawProxy)
log.Infof(
"[STACK] %s://%s <-> %s://%s",
e.device.Type(), e.device.Name(),
e.proxy.Type(), e.proxy.Addr(),
)
return nil
}
+1 -1
View File
@@ -37,7 +37,7 @@ func parseDevice(s string, mtu uint32) (device.Device, error) {
return d, nil
}
func parseProxy(s string) (proxy.Dialer, error) {
func parseProxy(s string) (proxy.Proxy, error) {
const defaultProto = "socks5"
if !strings.Contains(s, "://") {
s = defaultProto + "://" + s