import Control.Monad import Control.Concurrent import Control.Concurrent.STM import System.Environment import Crypto.Tox import Network.Tox.TCP import Network.QueryResponse import DebugTag import DPut main :: IO () main = do setVerbose XMisc setVerbose XTCP setVerbose XUnexpected crypto <- newCrypto (_,client) <- newClient crypto id (\cb p -> cb (Just (False,p))) quitTCP <- forkListener "TCP-recv" (addHandler print (handleMessage client) $ clientNet client) args <- getArgs let addr = read $ args !! 0 putStrLn $ unlines [ "-------------------------------" , "PING TEST" , "-------------------------------" , "ping " ++ show addr ] r <- tcpPing client (addr :: NodeInfo) print r forM_ (drop 1 args) $ (. read) $ \gw -> do putStrLn $ unlines [ "-------------------------------" , "GetNodes TEST" , "-------------------------------" ] -- getUDPNodes :: TCPClient err () Nonce8 -> NodeId -> UDP.NodeInfo -> IO (Maybe ([UDP.NodeInfo], [UDP.NodeInfo], Maybe ())) let nid = read "OrjBG.GyWuQhGc1pb0KssgmYAocohFh35Vx8mREC9Nu" s <- getUDPNodes (TCPClient crypto client $ \_ -> return $ Just gw) nid (udpNodeInfo addr) print s putStrLn $ unlines [ "-------------------------------" , "quitTCP" , "-------------------------------" ] quitTCP return ()