fix: dhcp hostname not compatible with some os

This commit is contained in:
Qiu Jian
2023-10-31 12:02:53 +08:00
parent 304e520ce6
commit 9e2e2d6b8d
2 changed files with 4 additions and 6 deletions
+3 -1
View File
@@ -182,10 +182,12 @@ func (s *SGuestDHCPServer) getGuestConfig(
conf.ServerIP = net.ParseIP(v4Ip.NetAddr(int8(masklen)).String())
conf.SubnetMask = net.ParseIP(netutils2.Netlen2Mask(int(masklen)))
conf.BroadcastAddr = v4Ip.BroadcastAddr(int8(masklen)).ToBytes()
conf.Hostname = guestDesc.Name
if len(guestDesc.Hostname) > 0 {
conf.Hostname = guestDesc.Hostname
} else {
conf.Hostname = guestDesc.Name
}
conf.Hostname = strings.ToLower(conf.Hostname)
conf.Domain = nicdesc.Domain
// get main ip
+1 -5
View File
@@ -59,11 +59,7 @@ type ResponseConfig struct {
}
func (conf ResponseConfig) GetHostname() string {
hostname := conf.Hostname
if conf.Domain != "" {
hostname = fmt.Sprintf("%s.%s", hostname, conf.Domain)
}
return hostname
return conf.Hostname
}
func GetOptUint16(val uint16) []byte {