2020-12-29 20:50:33 +00:00
|
|
|
{-# LANGUAGE DuplicateRecordFields #-}
|
2022-08-02 12:30:00 +00:00
|
|
|
{-# LANGUAGE NumericUnderscores #-}
|
2021-05-06 17:53:34 +00:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
2021-05-17 21:33:12 +00:00
|
|
|
{-# LANGUAGE TypeApplications #-}
|
2020-12-29 20:50:33 +00:00
|
|
|
|
2020-12-25 16:46:02 +00:00
|
|
|
module Main where
|
|
|
|
|
2021-01-22 08:59:47 +00:00
|
|
|
import Control.Logger.Simple
|
2021-05-06 17:53:34 +00:00
|
|
|
import qualified Data.List.NonEmpty as L
|
2020-12-26 13:01:57 +00:00
|
|
|
import Simplex.Messaging.Agent.Env.SQLite
|
2022-01-21 17:33:47 +00:00
|
|
|
import Simplex.Messaging.Agent.Server (runSMPAgent)
|
2022-08-02 12:30:00 +00:00
|
|
|
import Simplex.Messaging.Client (defaultNetworkConfig)
|
2021-12-15 07:48:57 +00:00
|
|
|
import Simplex.Messaging.Transport (TLS, Transport (..))
|
2020-12-25 16:46:02 +00:00
|
|
|
|
|
|
|
cfg :: AgentConfig
|
2022-04-08 07:47:04 +00:00
|
|
|
cfg = defaultAgentConfig
|
|
|
|
|
|
|
|
servers :: InitialAgentServers
|
|
|
|
servers =
|
|
|
|
InitialAgentServers
|
|
|
|
{ smp = L.fromList ["smp://bU0K-bRg24xWW__lS0umO1Zdw_SXqpJNtm1_RrPLViE=@localhost:5223"],
|
2022-07-23 12:57:10 +00:00
|
|
|
ntf = [],
|
2022-08-02 12:30:00 +00:00
|
|
|
netCfg = defaultNetworkConfig
|
2022-04-08 07:47:04 +00:00
|
|
|
}
|
2020-12-25 16:46:02 +00:00
|
|
|
|
2021-01-22 08:59:47 +00:00
|
|
|
logCfg :: LogConfig
|
|
|
|
logCfg = LogConfig {lc_file = Nothing, lc_stderr = True}
|
|
|
|
|
2020-12-25 16:46:02 +00:00
|
|
|
main :: IO ()
|
|
|
|
main = do
|
2020-12-29 20:50:33 +00:00
|
|
|
putStrLn $ "SMP agent listening on port " ++ tcpPort (cfg :: AgentConfig)
|
2021-01-22 08:59:47 +00:00
|
|
|
setLogLevel LogInfo -- LogError
|
2022-04-08 07:47:04 +00:00
|
|
|
withGlobalLogging logCfg $ runSMPAgent (transport @TLS) cfg servers
|