diff options
author | joe <joe@jerkface.net> | 2017-11-13 17:45:03 -0500 |
---|---|---|
committer | joe <joe@jerkface.net> | 2017-11-13 17:45:03 -0500 |
commit | ac35b0b19f74ffa4c4176f8b54b7d60ce2442391 (patch) | |
tree | b0cefd4b4ffd45b71dbc4097c9948b5b03927a39 /Presence/LocalPeerCred.hs | |
parent | 4d25010f0eaf06dc7c909c17f2a6ae85d29879c3 (diff) |
Replaced dependency (binary -> cereal) in LocalPeerCred.
Diffstat (limited to 'Presence/LocalPeerCred.hs')
-rw-r--r-- | Presence/LocalPeerCred.hs | 14 |
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 | |||
13 | import Control.Arrow (first) | 13 | import Control.Arrow (first) |
14 | import Data.Char | 14 | import Data.Char |
15 | import Data.Maybe | 15 | import Data.Maybe |
16 | import Data.Binary | ||
17 | import Data.Bits | 16 | import Data.Bits |
17 | import Data.Serialize | ||
18 | import Data.Word | ||
18 | import System.Posix.Types | 19 | import System.Posix.Types |
19 | import System.Posix.Files | 20 | import System.Posix.Files |
20 | import Logging | 21 | import Logging |
@@ -78,7 +79,7 @@ from16 = fromEnum | |||
78 | as16 :: Word16 -> Word16 | 79 | as16 :: Word16 -> Word16 |
79 | as16 = id | 80 | as16 = id |
80 | 81 | ||
81 | parseProcNet :: (Binary t, Num t1, Eq t, Eq t1) => | 82 | parseProcNet :: (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 |