Skip to content

Commit

Permalink
ipset: minor refine
Browse files Browse the repository at this point in the history
  • Loading branch information
leiless committed Sep 14, 2020
1 parent 0f45c04 commit 221382e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ Some of the options take a `DURATION` as argument, **zero time(i.e. `0`) duratio

* `no_ipv6` specifies don't try to resolve `IPv6` addresses for DNS exchange in `bootstrap`, in other words, use `IPv4` only.

* `ipset`(need *root* user privilege) specifies resolved IP address from `FROM...` will be added to ipset `SETNAME...`.
* `ipset`(needs *root* user privilege) specifies resolved IP address from `FROM...` will be added to ipset `SETNAME...`.

Note that only `IPv4`, `IPv6` protocol families are supported, and this option **only effective** on Linux.

Expand Down
12 changes: 4 additions & 8 deletions ipset_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,22 @@ func ipsetSetup(u *reloadableUpstream) (err error) {
if u.ipset == nil {
return nil
}
if os.Geteuid() != 0 {
log.Warningf("ipset needs root user privilege to work")
}
ipset := u.ipset.(*ipsetHandle)
ipset.conn, err = goipset.Dial(netfilter.ProtoUnspec, nil)
if err != nil {
return err
}
if os.Geteuid() != 0 {
log.Warningf("ipset needs root user privilege to work")
}
return nil
}

func ipsetShutdown(u *reloadableUpstream) (err error) {
if u.ipset == nil {
return nil
}
err = u.ipset.(*ipsetHandle).conn.Close()
if err != nil {
return err
}
return nil
return u.ipset.(*ipsetHandle).conn.Close()
}

// Taken from https://github.com/missdeer/ipset/blob/master/reverter.go#L32 with modification
Expand Down

0 comments on commit 221382e

Please sign in to comment.