Hash2Pub/app/Main.hs

33 lines
1 KiB
Haskell
Raw Normal View History

2020-03-20 19:01:25 +01:00
module Main where
import Control.Concurrent
import Data.IP (IPv6, toHostAddress6)
import System.Environment
import Hash2Pub.FediChord
2020-03-20 19:01:25 +01:00
main :: IO ()
main = do
-- ToDo: parse and pass config
-- probably use `tomland` for that
conf <- readConfig
-- ToDo: load persisted caches, bootstrapping nodes …
2020-05-12 21:24:56 +02:00
(serverSock, thisNode) <- fediChordInit conf
print thisNode
2020-05-12 21:24:56 +02:00
print serverSock
-- currently no masking is necessary, as there is nothing to clean up
cacheWriterThread <- forkIO $ cacheWriter thisNode
-- idea: list of bootstrapping nodes, try joining within a timeout
-- stop main thread from terminating during development
getChar
pure ()
readConfig :: IO FediChordConf
readConfig = do
confDomainString : ipString : portString : _ <- getArgs
pure $ FediChordConf {
confDomain = confDomainString
, confIP = toHostAddress6 . read $ ipString
, confDhtPort = read portString
}