mirror of
https://github.com/slackhq/nebula.git
synced 2025-11-24 01:14:25 +01:00
new mtu setting and const for default
This commit is contained in:
@@ -6,6 +6,8 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
const DEFAULT_MTU = 1300
|
||||
|
||||
type route struct {
|
||||
mtu int
|
||||
route *net.IPNet
|
||||
@@ -106,6 +108,23 @@ func parseUnsafeRoutes(config *Config, network *net.IPNet) ([]route, error) {
|
||||
return nil, fmt.Errorf("entry %v in tun.unsafe_routes is invalid", i+1)
|
||||
}
|
||||
|
||||
rMtu, ok := m["mtu"]
|
||||
if !ok {
|
||||
rMtu = config.GetInt("tun.mtu", DEFAULT_MTU)
|
||||
}
|
||||
|
||||
mtu, ok := rMtu.(int)
|
||||
if !ok {
|
||||
mtu, err = strconv.Atoi(rMtu.(string))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("entry %v.mtu in tun.unsafe_routes is not an integer: %v", i+1, err)
|
||||
}
|
||||
}
|
||||
|
||||
if mtu < 500 {
|
||||
return nil, fmt.Errorf("entry %v.mtu in tun.unsafe_routes is below 500: %v", i+1, mtu)
|
||||
}
|
||||
|
||||
rVia, ok := m["via"]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("entry %v.via in tun.unsafe_routes is not present", i+1)
|
||||
|
||||
Reference in New Issue
Block a user