fix: update NetworkConfig type in config.go

This commit is contained in:
Siyuan 2025-10-09 21:05:31 +00:00
parent 52ddc9ebe5
commit a9cd36c5fb
2 changed files with 27 additions and 97 deletions

View File

@ -78,33 +78,33 @@ func (m *KeyboardMacro) Validate() error {
}
type Config struct {
CloudURL string `json:"cloud_url"`
CloudAppURL string `json:"cloud_app_url"`
CloudToken string `json:"cloud_token"`
GoogleIdentity string `json:"google_identity"`
JigglerEnabled bool `json:"jiggler_enabled"`
JigglerConfig *JigglerConfig `json:"jiggler_config"`
AutoUpdateEnabled bool `json:"auto_update_enabled"`
IncludePreRelease bool `json:"include_pre_release"`
HashedPassword string `json:"hashed_password"`
LocalAuthToken string `json:"local_auth_token"`
LocalAuthMode string `json:"localAuthMode"` //TODO: fix it with migration
LocalLoopbackOnly bool `json:"local_loopback_only"`
WakeOnLanDevices []WakeOnLanDevice `json:"wake_on_lan_devices"`
KeyboardMacros []KeyboardMacro `json:"keyboard_macros"`
KeyboardLayout string `json:"keyboard_layout"`
EdidString string `json:"hdmi_edid_string"`
ActiveExtension string `json:"active_extension"`
DisplayRotation string `json:"display_rotation"`
DisplayMaxBrightness int `json:"display_max_brightness"`
DisplayDimAfterSec int `json:"display_dim_after_sec"`
DisplayOffAfterSec int `json:"display_off_after_sec"`
TLSMode string `json:"tls_mode"` // options: "self-signed", "user-defined", ""
UsbConfig *usbgadget.Config `json:"usb_config"`
UsbDevices *usbgadget.Devices `json:"usb_devices"`
NetworkConfig *network.NetworkConfig `json:"network_config"`
DefaultLogLevel string `json:"default_log_level"`
VideoSleepAfterSec int `json:"video_sleep_after_sec"`
CloudURL string `json:"cloud_url"`
CloudAppURL string `json:"cloud_app_url"`
CloudToken string `json:"cloud_token"`
GoogleIdentity string `json:"google_identity"`
JigglerEnabled bool `json:"jiggler_enabled"`
JigglerConfig *JigglerConfig `json:"jiggler_config"`
AutoUpdateEnabled bool `json:"auto_update_enabled"`
IncludePreRelease bool `json:"include_pre_release"`
HashedPassword string `json:"hashed_password"`
LocalAuthToken string `json:"local_auth_token"`
LocalAuthMode string `json:"localAuthMode"` //TODO: fix it with migration
LocalLoopbackOnly bool `json:"local_loopback_only"`
WakeOnLanDevices []WakeOnLanDevice `json:"wake_on_lan_devices"`
KeyboardMacros []KeyboardMacro `json:"keyboard_macros"`
KeyboardLayout string `json:"keyboard_layout"`
EdidString string `json:"hdmi_edid_string"`
ActiveExtension string `json:"active_extension"`
DisplayRotation string `json:"display_rotation"`
DisplayMaxBrightness int `json:"display_max_brightness"`
DisplayDimAfterSec int `json:"display_dim_after_sec"`
DisplayOffAfterSec int `json:"display_off_after_sec"`
TLSMode string `json:"tls_mode"` // options: "self-signed", "user-defined", ""
UsbConfig *usbgadget.Config `json:"usb_config"`
UsbDevices *usbgadget.Devices `json:"usb_devices"`
NetworkConfig *types.NetworkConfig `json:"network_config"`
DefaultLogLevel string `json:"default_log_level"`
VideoSleepAfterSec int `json:"video_sleep_after_sec"`
}
func (c *Config) GetDisplayRotation() uint16 {

View File

@ -192,76 +192,6 @@ func (c *Client) ensureInterfaceUp(ifname string) (*link.Link, error) {
return nlm.EnsureInterfaceUpWithTimeout(c.ctx, iface, c.cfg.LinkUpTimeout)
}
// func (c *Client) sendInitialRequests() chan any {
// return c.sendRequests(c.cfg.IPv4, c.cfg.IPv6)
// }
// func (c *Client) sendRequestsFamily(
// family int,
// wg *sync.WaitGroup,
// r *chan any,
// l *zerolog.Logger,
// iface *link.Link,
// ) {
// wg.Add(1)
// go func(iface *link.Link) {
// defer wg.Done()
// var (
// lease *Lease
// err error
// )
// switch family {
// case link.AfInet:
// lease, err = c.requestLease4(iface)
// case link.AfInet6:
// lease, err = c.requestLease6(iface)
// }
// if err != nil {
// l.Error().Err(err).Msg("Could not get lease")
// return
// }
// (*r) <- lease
// }(iface)
// }
// func (c *Client) sendRequests(ipv4, ipv6 bool) chan any {
// c.mu.Lock()
// defer c.mu.Unlock()
// // Yeah, this is a hack, until we can cancel all leases in progress.
// r := make(chan any, 3*len(c.ifaces))
// var wg sync.WaitGroup
// for _, iface := range c.ifaces {
// wg.Add(1)
// go func(ifname string) {
// defer wg.Done()
// l := c.l.With().Str("interface", ifname).Logger()
// iface, err := c.ensureInterfaceUp(ifname)
// if err != nil {
// l.Error().Err(err).Msg("Could not bring up interface")
// return
// }
// if ipv4 {
// c.sendRequestsFamily(link.AfInet, &wg, &r, &l, iface)
// }
// if ipv6 {
// c.sendRequestsFamily(link.AfInet6, &wg, &r, &l, iface)
// }
// }(iface)
// }
// go func() {
// wg.Wait()
// close(r)
// }()
// return r
// }
// Lease4 returns the current IPv4 lease
func (c *Client) Lease4() *types.DHCPLease {
c.lease4Mu.Lock()