mirror of
https://github.com/popura-network/Popura.git
synced 2024-12-06 19:26:23 +01:00
Add RAdv.DefaultRouter option as a crutch for Android
This commit is contained in:
@@ -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
@@ -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{})
|
||||
|
||||
Reference in New Issue
Block a user