guestnetworks: IsExit()减少一次数据库查询

This commit is contained in:
Yousong Zhou
2019-09-26 03:53:35 +00:00
parent 49a2c10dec
commit add3616007
+6
View File
@@ -546,6 +546,12 @@ func calculateNics(q *sqlchemy.SQuery) GuestnicsCount {
}
func (self *SGuestnetwork) IsExit() bool {
if self.IpAddr != "" {
addr, err := netutils.NewIPV4Addr(self.IpAddr)
if err == nil {
return netutils.IsExitAddress(addr)
}
}
net := self.GetNetwork()
if net != nil {
return net.IsExitNetwork()