blob: d168b1fb5ddb9c229aec3c81b393210327812fa1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
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 ()
|