mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
Unify MTU datatypes across the codebase
The codebase uses int and unit16 to represent MTU randomly. This change unifies it to a MTU type from types package, which is currently uint16.
This commit is contained in:
parent
4b16c325a3
commit
8358fe5c5c
13 changed files with 51 additions and 37 deletions
|
@ -10,17 +10,17 @@ import (
|
|||
)
|
||||
|
||||
// Configures the TUN adapter with the correct IPv6 address and MTU.
|
||||
func (tun *TunAdapter) setup(ifname string, addr string, mtu int) error {
|
||||
func (tun *TunAdapter) setup(ifname string, addr string, mtu MTU) error {
|
||||
if ifname == "auto" {
|
||||
ifname = "\000"
|
||||
}
|
||||
iface, err := wgtun.CreateTUN(ifname, mtu)
|
||||
iface, err := wgtun.CreateTUN(ifname, int(mtu))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
tun.iface = iface
|
||||
if mtu, err := iface.MTU(); err == nil {
|
||||
tun.mtu = getSupportedMTU(mtu)
|
||||
tun.mtu = getSupportedMTU(MTU(mtu))
|
||||
} else {
|
||||
tun.mtu = 0
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ func (tun *TunAdapter) setupAddress(addr string) error {
|
|||
if err := netlink.AddrAdd(nlintf, nladdr); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := netlink.LinkSetMTU(nlintf, tun.mtu); err != nil {
|
||||
if err := netlink.LinkSetMTU(nlintf, int(tun.mtu)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := netlink.LinkSetUp(nlintf); err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue