mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +08:00
Fix rewrite and over-long header handling on Windows
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI MacOS / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI Windows / ${{ matrix.target }} (windows-2022) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (windows-2022) (push) Waiting to run
C/C++ CI cmake / ubuntu-latest (wolfSSL) (push) Waiting to run
Update HTML documentation / docs (push) Has been cancelled
Update wiki / wiki (push) Has been cancelled
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI MacOS / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI Windows / ${{ matrix.target }} (windows-2022) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (windows-2022) (push) Waiting to run
C/C++ CI cmake / ubuntu-latest (wolfSSL) (push) Waiting to run
Update HTML documentation / docs (push) Has been cancelled
Update wiki / wiki (push) Has been cancelled
op_rewrite checked what it built with targetunsafe(), which describes a path on this machine: on Windows it must name a drive or a share, so a rewritten request path was refused and every rewrite rule failed there. A rewrite produces a request path and is checked as one. The header loop stopped at HTTPSRV_MAXHDR and answered anyway, leaving the rest of the request in the stream for the next one to be read out of. It refuses the request instead. A header longer than the buffer arrives as several lines, so the count bounds what is read rather than what a client may send in one header. The test for the buffer growth after a PCRE rewrite sent its request through to an httpsrv origin, which stops reading at that same cap; it uses an origin which reads whatever it is sent, since what is under test is the proxy in the middle.
This commit is contained in:
1 parent
5400d53cef
commit
f265ea0b52
3 files changed
+43
-14
No files matched your search
+11
-4
@@ -375,12 +375,14 @@ class Tester:
|
||||
text, _ = self.raw_session(pport, request, host=phost, quiet=2)
|
||||
return text
|
||||
|
||||
def raw_server(self, port, reply, close_after=True, host="127.0.0.1"):
|
||||
def raw_server(self, port, reply, close_after=True, host="127.0.0.1",
|
||||
drain=False):
|
||||
"""Answer every connection with fixed bytes. Returns a stop function.
|
||||
|
||||
For the shapes a real server would have to be talked into: an answer
|
||||
whose body is delimited by the close, or one which promises to stay
|
||||
and does not.
|
||||
and does not. drain reads the whole request first, however large,
|
||||
which is what a test of the sending side needs.
|
||||
"""
|
||||
sock = socket.socket()
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
@@ -395,8 +397,13 @@ class Tester:
|
||||
except OSError:
|
||||
break
|
||||
try:
|
||||
conn.settimeout(self.timeout)
|
||||
conn.recv(65536)
|
||||
conn.settimeout(0.5 if drain else self.timeout)
|
||||
while True:
|
||||
try:
|
||||
if not conn.recv(65536) or not drain:
|
||||
break
|
||||
except socket.timeout:
|
||||
break # it has stopped sending
|
||||
conn.sendall(reply)
|
||||
if close_after:
|
||||
conn.close()
|
||||
|
||||
Reference in new issue
Block a user