Chore: const tun.Driver = "tun"

This commit is contained in:
xjasonlyu
2021-02-07 10:09:26 +08:00
parent 79aa91da41
commit a3ff3a5a15
2 changed files with 4 additions and 5 deletions

View File

@@ -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)

View File

@@ -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)