functional programming - How reasonable/possible/difficult is it to write a tsocks clone in Haskell -


i'm reasonably competent programmer knows haskell, hasn't used in major projects. know enough c , systems , network programming believe can pick apart tsocks source code.

i don't have experience low-level systems interfaces haskell provides. i'm looking advice people can offer me on topic, including, "don't it; you'll hate it," provided there explanation.

i wouldn't this, except experiment. i'm haskell guy, not deep systems guy, there's caveat there. nonetheless, see following on tsocks page:

tsocks based on 'shared library interceptor' concept. through use of ld_preload environment variable or /etc/ld.so.preload file tsocks automatically loaded process space of every executed program. there overrides normal connect() function providing own. when application calls connect() establish tcp connection instead passes control tsocks. tsocks determines if connection needs made via socks server (by checking /etc/tsocks.conf) , negotiates connection if (through use of real connect() function )

it possible call haskell c, , vice-versa. , relatively easy, in fact. shared libraries, see this: http://www.haskell.org/ghc/docs/6.12.1/html/users_guide/using-shared-libs.html.

but when invoke haskell c, need a) link in runtime , b) invoke runtime.

so works when c knows calling haskell. relatively trickier when c doesn't know it's calling haskell, , you'd need wrap haskell shared library c library invoked , managed runtime transparently program preloading haskell-tsocks library intercept normal connect functions.

so i'm sure can done -- sounds rather painful , complicated, , expensive in terms of having link whole ghc runtime in 1 feature. , frankly, imagine code you'd writing (i haven't inspected tsocks code yet) largely ffi calls anyway.

so haskell implementation of element of socks -- proxy, client, etc. sounds interesting , potentially useful. exact preload magic tsocks sounds perhaps poor fit.

bear in mind there haskell hackers better @ stuff me, more knowledgeable, , more experienced. might otherwise.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -