diff options
-rw-r--r-- | Presence/LocalPeerCred.hs | 11 | ||||
-rw-r--r-- | whosocket.hs | 3 |
2 files changed, 8 insertions, 6 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 #-} | ||
1 | module LocalPeerCred where | 2 | module 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 | ||
40 | getLocalPeerCred' (SockAddrInet portn host) = do | 41 | getLocalPeerCred' (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 | ||
45 | getLocalPeerCred' (SockAddrInet6 portn flow host scope) = do | 46 | getLocalPeerCred' (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 | ||
51 | getLocalPeerCred' addr@(SockAddrUnix _) = | 52 | getLocalPeerCred' (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 | ||
115 | unmap6mapped4 addr@(SockAddrInet6 port _ (0,0,0xFFFF,a) _) = SockAddrInet port (toBE32 a) | ||
116 | unmap6mapped4 addr = addr | ||
diff --git a/whosocket.hs b/whosocket.hs index 7fd44b4d..14d2a708 100644 --- a/whosocket.hs +++ b/whosocket.hs | |||
@@ -157,6 +157,3 @@ identifyTTY tty_pids uid inode = do | |||
157 | return tty' | 157 | return tty' |
158 | 158 | ||
159 | 159 | ||
160 | -- PEER NAME: [::ffff:127.0.0.1]:34307 | ||
161 | unmap6mapped4 addr@(SockAddrInet6 port _ (0,0,0xFFFF,a) _) = SockAddrInet port (toBE32 a) | ||
162 | unmap6mapped4 addr = addr | ||