Update App version to 0.0.4

Signed-off-by: luckfox-eng29 <eng29@luckfox.com>
This commit is contained in:
luckfox-eng29
2025-11-11 20:38:22 +08:00
parent 4e82b8a11c
commit 5e17c52afc
41 changed files with 3537 additions and 598 deletions

View File

@@ -56,6 +56,7 @@ func initNetwork() error {
},
OnConfigChange: func(networkConfig *network.NetworkConfig) {
config.NetworkConfig = networkConfig
config.AppliedNetworkConfig = networkConfig
networkStateChanged()
},
})
@@ -73,6 +74,22 @@ func initNetwork() error {
networkState = state
if config != nil && config.NetworkConfig != nil {
if config.NetworkConfig.PendingReboot.Valid && config.NetworkConfig.PendingReboot.Bool {
if config.AppliedNetworkConfig != nil && network.IsSame(config.AppliedNetworkConfig, *config.NetworkConfig) {
config.NetworkConfig.PendingReboot = null.BoolFrom(false)
_ = SaveConfig()
}
}
}
if config != nil && config.NetworkConfig != nil {
if config.NetworkConfig.PendingReboot.Valid && config.NetworkConfig.PendingReboot.Bool {
config.NetworkConfig.PendingReboot = null.BoolFrom(false)
_ = SaveConfig()
}
}
return nil
}
@@ -88,11 +105,29 @@ func rpcGetNetworkSettings() network.RpcNetworkSettings {
}
func rpcSetNetworkSettings(settings network.RpcNetworkSettings) (*network.RpcNetworkSettings, error) {
current := networkState.RpcGetNetworkSettings()
changedCore := !network.IsSame(current.NetworkConfig, settings.NetworkConfig)
if changedCore {
settings.NetworkConfig.PendingReboot = null.BoolFrom(true)
}
s := networkState.RpcSetNetworkSettings(settings)
if s != nil {
return nil, s
}
applied := networkState.RpcGetNetworkSettings()
config.NetworkConfig = &applied.NetworkConfig
// If we just reverted to the same core config as applied, clear pending_reboot
if config.AppliedNetworkConfig != nil {
// create copies ignoring PendingReboot
a := *config.AppliedNetworkConfig
b := applied.NetworkConfig
a.PendingReboot = null.Bool{}
b.PendingReboot = null.Bool{}
if network.IsSame(a, b) {
config.NetworkConfig.PendingReboot = null.BoolFrom(false)
}
}
if err := SaveConfig(); err != nil {
return nil, err
}
@@ -103,3 +138,7 @@ func rpcSetNetworkSettings(settings network.RpcNetworkSettings) (*network.RpcNet
func rpcRenewDHCPLease() error {
return networkState.RpcRenewDHCPLease()
}
func rpcRequestDHCPAddress(ip string) error {
return networkState.RpcRequestDHCPAddress(ip)
}