diff options
Diffstat (limited to 'src/Network/UPNP.hs')
-rw-r--r-- | src/Network/UPNP.hs | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/src/Network/UPNP.hs b/src/Network/UPNP.hs deleted file mode 100644 index 01d222bf..00000000 --- a/src/Network/UPNP.hs +++ /dev/null | |||
@@ -1,40 +0,0 @@ | |||
1 | module Network.UPNP where | ||
2 | |||
3 | import Data.Maybe | ||
4 | import Network.Address (sockAddrPort) | ||
5 | import Network.Socket | ||
6 | import System.Directory | ||
7 | import System.Process as Process | ||
8 | import DPut | ||
9 | import DebugTag | ||
10 | |||
11 | protocols :: SocketType -> [String] | ||
12 | protocols Stream = ["tcp"] | ||
13 | protocols Datagram = ["udp"] | ||
14 | protocols _ = ["udp","tcp"] | ||
15 | |||
16 | upnpc :: FilePath | ||
17 | upnpc = "/usr/bin/upnpc" | ||
18 | |||
19 | -- | Invokes the miniupnpc command line program to request ports from a UPNP | ||
20 | -- wifi router. Returns the process handle on success. | ||
21 | requestPorts :: String -- ^ Description stored on router. | ||
22 | -> [(SocketType, SockAddr)] -- ^ Protocol-port pairs to request. | ||
23 | -> IO (Maybe ProcessHandle) | ||
24 | requestPorts description binds = do | ||
25 | let requests = do | ||
26 | (stype,saddr) <- binds | ||
27 | proto <- protocols stype | ||
28 | port <- maybeToList (sockAddrPort saddr) | ||
29 | [ show port, proto ] | ||
30 | bail = return Nothing | ||
31 | case requests of | ||
32 | [] -> bail | ||
33 | _ -> do | ||
34 | gotMiniUPNPC <- doesFileExist upnpc | ||
35 | if gotMiniUPNPC then do | ||
36 | phandle <- spawnProcess upnpc $ "-e": description : "-r" : requests | ||
37 | return $ Just phandle | ||
38 | else do | ||
39 | dput XMisc $ "Warning: unable to find miniupnpc client at "++upnpc++"." | ||
40 | bail | ||