diff options
Diffstat (limited to 'httpconnectd.sh')
-rw-r--r-- | httpconnectd.sh | 30 |
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 "$@" |