[erlang-questions] how to bind to divert socket in erlang

14 views
Skip to first unread message

Michael van Slingerland

unread,
Aug 30, 2012, 10:08:56 AM8/30/12
to erlang-q...@erlang.org
Hi,

I am working on a transparent proxy on openbsd that adds headers to
http get requests.
everything passing through the machine destined for port 80 will be
redirect through a divert-socket to a userland daemon listening on
port 8080.

In python it is quite simple:

socket.IPPROTO_DIVERT = 258
self.sock = socket.socket(socket.AF_INET, socket.SOCK_RAW,
socket.IPPROTO_DIVERT)
self.sock.bind(("0.0.0.0", port))

This makes the program listen on a divert socket on port 8080.

My question is how I can set this in erlang?
I am no erlang expert, I have been browsing through the gen_tcp an
inet docs, but no success.

Any help appreciated!

thanks,
Mike
_______________________________________________
erlang-questions mailing list
erlang-q...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

Gleb Peregud

unread,
Aug 30, 2012, 10:25:37 AM8/30/12
to Michael van Slingerland, erlang-q...@erlang.org
I'm not sure if it helps, but read inet:setops/2 (especially last few
paragraphs) and it it doesn't help, take a look at procket:

https://github.com/msantos/procket
Reply all
Reply to author
Forward
0 new messages