diff --git a/redirect.go b/redirect.go index 8f131ac..ec238c3 100644 --- a/redirect.go +++ b/redirect.go @@ -30,6 +30,6 @@ type AutoRedirectOptions struct { TableName string DisableNFTables bool CustomRedirectPort func() int - RouteAddressSet *[]*netipx.IPSet - RouteExcludeAddressSet *[]*netipx.IPSet + RouteAddressSet func() []*netipx.IPSet + RouteExcludeAddressSet func() []*netipx.IPSet } diff --git a/redirect_linux.go b/redirect_linux.go index cafdd61..0db60be 100644 --- a/redirect_linux.go +++ b/redirect_linux.go @@ -39,8 +39,8 @@ type autoRedirect struct { useNFTables bool androidSu bool suPath string - routeAddressSet *[]*netipx.IPSet - routeExcludeAddressSet *[]*netipx.IPSet + routeAddressSet func() []*netipx.IPSet + routeExcludeAddressSet func() []*netipx.IPSet } func NewAutoRedirect(options AutoRedirectOptions) (AutoRedirect, error) { diff --git a/redirect_nftables_rules.go b/redirect_nftables_rules.go index 8cb78e5..840f8ea 100644 --- a/redirect_nftables_rules.go +++ b/redirect_nftables_rules.go @@ -27,8 +27,8 @@ func (r *autoRedirect) nftablesCreateAddressSets( nft *nftables.Conn, table *nftables.Table, update bool, ) error { - routeAddressSet := *r.routeAddressSet - routeExcludeAddressSet := *r.routeExcludeAddressSet + routeAddressSet := r.routeAddressSet() + routeExcludeAddressSet := r.routeExcludeAddressSet() if len(routeAddressSet) == 0 && len(routeExcludeAddressSet) == 0 { return nil } @@ -404,8 +404,8 @@ func (r *autoRedirect) nftablesCreateExcludeRules(nft *nftables.Conn, table *nft nftablesCreateExcludeDestinationIPSet(nft, table, chain, 6, "inet6_local_address_set", nftables.TableFamilyIPv6, false) } - routeAddressSet := *r.routeAddressSet - routeExcludeAddressSet := *r.routeExcludeAddressSet + routeAddressSet := r.routeAddressSet() + routeExcludeAddressSet := r.routeExcludeAddressSet() if r.enableIPv4 && len(routeAddressSet) > 0 { nftablesCreateExcludeDestinationIPSet(nft, table, chain, 1, "inet4_route_address_set", nftables.TableFamilyIPv4, true)