diff options
Diffstat (limited to 'dht/src/Data/Tox/DHT/Multi.hs')
-rw-r--r-- | dht/src/Data/Tox/DHT/Multi.hs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/dht/src/Data/Tox/DHT/Multi.hs b/dht/src/Data/Tox/DHT/Multi.hs index d31ae4b8..878b47e6 100644 --- a/dht/src/Data/Tox/DHT/Multi.hs +++ b/dht/src/Data/Tox/DHT/Multi.hs | |||
@@ -13,7 +13,7 @@ import qualified Network.Tox.NodeId as UDP | |||
13 | import qualified Network.Tox.TCP.NodeId as TCP | 13 | import qualified Network.Tox.TCP.NodeId as TCP |
14 | import Data.Tox.Onion (OnionDestination,RouteId) | 14 | import Data.Tox.Onion (OnionDestination,RouteId) |
15 | import Data.Tox.Relay hiding (NodeInfo) | 15 | import Data.Tox.Relay hiding (NodeInfo) |
16 | import Network.Address (either4or6) | 16 | import Network.Address as SockAddr (canonize) |
17 | import Network.Tox.TCP as TCP (ViaRelay(..), tcpConnectionRequest_) | 17 | import Network.Tox.TCP as TCP (ViaRelay(..), tcpConnectionRequest_) |
18 | import Network.QueryResponse as QR (Tagged(..), Client) | 18 | import Network.QueryResponse as QR (Tagged(..), Client) |
19 | 19 | ||
@@ -88,7 +88,7 @@ untagOnion (OnionTCP :=> Identity o) = o | |||
88 | 88 | ||
89 | -- Canonical in case of 6-mapped-4 addresses. | 89 | -- Canonical in case of 6-mapped-4 addresses. |
90 | canonize :: DSum S Identity -> DSum S Identity | 90 | canonize :: DSum S Identity -> DSum S Identity |
91 | canonize (SessionUDP :=> Identity saddr) = SessionUDP ==> either id id (either4or6 saddr) | 91 | canonize (SessionUDP :=> Identity saddr) = SessionUDP ==> SockAddr.canonize saddr |
92 | canonize taddr = taddr | 92 | canonize taddr = taddr |
93 | 93 | ||
94 | type NodeInfo = DSum T Identity | 94 | type NodeInfo = DSum T Identity |
@@ -144,3 +144,9 @@ tcpConnectionRequest :: QR.Client err PacketNumber tid TCP.NodeInfo (Bool, Relay | |||
144 | tcpConnectionRequest client pubkey ni = do | 144 | tcpConnectionRequest client pubkey ni = do |
145 | mcon <- tcpConnectionRequest_ client pubkey ni | 145 | mcon <- tcpConnectionRequest_ client pubkey ni |
146 | return $ fmap (\conid -> TCP ==> ViaRelay (Just conid) (UDP.key2id pubkey) ni) mcon | 146 | return $ fmap (\conid -> TCP ==> ViaRelay (Just conid) (UDP.key2id pubkey) ni) mcon |
147 | |||
148 | showSessionAddr :: SessionAddress -> String | ||
149 | showSessionAddr (SessionUDP :=> Identity udp) = | ||
150 | show (SockAddr.canonize udp) | ||
151 | showSessionAddr (SessionTCP :=> Identity (ViaRelay mcon _ tcp)) = | ||
152 | "TCP:" ++ maybe "" (\(ConId con) -> "(" ++ show con ++ ")") mcon ++ show tcp | ||