Skip to content

Commit

Permalink
Fix route address set update
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Jun 17, 2024
1 parent 85f5f2d commit e17436c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions redirect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions redirect_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions redirect_nftables_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e17436c

Please sign in to comment.