You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To talk to a tor hidden service using servant-client, I implemented my own managerRawConnection. It simply uses socks to open the tor socket, and then needs to turn the Socket into a Connection.
There's a function to do that, socketConnection, but it's not exported from http-client at all. That leaves Network.HTTP.Client.makeConnection, which has no api stability. So, it would be great to get either of these promoted to the stable API to allow for this and other use cases for using socks.
Here's the code I wrote to talk to tor hidden services. I could see making a http-client-socks or a http-client-tor library out of this eventually, but not today.
torableManager :: ManagerSettings
torableManager = defaultManagerSettings
{ managerRawConnection = return conn
}
where
conn addr host port
| ".onion" `isSuffixOf` (map toLower host) = torConnection host port
| otherwise = do
regular <- managerRawConnection defaultManagerSettings
regular addr host port
torConnection :: HostName -> Port -> IO Connection
torConnection onionaddress p = do
(socket, _) <- socksConnect torsockconf socksaddr
socketConnection socket 8192
where
torsocksport = 9050
torsockconf = defaultSocksConf "127.0.0.1" torsocksport
socksdomain = SocksAddrDomainName (BU8.fromString onionaddress)
socksaddr = SocksAddress socksdomain (fromIntegral p)
-- copied from http-client
socketConnection :: Network.Socket.Socket -> Int -> IO Connection
socketConnection socket chunksize = makeConnection
(recv socket chunksize)
(sendAll socket)
(Network.Socket.close socket)
The text was updated successfully, but these errors were encountered:
To talk to a tor hidden service using servant-client, I implemented my own managerRawConnection. It simply uses socks to open the tor socket, and then needs to turn the Socket into a Connection.
There's a function to do that, socketConnection, but it's not exported from http-client at all. That leaves Network.HTTP.Client.makeConnection, which has no api stability. So, it would be great to get either of these promoted to the stable API to allow for this and other use cases for using socks.
Here's the code I wrote to talk to tor hidden services. I could see making a http-client-socks or a http-client-tor library out of this eventually, but not today.
The text was updated successfully, but these errors were encountered: