diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2024-10-21 19:55:04 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2024-10-21 20:26:01 +0200 |
commit | 3330135a2f0c400b45d4ef6bc30c76be40a4cb74 (patch) | |
tree | 62304c4d3e0c8e26769fec15fed50cea20d74799 | |
parent | e9320de63391bfca221ea7ae46a0b40bf9b992b0 (diff) |
Try resolving multiple public servers
Changelog: Support multiple public peers
-rw-r--r-- | main/Main.hs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/main/Main.hs b/main/Main.hs index 94c0418..32c226f 100644 --- a/main/Main.hs +++ b/main/Main.hs @@ -540,8 +540,19 @@ cmdPeerAdd = void $ do cmdPeerAddPublic :: Command cmdPeerAddPublic = do server <- asks ciServer - addr:_ <- liftIO $ getAddrInfo (Just $ defaultHints { addrSocketType = Datagram }) (Just "discovery1.erebosprotocol.net") (Just (show discoveryPort)) - void $ liftIO $ serverPeer server (addrAddress addr) + liftIO $ mapM_ (serverPeer server . addrAddress) =<< gather 'a' + where + gather c + | c <= 'z' = do + let hints = Just $ defaultHints { addrSocketType = Datagram } + hostname = Just $ c : ".discovery.erebosprotocol.net" + service = Just $ show discoveryPort + handle (\(_ :: IOException) -> return []) (getAddrInfo hints hostname service) >>= \case + addr : _ -> (addr :) <$> gather (succ c) + [] -> return [] + + | otherwise = do + return [] cmdPeerDrop :: Command cmdPeerDrop = do |