summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2017-11-13 17:45:03 -0500
committerjoe <joe@jerkface.net>2017-11-13 17:45:03 -0500
commitac35b0b19f74ffa4c4176f8b54b7d60ce2442391 (patch)
treeb0cefd4b4ffd45b71dbc4097c9948b5b03927a39
parent4d25010f0eaf06dc7c909c17f2a6ae85d29879c3 (diff)
Replaced dependency (binary -> cereal) in LocalPeerCred.
-rw-r--r--Presence/LocalPeerCred.hs14
1 files changed, 9 insertions, 5 deletions
diff --git a/Presence/LocalPeerCred.hs b/Presence/LocalPeerCred.hs
index c73c39df..9054f180 100644
--- a/Presence/LocalPeerCred.hs
+++ b/Presence/LocalPeerCred.hs
@@ -13,8 +13,9 @@ import System.Directory
13import Control.Arrow (first) 13import Control.Arrow (first)
14import Data.Char 14import Data.Char
15import Data.Maybe 15import Data.Maybe
16import Data.Binary
17import Data.Bits 16import Data.Bits
17import Data.Serialize
18import Data.Word
18import System.Posix.Types 19import System.Posix.Types
19import System.Posix.Files 20import System.Posix.Files
20import Logging 21import Logging
@@ -78,7 +79,7 @@ from16 = fromEnum
78as16 :: Word16 -> Word16 79as16 :: Word16 -> Word16
79as16 = id 80as16 = id
80 81
81parseProcNet :: (Binary t, Num t1, Eq t, Eq t1) => 82parseProcNet :: (Serialize t, Num t1, Eq t, Eq t1) =>
82 t1 83 t1
83 -> t 84 -> t
84 -> Handle 85 -> Handle
@@ -93,13 +94,16 @@ parseProcNet port host h = do
93 localaddr <- listToMaybe ys 94 localaddr <- listToMaybe ys
94 let zs = L.splitWith (==':') localaddr 95 let zs = L.splitWith (==':') localaddr
95 addr <- fmap parseHex $ listToMaybe zs 96 addr <- fmap parseHex $ listToMaybe zs
96 port <- fmap (fromIntegral . as16 . decode . parseHex) $ listToMaybe $ snd (Prelude.splitAt 1 zs) 97 port <- either (const Nothing) (Just . fromIntegral . as16) . decode . L.toStrict . parseHex
98 =<< listToMaybe (snd (Prelude.splitAt 1 zs))
97 let ys' = snd (Prelude.splitAt 5 (tail ys)) 99 let ys' = snd (Prelude.splitAt 5 (tail ys))
98 ys'' = snd (Prelude.splitAt 2 ys') 100 ys'' = snd (Prelude.splitAt 2 ys')
99 uid <- listToMaybe ys' 101 uid <- listToMaybe ys'
100 inode <- listToMaybe ys'' 102 inode <- listToMaybe ys''
101 let peer = (port,decode addr) 103 peer <- either (const Nothing) Just $ do
102 user = toEnum (read (L.unpack uid) ::Int) ::UserID -- CUid . fromIntegral $ (read (unpack uid)::Int) 104 a <- decode $ L.toStrict addr
105 return (port,a)
106 let user = toEnum (read (L.unpack uid) ::Int) ::UserID -- CUid . fromIntegral $ (read (unpack uid)::Int)
103 return $ {-trace ("peer:"++show(peer,user,inode))-} (peer,(user,inode)) 107 return $ {-trace ("peer:"++show(peer,user,inode))-} (peer,(user,inode))
104 ) 108 )
105 fmap snd . listToMaybe $ filter ((==(port,host)).fst) rs 109 fmap snd . listToMaybe $ filter ((==(port,host)).fst) rs