Fix fakeip lookup

This commit is contained in:
世界
2023-07-11 14:05:14 +08:00
parent bb651db2d2
commit 120dae4eed
5 changed files with 94 additions and 20 deletions

View File

@@ -4,7 +4,6 @@ import (
"net/netip"
"github.com/sagernet/sing-box/adapter"
"github.com/sagernet/sing-dns"
E "github.com/sagernet/sing/common/exceptions"
"github.com/sagernet/sing/common/logger"
)
@@ -72,9 +71,12 @@ func (s *Store) Close() error {
})
}
func (s *Store) Create(domain string, strategy dns.DomainStrategy) (netip.Addr, error) {
func (s *Store) Create(domain string, isIPv6 bool) (netip.Addr, error) {
if address, loaded := s.storage.FakeIPLoadDomain(domain, isIPv6); loaded {
return address, nil
}
var address netip.Addr
if strategy == dns.DomainStrategyUseIPv4 {
if !isIPv6 {
if !s.inet4Current.IsValid() {
return netip.Addr{}, E.New("missing IPv4 fakeip address range")
}