mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
Move tunDevice into router
This commit is contained in:
parent
d9b376b3ad
commit
10157483f9
4 changed files with 24 additions and 20 deletions
|
@ -160,9 +160,9 @@ func (a *admin) init(c *Core, listenaddr string) {
|
|||
}()
|
||||
|
||||
return admin_info{
|
||||
a.core.tun.iface.Name(): admin_info{
|
||||
"tap_mode": a.core.tun.iface.IsTAP(),
|
||||
"mtu": a.core.tun.mtu,
|
||||
a.core.router.tun.iface.Name(): admin_info{
|
||||
"tap_mode": a.core.router.tun.iface.IsTAP(),
|
||||
"mtu": a.core.router.tun.mtu,
|
||||
},
|
||||
}, nil
|
||||
})
|
||||
|
@ -185,8 +185,8 @@ func (a *admin) init(c *Core, listenaddr string) {
|
|||
return admin_info{}, errors.New("Failed to configure adapter")
|
||||
} else {
|
||||
return admin_info{
|
||||
a.core.tun.iface.Name(): admin_info{
|
||||
"tap_mode": a.core.tun.iface.IsTAP(),
|
||||
a.core.router.tun.iface.Name(): admin_info{
|
||||
"tap_mode": a.core.router.tun.iface.IsTAP(),
|
||||
"mtu": ifmtu,
|
||||
},
|
||||
}, nil
|
||||
|
@ -539,12 +539,12 @@ func (a *admin) removePeer(p string) error {
|
|||
// startTunWithMTU creates the tun/tap device, sets its address, and sets the MTU to the provided value.
|
||||
func (a *admin) startTunWithMTU(ifname string, iftapmode bool, ifmtu int) error {
|
||||
// Close the TUN first if open
|
||||
_ = a.core.tun.close()
|
||||
_ = a.core.router.tun.close()
|
||||
// Then reconfigure and start it
|
||||
addr := a.core.router.addr
|
||||
straddr := fmt.Sprintf("%s/%v", net.IP(addr[:]).String(), 8*len(address_prefix)-1)
|
||||
if ifname != "none" {
|
||||
err := a.core.tun.setup(ifname, iftapmode, straddr, ifmtu)
|
||||
err := a.core.router.tun.setup(ifname, iftapmode, straddr, ifmtu)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -559,9 +559,9 @@ func (a *admin) startTunWithMTU(ifname string, iftapmode bool, ifmtu int) error
|
|||
a.core.sessions.sendPingPong(sinfo, false)
|
||||
}
|
||||
// Aaaaand... go!
|
||||
go a.core.tun.read()
|
||||
go a.core.router.tun.read()
|
||||
}
|
||||
go a.core.tun.write()
|
||||
go a.core.router.tun.write()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue