ahmetb / go-httpbin

http://httpbin.org endpoints for your Go tests
https://godoc.org/github.com/ahmetalpbalkan/go-httpbin
Apache License 2.0
124 stars 26 forks source link

Return a few IPs in `origin` field #3

Closed egorsmkv closed 7 years ago

egorsmkv commented 7 years ago

Check this line: https://github.com/Runscope/httpbin/blob/master/httpbin/helpers.py#L184

For example: I send http request with proxy server and get this response:

{"headers":{"Accept-Encoding":"gzip","Cache-Control":"max-age=259200","Connection":"keep-alive","Cookie":"foo=1234","Referer":"http://foobar.com","User-Agent":"Mozilla/5.0 (X11; Linux x86_64) AWK/537.36 (KHTML, like Gecko) Ubuntu Chromium/49.0.2623.108 Chrome/49.0.2623.108 Safari/537.36","Via":"1.1 ricknetfree (squid/3.1.20)","X-Forwarded-For":"93.76.210.86"},"origin":"89.38.148.120","url":"","args":{}}

I think you should add IP from X-Forwarded-For field to origin field.

ahmetb commented 7 years ago

Thanks for reporting. Can you contrib a patch? It should be as easy as extracting h, _, _ := net.SplitHostPort(r.RemoteAddr) (used in several places) into a method.

egorsmkv commented 7 years ago

Okay. I send PR, only later.

egorsmkv commented 7 years ago

@ahmetalpbalkan I have my doubts.

Perhaps it's NGINX adds a comma to the original IP when proxying application.

ahmetb commented 7 years ago

you can just copy the logic in the other httpbin project, I think it's pretty standard.

ahmetb commented 7 years ago

Closing, feel free to send a patch if still interested.