mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-22 08:31:30 +00:00
Fix save FakeIP cache
This commit is contained in:
parent
230e8f895d
commit
ec1160924f
|
@ -252,7 +252,7 @@ func NewRouter(
|
||||||
if fakeIPOptions.Inet6Range != nil {
|
if fakeIPOptions.Inet6Range != nil {
|
||||||
inet6Range = fakeIPOptions.Inet6Range.Build()
|
inet6Range = fakeIPOptions.Inet6Range.Build()
|
||||||
}
|
}
|
||||||
router.fakeIPStore = fakeip.NewStore(router, inet4Range, inet6Range)
|
router.fakeIPStore = fakeip.NewStore(router, router.logger, inet4Range, inet6Range)
|
||||||
}
|
}
|
||||||
|
|
||||||
usePlatformDefaultInterfaceMonitor := platformInterface != nil && platformInterface.UsePlatformDefaultInterfaceMonitor()
|
usePlatformDefaultInterfaceMonitor := platformInterface != nil && platformInterface.UsePlatformDefaultInterfaceMonitor()
|
||||||
|
|
|
@ -6,12 +6,14 @@ import (
|
||||||
"github.com/sagernet/sing-box/adapter"
|
"github.com/sagernet/sing-box/adapter"
|
||||||
"github.com/sagernet/sing-dns"
|
"github.com/sagernet/sing-dns"
|
||||||
E "github.com/sagernet/sing/common/exceptions"
|
E "github.com/sagernet/sing/common/exceptions"
|
||||||
|
"github.com/sagernet/sing/common/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ adapter.FakeIPStore = (*Store)(nil)
|
var _ adapter.FakeIPStore = (*Store)(nil)
|
||||||
|
|
||||||
type Store struct {
|
type Store struct {
|
||||||
router adapter.Router
|
router adapter.Router
|
||||||
|
logger logger.Logger
|
||||||
inet4Range netip.Prefix
|
inet4Range netip.Prefix
|
||||||
inet6Range netip.Prefix
|
inet6Range netip.Prefix
|
||||||
storage adapter.FakeIPStorage
|
storage adapter.FakeIPStorage
|
||||||
|
@ -19,9 +21,10 @@ type Store struct {
|
||||||
inet6Current netip.Addr
|
inet6Current netip.Addr
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStore(router adapter.Router, inet4Range netip.Prefix, inet6Range netip.Prefix) *Store {
|
func NewStore(router adapter.Router, logger logger.Logger, inet4Range netip.Prefix, inet6Range netip.Prefix) *Store {
|
||||||
return &Store{
|
return &Store{
|
||||||
router: router,
|
router: router,
|
||||||
|
logger: logger,
|
||||||
inet4Range: inet4Range,
|
inet4Range: inet4Range,
|
||||||
inet6Range: inet6Range,
|
inet6Range: inet6Range,
|
||||||
}
|
}
|
||||||
|
@ -92,10 +95,12 @@ func (s *Store) Create(domain string, strategy dns.DomainStrategy) (netip.Addr,
|
||||||
s.inet6Current = nextAddress
|
s.inet6Current = nextAddress
|
||||||
address = nextAddress
|
address = nextAddress
|
||||||
}
|
}
|
||||||
err := s.storage.FakeIPStore(address, domain)
|
go func() {
|
||||||
if err != nil {
|
err := s.storage.FakeIPStore(address, domain)
|
||||||
return netip.Addr{}, err
|
if err != nil {
|
||||||
}
|
s.logger.Warn("save FakeIP address pair: ", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
return address, nil
|
return address, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue