diff options
author | joe <joe@jerkface.net> | 2017-01-25 20:48:00 -0500 |
---|---|---|
committer | joe <joe@jerkface.net> | 2017-01-25 20:48:00 -0500 |
commit | b3cebbedeb89fdd6b85c659360241b9251a8f1ae (patch) | |
tree | 0d9b6907ed684f1e7e5d590bbf3f068229aec8c6 | |
parent | af87d80ebe4cf46a1aeb0a9421708ea52d09000b (diff) |
Safer exception handling in probeNode.
-rw-r--r-- | src/Network/BitTorrent/DHT/Query.hs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/Network/BitTorrent/DHT/Query.hs b/src/Network/BitTorrent/DHT/Query.hs index e0338572..8215c95d 100644 --- a/src/Network/BitTorrent/DHT/Query.hs +++ b/src/Network/BitTorrent/DHT/Query.hs | |||
@@ -75,6 +75,7 @@ import Data.Time.Clock.POSIX | |||
75 | 75 | ||
76 | import Network.KRPC hiding (Options, def) | 76 | import Network.KRPC hiding (Options, def) |
77 | import Network.KRPC.Message (ReflectedIP(..)) | 77 | import Network.KRPC.Message (ReflectedIP(..)) |
78 | import Network.KRPC.Manager (QueryFailure(..)) | ||
78 | import Data.Torrent | 79 | import Data.Torrent |
79 | import Network.BitTorrent.Address | 80 | import Network.BitTorrent.Address |
80 | import Network.BitTorrent.DHT.Message | 81 | import Network.BitTorrent.DHT.Message |
@@ -206,7 +207,7 @@ probeNode :: Address ip => NodeAddr ip -> DHT ip (Bool, Maybe ReflectedIP) | |||
206 | probeNode addr = do | 207 | probeNode addr = do |
207 | $(logDebugS) "routing.questionable_node" (T.pack (render (pPrint addr))) | 208 | $(logDebugS) "routing.questionable_node" (T.pack (render (pPrint addr))) |
208 | result <- try $ pingQ addr | 209 | result <- try $ pingQ addr |
209 | let _ = fmap (const ()) result :: Either SomeException () | 210 | let _ = fmap (const ()) result :: Either QueryFailure () |
210 | return $ either (const (False,Nothing)) (\(_,mip)->(True,mip)) result | 211 | return $ either (const (False,Nothing)) (\(_,mip)->(True,mip)) result |
211 | 212 | ||
212 | 213 | ||