|David Sweetman 2052ba59ed Refactor proxy_delegate cases into separate functions.||1 year ago|
|config||2 years ago|
|lib||1 year ago|
|test||2 years ago|
|.gitignore||2 years ago|
|README.md||2 years ago|
|mix.exs||2 years ago|
|mix.lock||2 years ago|
Started by following this erlang tutorial but extended to actually proxy requests to a remote host.
tcpproxy.ex accepts connections and creates/owns the upstream and downstream sockets. It stores a reference of active connections in an ets table.
proxy_delegate.ex determines what to do with the data when it is received from either the upstream or downstream socket. In this example it just forwards the data and counts the number of bytes that pass up and down.
mix run --no-halt mix.exs --listen 4040 --host example.com:80 # try it out curl --header 'Host: example.com' localhost:4040