mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2024-12-30 02:37:01 +00:00
Chore: update engine log of proxy & device
This commit is contained in:
+9
-3
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user