aboutsummaryrefslogtreecommitdiff
path: root/ip-echo-daemon
diff options
context:
space:
mode:
authorJason McCormick <jason@mfamily.org>2026-11-02 20:42:45 -0500
committerJason McCormick <jason@mfamily.org>2026-11-02 20:42:45 -0500
commitc333e4c76d42dc5c813a52b22fbe5328304a8ae8 (patch)
treea8b582bdbce3097947395f4c8a289ee0b3ddb347 /ip-echo-daemon
parent2474f6cade62ba937ff714f0aa54555f7ebc18d8 (diff)
updates for prod
Diffstat (limited to 'ip-echo-daemon')
-rwxr-xr-xip-echo-daemon13
1 files changed, 11 insertions, 2 deletions
diff --git a/ip-echo-daemon b/ip-echo-daemon
index 5b66801..1864956 100755
--- a/ip-echo-daemon
+++ b/ip-echo-daemon
@@ -22,14 +22,23 @@ class AddressHandler(BaseHTTPRequestHandler):
server_version = "ip-echo-daemon"
sys_version = ""
+ def send_error(self, code, message=None, explain=None):
+ body = (str(code) + "\n").encode("ascii")
+ self.send_response(code)
+ self.send_header("Content-Type", "text/plain; charset=us-ascii")
+ self.send_header("Content-Length", str(len(body)))
+ self.end_headers()
+ if self.command != "HEAD":
+ self.wfile.write(body)
+
def do_GET(self):
if self.path != "/":
self.send_error(404)
return
try:
address = proxied_address(self.client_address[0], self.headers.get("X-Real-IP"))
- except ValueError as exc:
- self.send_error(400, str(exc))
+ except ValueError:
+ self.send_error(400)
return
body = (str(address) + "\n").encode("ascii")
self.send_response(200)