blob: ce681cb582114efab021dde0afe5bfcc4262e534 (
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
|
import System.Posix.Signals
import Control.Concurrent.STM
import Control.Monad.Trans.Resource (runResourceT)
import Control.Monad.IO.Class (MonadIO, liftIO)
import Network.Socket
( addrAddress
, getAddrInfo
, defaultHints
, addrFlags
, AddrInfoFlag(AI_CANONNAME)
)
import XMPPServer
import Server
main = runResourceT $ do
(sv,peer_params) <- xmppServer
liftIO $ do
let testaddr0 = "fd97:ca88:fa7c:b94b:c8b8:fad4:1021:a54d"
-- testaddr0 = "fdef:9e0b:b502:52c3:c074:28d3:fcd7:bfb7"
testaddr<- fmap (addrAddress . head) $
getAddrInfo (Just $ defaultHints { addrFlags = [ AI_CANONNAME ]})
(Just testaddr0)
(Just "5269")
putStrLn $ "Connecting to "++show testaddr
control sv (ConnectWithEndlessRetry testaddr peer_params 10000)
quitVar <- newEmptyTMVarIO
installHandler sigTERM (CatchOnce (atomically $ putTMVar quitVar True)) Nothing
installHandler sigINT (CatchOnce (atomically $ putTMVar quitVar True)) Nothing
quitMessage <- atomically $ takeTMVar quitVar
putStrLn "goodbye."
return ()
|