ahmetb / go-httpbin

http://httpbin.org endpoints for your Go tests

Home Page:https://godoc.org/github.com/ahmetalpbalkan/go-httpbin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Return a few IPs in `origin` field

egorsmkv opened this issue · comments

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.

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.

Okay. I send PR, only later.

@ahmetalpbalkan I have my doubts.

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

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

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