chore: cleanup netip code

This commit is contained in:
wwqgtxx
2025-04-09 11:39:00 +08:00
parent b2d2890866
commit cac2bf72e1
10 changed files with 48 additions and 109 deletions

View File

@@ -6,9 +6,10 @@ import (
"strings"
"sync"
"github.com/metacubex/mihomo/common/nnip"
"github.com/metacubex/mihomo/component/profile/cachefile"
C "github.com/metacubex/mihomo/constant"
"go4.org/netipx"
)
const (
@@ -183,7 +184,7 @@ func New(options Options) (*Pool, error) {
hostAddr = options.IPNet.Masked().Addr()
gateway = hostAddr.Next()
first = gateway.Next().Next().Next() // default start with 198.18.0.4
last = nnip.UnMasked(options.IPNet)
last = netipx.PrefixLastIP(options.IPNet)
)
if !options.IPNet.IsValid() || !first.IsValid() || !first.Less(last) {