Browse Source

Chore: update engine log of proxy & device

pull/76/head
xjasonlyu 4 years ago
parent
commit
9caf06760d
  1. 12
      engine/engine.go
  2. 2
      engine/parse.go

12
engine/engine.go

@ -20,6 +20,7 @@ type Engine struct {
rawProxy string rawProxy string
rawDevice string rawDevice string
proxy proxy.Proxy
device device.Device device device.Device
} }
@ -90,11 +91,12 @@ func (e *Engine) setProxy() error {
return errors.New("empty proxy") return errors.New("empty proxy")
} }
d, err := parseProxy(e.rawProxy) p, err := parseProxy(e.rawProxy)
if err != nil { if err != nil {
return err return err
} }
proxy.SetDialer(d) e.proxy = p
proxy.SetDialer(p)
return nil return nil
} }
@ -116,6 +118,10 @@ func (e *Engine) setStack() error {
if _, err := stack.New(e.device, handler, stack.WithDefault()); err != nil { if _, err := stack.New(e.device, handler, stack.WithDefault()); err != nil {
return err 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 return nil
} }

2
engine/parse.go

@ -37,7 +37,7 @@ func parseDevice(s string, mtu uint32) (device.Device, error) {
return d, nil return d, nil
} }
func parseProxy(s string) (proxy.Dialer, error) { func parseProxy(s string) (proxy.Proxy, error) {
const defaultProto = "socks5" const defaultProto = "socks5"
if !strings.Contains(s, "://") { if !strings.Contains(s, "://") {
s = defaultProto + "://" + s s = defaultProto + "://" + s

Loading…
Cancel
Save