-
Notifications
You must be signed in to change notification settings - Fork 35
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
Update transport.go , to fix ntlm 407 challenge httpresponse containing extra httpbody issue #119
Conversation
…ddress instead of nonloopback address
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ziyiwang for the PR, and for the bug report! These look like two separate bugs that you're running into, I've left a comment on each of the proposed fixes.
// No packets are ever sent, because UDP is "connectionless". | ||
// The IP address chosen is in one of the "documentation" prefixes that are guaranteed not to exist on the | ||
// internet, and is therefore "safe" to use. It will generally follow the default route set in the OS. | ||
conn, err := net.Dial("udp", "192.0.2.1:53") // RFC5737 TEST-NET-1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense to do a UDP dial and take the local IP address, but it's not really clear to me which network interface the OS will choose to dial 192.0.2.1. RFC5737 says that this address "SHOULD" be unroutable, but maybe it's possible for people to, for example, set this up as a local test network which would quietly break Alpaca in unexpected ways?
Before we settle on an approach, I'd like to test a few scenarios myself first (including what happens if I try to make a UDP connection to this IP). I'll get back to you on that later this week, but let's make this myIpAddress() fix in a separate PR? It seems unrelated to the other change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ziyiwang I took a look at this, and yes Alpaca does give the "wrong" IP address back - in my case, it returns my WiFi adapter's IP address, rather than the VPN address, so similar to what you were seeing.
I've written up the problem here: #122.
I personally don't need to use the myIpAddress() function, so thanks for reporting this, it's not something I would've noticed myself.
var resp2 *http.Response | ||
var err2 error | ||
|
||
resp2,err2 = http.ReadResponse(t.reader, req) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure it's correct to read another response here. This function gets called by ProxyHandler.proxyRequest(), and the body of the response gets closed later in that file. Since this is done in a defer
statement, it might not happen until after the next request is sent, which I think is the bug that you're running into.
If that's the case, then I think #120 would fix it - any chance you can give that branch a try and let me know if it fixes your issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure let me test it out and come back to you, most likely removing defer will also fix the issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, let's continue the discussion in that PR.
to fix ntlm 407 challenge httpresponse containing extra httpbody issue issue #118
extra httpBody in httpResponse with 407 , is not read and stuck in stream, the body needs to be read and discarded before next HTTP response comes in (HTTP 200) , otherwise the stuck body in stream will cause HTTP response error