diff --git a/device/tun/tun.go b/device/tun/tun.go index d617d70..53dfa8d 100755 --- a/device/tun/tun.go +++ b/device/tun/tun.go @@ -5,10 +5,10 @@ import ( "github.com/xjasonlyu/tun2socks/device" ) -const driverType = "tun" +const Driver = "tun" func (t *TUN) Type() string { - return driverType + return Driver } var _ device.Device = (*TUN)(nil) diff --git a/engine/parse.go b/engine/parse.go index 8fd095a..c7f4291 100644 --- a/engine/parse.go +++ b/engine/parse.go @@ -12,9 +12,8 @@ import ( ) func parseDevice(s string, mtu uint32) (device.Device, error) { - const defaultDriver = "tun" if !strings.Contains(s, "://") { - s = defaultDriver + "://" + s + s = tun.Driver + "://" + s /* default driver */ } u, err := url.Parse(s) @@ -26,7 +25,7 @@ func parseDevice(s string, mtu uint32) (device.Device, error) { driver := strings.ToLower(u.Scheme) switch driver { - case "tun": + case tun.Driver: return tun.Open(tun.WithName(name), tun.WithMTU(mtu)) default: return nil, fmt.Errorf("unsupported driver: %s", driver)