From 0efeea061f1aaad7ee60162f0502c4e445489d3b Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Sun, 7 Jul 2019 16:32:56 -0400 Subject: trying to clarify setHostnames --- lib/KeyRing/BuildKeyDB.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/KeyRing/BuildKeyDB.hs b/lib/KeyRing/BuildKeyDB.hs index f90f638..6e62e70 100644 --- a/lib/KeyRing/BuildKeyDB.hs +++ b/lib/KeyRing/BuildKeyDB.hs @@ -617,7 +617,7 @@ mergeHostFiles krd db ctx = do -- 2. replace gpg annotations with those in U -- forM use_db - db' <- Traversable.mapM (setHostnames (`notElem` outgoing_names) u1) db + db' <- Traversable.mapM (setHostnames outgoing_names u1) db return $ KikiSuccess ((db',(hostdbs0,hostdbs,u1,gpgnames,outgoing_names)),[]) @@ -947,13 +947,13 @@ hasFingerDress db addr = pre=="fd" && isJust (selectPublicKey (KeyGrip g',Nothin g' = map toUpper g -- We return into IO in case we want to make a signature here. -setHostnames :: (SockAddr -> Bool) -> Hosts.Hosts -> KeyData -> IO KeyData -setHostnames pred hosts kd@(KeyData topmp topsigs uids subs) = +setHostnames :: [SockAddr] -> Hosts.Hosts -> KeyData -> IO KeyData +setHostnames outgoing_names hosts kd@(KeyData topmp topsigs uids subs) = -- TODO: we are removing the origin from the UID OriginMap, -- when we should be removing origins from the locations -- field of the sig's MappedPacket records. -- Call getHostnames and compare to see if no-op. - if not (pred addr) || gotNonOnions == namesWithoutGotOnions + if pred || pred2 then {- trace (unlines [ "setHostnames NO-OP: gpg: "++show (map Char8.unpack onions, map Char8.unpack names0) , " file: "++show (map Char8.unpack names) , " pred: "++show (pred addr)]) -} @@ -969,10 +969,12 @@ setHostnames pred hosts kd@(KeyData topmp topsigs uids subs) = -} return $ KeyData topmp topsigs uids1 subs where + pred = addr `elem` outgoing_names topk = packet topmp addr = fingerdress topk names :: [Char8.ByteString] names = Hosts.namesForAddress addr hosts + pred2 = gotNonOnions == namesWithoutGotOnions Hostnames _ gotOnions gotNonOnions cryptonomic = getHostnames kd -- cgit v1.2.3