|
|
@ -49,7 +49,7 @@ func createTun(cfg TunConfig) (conn net.Conn, ipNet *net.IPNet, err error) { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func createTap(cfg TapConfig) (conn net.Conn, ipNet *net.IPNet, err error) { |
|
|
func createTap(cfg TapConfig) (conn net.Conn, itf *net.Interface, err error) { |
|
|
ip, ipNet, err := net.ParseCIDR(cfg.Addr) |
|
|
ip, ipNet, err := net.ParseCIDR(cfg.Addr) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return |
|
|
return |
|
|
@ -81,6 +81,11 @@ func createTap(cfg TapConfig) (conn net.Conn, ipNet *net.IPNet, err error) { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
itf, err = net.InterfaceByName(ifce.Name()) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
conn = &tunTapConn{ |
|
|
conn = &tunTapConn{ |
|
|
ifce: ifce, |
|
|
ifce: ifce, |
|
|
addr: &net.IPAddr{IP: ip}, |
|
|
addr: &net.IPAddr{IP: ip}, |
|
|
|