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

treat ipv6 addresses correctly #118

Merged
merged 1 commit into from
Sep 10, 2018
Merged

Conversation

NixM0nk3y
Copy link
Contributor

When dealing with IPv6 addresses - Sprintf will not do the right thing i.e.

Host: fd00::7c46
Port: 80

Results in upstream target of:

POST /upstreams/myservice.http-svc.80/targets HTTP/1.1
{"target":"fd00::7c46:80","upstream_id":"2e0a4d5a-ed01-4858-ac12-9c3f11df7556"}

Which results in unreachable targets

2018/09/09 14:48:06 [error] 38#38: *22634 connect() failed (113: Host is unreachable) while connecting to upstream, client: fd00::1, server: kong, request: "GET / HTTP/1.1", upstream: "http://[fd00:0000:0000:0000:0000:0000:7c46:0080]:8000/", host: "foo.bar"

The correct API call is:

POST /upstreams/myservice.http-svc.80/targets HTTP/1.1
{"target":"[fd00::7c46]:80","upstream_id":"2e0a4d5a-ed01-4858-ac12-9c3f11df7556"}

golangs standard net.JoinHostPort will do the right thing for both IPv4 + IPv6

@codecov-io
Copy link

Codecov Report

Merging #118 into master will not change coverage.
The diff coverage is 0%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #118   +/-   ##
=======================================
  Coverage   32.09%   32.09%           
=======================================
  Files          33       33           
  Lines        2891     2891           
=======================================
  Hits          928      928           
  Misses       1850     1850           
  Partials      113      113
Impacted Files Coverage Δ
internal/ingress/controller/kong.go 1.22% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a8838ab...6f0a8b2. Read the comment docs.

Copy link
Member

@hbagdi hbagdi left a comment

Choose a reason for hiding this comment

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

Verified JoinHostPort() does what it should and Kong processes IPv6 correctly. Will merge shortly.

@hbagdi
Copy link
Member

hbagdi commented Sep 10, 2018

@NixM0nk3y Thank you for taking the time to fix this issue!

@hbagdi hbagdi merged commit 1fa2c1e into Kong:master Sep 10, 2018
hbagdi pushed a commit that referenced this pull request Oct 23, 2018
IPv6 addresses contain colon(`:`) which results in incorrect parsing and interpretation.

From #118
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants