tap: fix createTap
This commit is contained in:
parent
124bc03ea4
commit
8e914c87e0
@ -48,7 +48,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) {
|
||||||
err = errors.New("tap is not supported on darwin")
|
err = errors.New("tap is not supported on darwin")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,8 @@ 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, _, err := net.ParseCIDR(cfg.Addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -79,6 +79,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},
|
||||||
|
@ -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},
|
||||||
|
Loading…
Reference in New Issue
Block a user