summaryrefslogtreecommitdiff
path: root/Presence
diff options
context:
space:
mode:
Diffstat (limited to 'Presence')
-rw-r--r--Presence/LocalPeerCred.hs11
1 files changed, 8 insertions, 3 deletions
diff --git a/Presence/LocalPeerCred.hs b/Presence/LocalPeerCred.hs
index b6ec9491..0122b5d0 100644
--- a/Presence/LocalPeerCred.hs
+++ b/Presence/LocalPeerCred.hs
@@ -1,3 +1,4 @@
1{-# LANGUAGE ViewPatterns #-}
1module LocalPeerCred where 2module LocalPeerCred where
2 3
3{- for main 4{- for main
@@ -37,18 +38,18 @@ parseHex bs = L.concat . parseHex' $ bs
37 then [] 38 then []
38 else parseHex' ts 39 else parseHex' ts
39 40
40getLocalPeerCred' (SockAddrInet portn host) = do 41getLocalPeerCred' (unmap6mapped4 -> SockAddrInet portn host) = do
41 let port = fromEnum portn 42 let port = fromEnum portn
42 {- trace ("tcp4 "++show(port,host)) $ -} 43 {- trace ("tcp4 "++show(port,host)) $ -}
43 withFile "/proc/net/tcp" ReadMode (parseProcNet port host) 44 withFile "/proc/net/tcp" ReadMode (parseProcNet port host)
44 45
45getLocalPeerCred' (SockAddrInet6 portn flow host scope) = do 46getLocalPeerCred' (unmap6mapped4 -> SockAddrInet6 portn flow host scope) = do
46 let port = fromEnum portn 47 let port = fromEnum portn
47 (a,b,c,d) = host 48 (a,b,c,d) = host
48 host' = (toBE32 a, toBE32 b, toBE32 c, toBE32 d) 49 host' = (toBE32 a, toBE32 b, toBE32 c, toBE32 d)
49 withFile "/proc/net/tcp6" ReadMode (parseProcNet port host') 50 withFile "/proc/net/tcp6" ReadMode (parseProcNet port host')
50 51
51getLocalPeerCred' addr@(SockAddrUnix _) = 52getLocalPeerCred' (unmap6mapped4 -> addr@(SockAddrUnix _)) =
52 -- TODO: parse /proc/net/unix 53 -- TODO: parse /proc/net/unix
53 -- see also: Network.Socket.getPeerCred 54 -- see also: Network.Socket.getPeerCred
54 return Nothing 55 return Nothing
@@ -109,3 +110,7 @@ main = do
109 r <- getLocalPeerCred' addr 110 r <- getLocalPeerCred' addr
110 putStrLn $ "r{"++show addr++"} = " ++ show r 111 putStrLn $ "r{"++show addr++"} = " ++ show r
111-} 112-}
113
114-- PEER NAME: [::ffff:127.0.0.1]:34307
115unmap6mapped4 addr@(SockAddrInet6 port _ (0,0,0xFFFF,a) _) = SockAddrInet port (toBE32 a)
116unmap6mapped4 addr = addr