From 9caf06760d2b495dc10896350b32c0a72de40c74 Mon Sep 17 00:00:00 2001 From: xjasonlyu Date: Sat, 6 Feb 2021 18:58:27 +0800 Subject: [PATCH] Chore: update engine log of proxy & device --- engine/engine.go | 12 +++++++++--- engine/parse.go | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/engine/engine.go b/engine/engine.go index 913e31c..f988937 100755 --- a/engine/engine.go +++ b/engine/engine.go @@ -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 } diff --git a/engine/parse.go b/engine/parse.go index 44fc5fb..2c11588 100644 --- a/engine/parse.go +++ b/engine/parse.go @@ -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