summaryrefslogtreecommitdiff
path: root/lib/KeyRing/BuildKeyDB.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/KeyRing/BuildKeyDB.hs')
-rw-r--r--lib/KeyRing/BuildKeyDB.hs16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/KeyRing/BuildKeyDB.hs b/lib/KeyRing/BuildKeyDB.hs
index 587d812..3fe1d17 100644
--- a/lib/KeyRing/BuildKeyDB.hs
+++ b/lib/KeyRing/BuildKeyDB.hs
@@ -2,6 +2,7 @@
2{-# LANGUAGE DoAndIfThenElse #-} 2{-# LANGUAGE DoAndIfThenElse #-}
3{-# LANGUAGE ForeignFunctionInterface #-} 3{-# LANGUAGE ForeignFunctionInterface #-}
4{-# LANGUAGE LambdaCase #-} 4{-# LANGUAGE LambdaCase #-}
5{-# LANGUAGE NamedFieldPuns #-}
5{-# LANGUAGE OverloadedStrings #-} 6{-# LANGUAGE OverloadedStrings #-}
6{-# LANGUAGE PatternGuards #-} 7{-# LANGUAGE PatternGuards #-}
7{-# LANGUAGE TupleSections #-} 8{-# LANGUAGE TupleSections #-}
@@ -550,10 +551,7 @@ mergeHostFiles krd db ctx = do
550 hostdbs0 <- mapM (fmap Hosts.decode . readInputFileL' ctx) hns 551 hostdbs0 <- mapM (fmap Hosts.decode . readInputFileL' ctx) hns
551 552
552 let gpgnames = map getHostnames $ keyData db 553 let gpgnames = map getHostnames $ keyData db
553 os = do 554 os = concat $ allNames' <$> gpgnames
554 Hostnames addr ns _ _ <- gpgnames
555 n <- ns
556 return (addr,n)
557 setOnions hosts = foldl' (flip $ uncurry Hosts.assignName) hosts os 555 setOnions hosts = foldl' (flip $ uncurry Hosts.assignName) hosts os
558 -- we ensure .onion names are set properly 556 -- we ensure .onion names are set properly
559 hostdbs = map setOnions hostdbs0 557 hostdbs = map setOnions hostdbs0
@@ -864,6 +862,12 @@ generateSubkey transcode kd' (genparam,StreamInfo { spill = KF_Match tag }) = do
864 return $ KikiSuccess (kd,report0) 862 return $ KikiSuccess (kd,report0)
865generateSubkey _ kd _ = return kd 863generateSubkey _ kd _ = return kd
866 864
865allNames :: Hostnames -> [Char8.ByteString]
866allNames (Hostnames _ ns os cs) = ns ++ os ++ (maybe [] return cs)
867
868allNames' :: Hostnames -> [(SockAddr, Char8.ByteString)]
869allNames' h@Hostnames{gpgipv6addr} = (gpgipv6addr,) <$> allNames h
870
867data Hostnames = Hostnames { 871data Hostnames = Hostnames {
868 gpgipv6addr :: SockAddr, 872 gpgipv6addr :: SockAddr,
869 verifiedOnionNames :: [L.ByteString], 873 verifiedOnionNames :: [L.ByteString],
@@ -915,7 +919,7 @@ setHostnames (IPsToWriteToHostsFile outgoing_names) hosts kd@(KeyData topmp tops
915 -- when we should be removing origins from the locations 919 -- when we should be removing origins from the locations
916 -- field of the sig's MappedPacket records. 920 -- field of the sig's MappedPacket records.
917 -- Call getHostnames and compare to see if no-op. 921 -- Call getHostnames and compare to see if no-op.
918 if pred || pred2 922 if (addr `elem` outgoing_names) || (gotNonOnions == namesWithoutGotOnions)
919 then {- trace (unlines [ "setHostnames NO-OP: gpg: "++show (map Char8.unpack onions, map Char8.unpack names0) 923 then {- trace (unlines [ "setHostnames NO-OP: gpg: "++show (map Char8.unpack onions, map Char8.unpack names0)
920 , " file: "++show (map Char8.unpack names) 924 , " file: "++show (map Char8.unpack names)
921 , " pred: "++show (pred addr)]) -} 925 , " pred: "++show (pred addr)]) -}
@@ -931,11 +935,9 @@ setHostnames (IPsToWriteToHostsFile outgoing_names) hosts kd@(KeyData topmp tops
931 -} 935 -}
932 return $ KeyData topmp topsigs uids1 subs 936 return $ KeyData topmp topsigs uids1 subs
933 where 937 where
934 pred = addr `elem` outgoing_names
935 addr = fingerdress $ packet topmp 938 addr = fingerdress $ packet topmp
936 names :: [Char8.ByteString] 939 names :: [Char8.ByteString]
937 names = Hosts.namesForAddress addr hosts 940 names = Hosts.namesForAddress addr hosts
938 pred2 = gotNonOnions == namesWithoutGotOnions
939 941
940 Hostnames _ gotOnions gotNonOnions cryptonomic = getHostnames kd 942 Hostnames _ gotOnions gotNonOnions cryptonomic = getHostnames kd
941 943