Add RAdv.DefaultRouter option as a crutch for Android

This commit is contained in:
George
2020-08-03 04:20:57 -04:00
parent 648d5492aa
commit 4ac05a20da
2 changed files with 28 additions and 18 deletions
+2
View File
@@ -29,6 +29,7 @@ type RAdvConfig struct {
Enable bool `comment:"Enable or disable Router Advertisement"`
Interface string `comment:"Send router advertisement for this network interface"`
SetGatewayIP bool `comment:"Set IP address on the Interface automatically"`
DefaultRouter bool `comment:"Advertise a default router (a fix for Android)"`
}
func GenerateConfig() (*config.NodeConfig, *PopuraConfig) {
@@ -41,6 +42,7 @@ func GenerateConfig() (*config.NodeConfig, *PopuraConfig) {
popConfig.RAdv.Enable = false
popConfig.RAdv.Interface = "eth0"
popConfig.RAdv.SetGatewayIP = true
popConfig.RAdv.DefaultRouter = false
return config.GenerateConfig(), &popConfig
}
+26 -18
View File
@@ -86,31 +86,39 @@ func (s *RAdv) Start() error {
}
}
routerLifetime := time.Second * 0
options := []ndp.Option{
&ndp.PrefixInformation{
PrefixLength: 64,
OnLink: true,
AutonomousAddressConfiguration: true,
ValidLifetime: time.Second * 86400,
PreferredLifetime: time.Second * 14400,
Prefix: s.subnet.IP,
},
&ndp.LinkLayerAddress{Direction: ndp.Source, Addr: ifi.HardwareAddr},
}
if s.config.DefaultRouter {
routerLifetime = time.Second * 1800
} else {
options = append(options, &ndp.RouteInformation{
PrefixLength: 7,
Preference: ndp.Medium,
RouteLifetime: time.Second * 1800,
Prefix: yggdrasilPrefixIP,
})
}
s.message = &ndp.RouterAdvertisement{
CurrentHopLimit: 64,
ManagedConfiguration: false,
OtherConfiguration: false,
RouterSelectionPreference: ndp.Medium,
RouterLifetime: time.Second * 0,
RouterLifetime: routerLifetime,
ReachableTime: time.Second * 0,
RetransmitTimer: time.Second * 0,
Options: []ndp.Option{
&ndp.PrefixInformation{
PrefixLength: 64,
OnLink: true,
AutonomousAddressConfiguration: true,
ValidLifetime: time.Second * 86400,
PreferredLifetime: time.Second * 14400,
Prefix: s.subnet.IP,
},
&ndp.RouteInformation{
PrefixLength: 7,
Preference: ndp.Medium,
RouteLifetime: time.Second * 1800,
Prefix: yggdrasilPrefixIP,
},
&ndp.LinkLayerAddress{Direction: ndp.Source, Addr: ifi.HardwareAddr},
},
Options: options,
}
advTrigger := make(chan struct{})