Enhance Network Interface Detection and Configuration Management

- Implemented robust network interface detection with `GetInterfaces()` function
- Added validation for network interface names using regex patterns
- Updated `Network` struct to improve YAML tag formatting
- Modified `Gather()` and `SaveConfig()` methods to streamline network configuration
- Removed redundant `SaveConfig()` calls in various methods
- Added comprehensive network interface name validation logic
This commit is contained in:
zeaslity
2025-02-28 11:19:29 +08:00
parent c10554c218
commit b28c6462f1
5 changed files with 106 additions and 7 deletions

View File

@@ -57,12 +57,12 @@ type OS struct {
OsType string `yaml:"os_type"`
Kernel string `yaml:"kernel"`
Arch string `yaml:"arch"`
IsUbuntuType bool `yaml:"is_ubuntu_type",comment:"是否是ubuntu类型的操作系统"`
PackInit bool `yaml:"pack_init",comment:"是否初始化ubuntu需要"`
IsUbuntuType bool `yaml:"is_ubuntu_type" comment:"是否是ubuntu类型的操作系统"`
PackInit bool `yaml:"pack_init" comment:"是否初始化ubuntu需要"`
}
type Network struct {
Internet int `yaml:"internet",comment:"是否能够上网 外网为9 国内为7 不能上网为1"`
Internet int `yaml:"internet" comment:"是否能够上网 外网为9 国内为7 不能上网为1"`
Public PublicInfo `yaml:"public"`
Interfaces []Interface `yaml:"interfaces"`
}