summaryrefslogtreecommitdiff
path: root/httpconnectd.sh
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-01-22 15:28:56 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-01-22 15:28:56 -0500
commitc80e4036fbac53039b607c4bb8a5489d016a009f (patch)
tree71890b78ecfa239b2f3e272b501f63c87ab3ec32 /httpconnectd.sh
initial commit
Diffstat (limited to 'httpconnectd.sh')
-rw-r--r--httpconnectd.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/httpconnectd.sh b/httpconnectd.sh
new file mode 100644
index 0000000..ff22d13
--- /dev/null
+++ b/httpconnectd.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+# Copyright 2016 Luke Shumaker
+# License: WTFPLv2
+
+# Dependencies:
+# - bash
+# - socat
+# - date -R
+
+server='httpconnectd'
+
+MethodNotAllowed() {
+ printf '%\r\n' \
+ 'HTTP/1.1 405 Method Not Allowed' \
+ "Server: $server" \
+ "Date: $(date -R)" \
+ 'Allow: CONNECT' \
+ ''
+ exit 0
+}
+
+worker() {
+ read -r method dest version
+ if [[ "$method" != CONNECT ]]; then
+ MethodNotAllowed
+ fi
+ exec socat STDIO TCP-CONNECT:"$dest"
+}
+
+worker "$@"