diff options
author | joe <joe@jerkface.net> | 2017-10-02 18:27:12 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2017-10-02 18:27:12 -0400 |
commit | f7a3c6c057244c8ca14bb9c6ad4bdfb4629ac154 (patch) | |
tree | 833b7bd39883e56a16a230244fec04f06d8ac755 /src/Network/Tox.hs | |
parent | d408e6c3148106c6dbc8afe24a1488619adf34e1 (diff) |
Stubs for maintaining onion routes.
Diffstat (limited to 'src/Network/Tox.hs')
-rw-r--r-- | src/Network/Tox.hs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/Network/Tox.hs b/src/Network/Tox.hs index 3c5fc955..7814046e 100644 --- a/src/Network/Tox.hs +++ b/src/Network/Tox.hs | |||
@@ -93,6 +93,7 @@ import qualified Network.Tox.Onion.Transport as Onion | |||
93 | import qualified Network.Tox.Onion.Handlers as Onion | 93 | import qualified Network.Tox.Onion.Handlers as Onion |
94 | import Network.Tox.Crypto.Transport (NetCrypto) | 94 | import Network.Tox.Crypto.Transport (NetCrypto) |
95 | import Text.XXD | 95 | import Text.XXD |
96 | import OnionRouter | ||
96 | 97 | ||
97 | newCrypto :: IO TransportCrypto | 98 | newCrypto :: IO TransportCrypto |
98 | newCrypto = do | 99 | newCrypto = do |
@@ -157,9 +158,10 @@ newClient :: (DRG g, Show addr, Show meth) => | |||
157 | -> (x -> MessageClass String meth DHT.TransactionId) | 158 | -> (x -> MessageClass String meth DHT.TransactionId) |
158 | -> (Maybe addr -> IO addr) | 159 | -> (Maybe addr -> IO addr) |
159 | -> (meth -> Maybe (MethodHandler String DHT.TransactionId addr x)) | 160 | -> (meth -> Maybe (MethodHandler String DHT.TransactionId addr x)) |
161 | -> (forall d. TransactionMethods d DHT.TransactionId x -> TransactionMethods d DHT.TransactionId x) | ||
160 | -> (Client String meth DHT.TransactionId addr x -> Transport String addr x -> Transport String addr x) | 162 | -> (Client String meth DHT.TransactionId addr x -> Transport String addr x -> Transport String addr x) |
161 | -> IO (Client String meth DHT.TransactionId addr x) | 163 | -> IO (Client String meth DHT.TransactionId addr x) |
162 | newClient drg net classify selfAddr handlers modifynet = do | 164 | newClient drg net classify selfAddr handlers modifytbl modifynet = do |
163 | -- If we have 8-byte keys for IntMap, then use it for transaction lookups. | 165 | -- If we have 8-byte keys for IntMap, then use it for transaction lookups. |
164 | -- Otherwise, use ordinary Map. The details of which will be hidden by an | 166 | -- Otherwise, use ordinary Map. The details of which will be hidden by an |
165 | -- existential closure (see mkclient below). | 167 | -- existential closure (see mkclient below). |
@@ -176,7 +178,7 @@ newClient drg net classify selfAddr handlers modifynet = do | |||
176 | let dispatch tbl var handlers = DispatchMethods | 178 | let dispatch tbl var handlers = DispatchMethods |
177 | { classifyInbound = classify | 179 | { classifyInbound = classify |
178 | , lookupHandler = handlers -- var | 180 | , lookupHandler = handlers -- var |
179 | , tableMethods = tbl | 181 | , tableMethods = modifytbl tbl |
180 | } | 182 | } |
181 | mkclient (tbl,var) handlers = | 183 | mkclient (tbl,var) handlers = |
182 | let client = Client | 184 | let client = Client |
@@ -224,11 +226,12 @@ newTox keydb addr = do | |||
224 | crypto <- newCrypto | 226 | crypto <- newCrypto |
225 | drg <- drgNew | 227 | drg <- drgNew |
226 | let lookupClose _ = return Nothing | 228 | let lookupClose _ = return Nothing |
227 | (dhtcrypt,onioncrypt,cryptonet) <- toxTransport crypto lookupClose udp | ||
228 | |||
229 | routing <- DHT.newRouting addr crypto updateIP updateIP | 229 | routing <- DHT.newRouting addr crypto updateIP updateIP |
230 | |||
231 | (dhtcrypt,onioncrypt,cryptonet) <- toxTransport crypto (DHT.orouter routing) lookupClose udp | ||
232 | |||
230 | let dhtnet0 = layerTransport (DHT.decrypt crypto) (DHT.encrypt crypto) dhtcrypt | 233 | let dhtnet0 = layerTransport (DHT.decrypt crypto) (DHT.encrypt crypto) dhtcrypt |
231 | dhtclient <- newClient drg dhtnet0 DHT.classify (myAddr routing) (DHT.handlers routing) | 234 | dhtclient <- newClient drg dhtnet0 DHT.classify (myAddr routing) (DHT.handlers routing) id |
232 | $ \client net -> onInbound (DHT.updateRouting client routing) net | 235 | $ \client net -> onInbound (DHT.updateRouting client routing) net |
233 | 236 | ||
234 | toks <- do | 237 | toks <- do |
@@ -242,6 +245,7 @@ newTox keydb addr = do | |||
242 | (flip Onion.OnionDestination Nothing) | 245 | (flip Onion.OnionDestination Nothing) |
243 | $ nodeInfo zeroID addr) | 246 | $ nodeInfo zeroID addr) |
244 | (Onion.handlers onionnet routing toks keydb) | 247 | (Onion.handlers onionnet routing toks keydb) |
248 | (hookQueries (DHT.orouter routing) DHT.transactionKey) | ||
245 | (const id) | 249 | (const id) |
246 | return Tox | 250 | return Tox |
247 | { toxDHT = dhtclient | 251 | { toxDHT = dhtclient |