mirror of
https://github.com/go-gost/gost.git
synced 2026-10-08 12:05:46 +00:00
e2e: add PROXY protocol test (gost#677), bump core/x deps
ProxyProtoSuite starts gost with metadata.proxyProtocol set and asserts the HAProxy PROXY header is prepended on outbound connections (v1/v2), backed by a raw-TCP capture script and configs. Add echo754_repro.py from the hot-reload EADDRINUSE investigation (gost#754). Bump github.com/go-gost/core to v0.6.1 and x to v0.16.0.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
# Raw-TCP backend for the PROXY-protocol e2e test (issue #677).
|
||||
# Reads the first bytes of each connection and reflects whether a HAProxy
|
||||
# PROXY protocol header was prepended by gost:
|
||||
# - v1 ("PROXY TCP4 ...") -> "PROXY-RECEIVED: PROXY TCP4 ..."
|
||||
# - v2 (12-byte signature) -> "PROXY-V2-RECEIVED"
|
||||
# - neither -> "NO-PROXY"
|
||||
import socket
|
||||
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
s.bind(("0.0.0.0", 5678))
|
||||
s.listen(5)
|
||||
|
||||
while True:
|
||||
c, _ = s.accept()
|
||||
d = c.recv(4096)
|
||||
if d[:12] == b"\r\n\r\n\x00\r\nQUIT\n":
|
||||
c.sendall(b"PROXY-V2-RECEIVED\n")
|
||||
elif d[:6] == b"PROXY ":
|
||||
c.sendall(b"PROXY-RECEIVED: " + d.split(b"\r\n", 1)[0] + b"\n")
|
||||
else:
|
||||
c.sendall(b"NO-PROXY\n")
|
||||
c.close()
|
||||
Reference in New Issue
Block a user