From 51068952db8fa263f576e49ee7d2ce1dcc89898a Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Thu, 27 Feb 2014 15:56:57 +0400 Subject: Check uri scheme before making RPC --- src/Network/BitTorrent/Tracker/RPC/UDP.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/Network') diff --git a/src/Network/BitTorrent/Tracker/RPC/UDP.hs b/src/Network/BitTorrent/Tracker/RPC/UDP.hs index 160397dd..0cb8e95e 100644 --- a/src/Network/BitTorrent/Tracker/RPC/UDP.hs +++ b/src/Network/BitTorrent/Tracker/RPC/UDP.hs @@ -212,6 +212,9 @@ data RpcException -- | Unable to lookup hostname; | HostLookupFailed + -- | Expecting 'udp:', but some other scheme provided. + | UnrecognizedScheme String + -- | Tracker exists but not responding for specific number of seconds. | TimeoutExpired Int @@ -250,7 +253,9 @@ resolveURI _ = throwIO HostUnknown -- TODO caching? getTrackerAddr :: Manager -> URI -> IO SockAddr -getTrackerAddr _ = resolveURI +getTrackerAddr _ uri + | uriScheme uri == "udp:" = resolveURI uri + | otherwise = throwIO (UnrecognizedScheme (uriScheme uri)) {----------------------------------------------------------------------- Tokens -- cgit v1.2.3