diff options
-rw-r--r-- | lib/Kiki.hs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/Kiki.hs b/lib/Kiki.hs index c1dd587..2198fb7 100644 --- a/lib/Kiki.hs +++ b/lib/Kiki.hs | |||
@@ -510,14 +510,9 @@ refreshCache rt rootdir = do | |||
510 | let warn' x = warn x >> return Char8.empty | 510 | let warn' x = warn x >> return Char8.empty |
511 | flip (either warn') (pemFromPacket k :: Either String String) $ \pem -> do | 511 | flip (either warn') (pemFromPacket k :: Either String String) $ \pem -> do |
512 | write (mkpath cpath) pem | 512 | write (mkpath cpath) pem |
513 | case take 1 sshs of | 513 | case sshs of |
514 | [sshkey] -> do | 514 | (sshkey:_) -> strongswanForContact addr contactname <$> sshKeyToHostname sshkey |
515 | (_,(sout,serr)) <- runExternal "(f=$(mktemp); cat > \"$f\"; ssh-keygen -l -f \"$f\" | (read _ hash _; echo -n $hash.ssh.cryptonomic.net) | tr -d ':')" | 515 | _ -> error "fuck." |
516 | (Just $ sshblobFromPacket sshkey) | ||
517 | -- ssh-keygen -l -f /dev/stdin | ||
518 | -- putStrLn $ "wtf="++show(sout,serr, sshblobFromPacket sshkey) | ||
519 | return $ strongswanForContact addr contactname (Char8.fromChunks [sout]) | ||
520 | [] -> error "fuck." | ||
521 | return $ Char8.concat bss | 516 | return $ Char8.concat bss |
522 | 517 | ||
523 | known_hosts = L.concat $ map getssh onionkeys | 518 | known_hosts = L.concat $ map getssh onionkeys |
@@ -558,9 +553,18 @@ refreshCache rt rootdir = do | |||
558 | ] ++ filter (not . Char8.null) cons | 553 | ] ++ filter (not . Char8.null) cons |
559 | commit | 554 | commit |
560 | 555 | ||
556 | sshKeyToHostname :: Packet -> IO Char8.ByteString | ||
557 | sshKeyToHostname sshkey = do | ||
558 | (_, (sout, _serr)) <- runExternal shellScript (Just $ sshblobFromPacket sshkey) | ||
559 | return $ Char8.fromChunks [sout] | ||
560 | where | ||
561 | shellScript = | ||
562 | "f=$(mktemp) && cat > \"$f\" && ssh-keygen -r _ -f \"$f\" | (read _ _ _ _ _ hash _ && echo -n $hash.ssh.cryptonomic.net)" | ||
563 | |||
564 | strongswanForContact :: SockAddr -> Char8.ByteString -> Char8.ByteString -> Char8.ByteString | ||
561 | strongswanForContact addr oname rightip = Char8.unlines | 565 | strongswanForContact addr oname rightip = Char8.unlines |
562 | [ "conn " <> oname | 566 | [ "conn " <> oname |
563 | , " right=lan." <> rightip | 567 | , " right=" <> rightip |
564 | , " rightsubnet=" <> p (showA addr) <> "/128" | 568 | , " rightsubnet=" <> p (showA addr) <> "/128" |
565 | , " rightauth=pubkey" | 569 | , " rightauth=pubkey" |
566 | , " rightid=" <> p (showA addr) | 570 | , " rightid=" <> p (showA addr) |