Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue: 2926 whitelist by hostname #2953

Merged
merged 6 commits into from
Jan 30, 2019

Conversation

codexnull
Copy link
Contributor

@codexnull codexnull commented Jan 30, 2019

Fixes #2926. In addition to addrLo:addrHi ranges, support whitelisting by

  • a single IP address (e.g. 144.142.126.254)
  • a CIDR block (e.g. 192.168.0.0/16)
  • a hostname (e.g. host.docker.internal)

This change is Reviewable

rangeHi := make(net.IP, len(rangeLo))
copy(rangeHi, rangeLo)
for i := 1; i <= maskLen; i++ {
rangeHi[addrLen - i] |= ^network.Mask[maskLen - i]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File is not goimports-ed (from goimports)

Copy link
Contributor

@manishrjain manishrjain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 2 of 2 files at r2.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @codexnull, @golangcibot, and @srfrog)


dgraph/cmd/alpha/run.go, line 231 at r2 (raw file):

			rangeLo := net.ParseIP(tuple[0])
			rangeHi := net.ParseIP(tuple[1])
			if rangeLo == nil {

@srfrog would do a switch case here. Looks nicer as well.

Copy link
Contributor

@srfrog srfrog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @golangcibot and @manishrjain)


dgraph/cmd/alpha/run.go, line 231 at r2 (raw file):

Previously, manishrjain (Manish R Jain) wrote…

@srfrog would do a switch case here. Looks nicer as well.

yes, if more than one else case, i'd use a switch.
https://golang.org/doc/effective_go.html#switch

@codexnull codexnull merged commit 0a77d2e into master Jan 30, 2019
@codexnull codexnull deleted the javier/issue2926_whitelist_by_hostname branch February 22, 2019 19:13
dna2github pushed a commit to dna2fork/dgraph that referenced this pull request Jul 19, 2019
Changes:

* Add support for whitelisting by
   * hostname
   * single IP address
   * CIDR block
   * IPv6

* Add IP string parsing test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants