forked from schmittlauch/Hash2Pub
33 lines
1 KiB
Haskell
33 lines
1 KiB
Haskell
module Main where
|
|
|
|
import Control.Concurrent
|
|
import Data.IP (IPv6, toHostAddress6)
|
|
import System.Environment
|
|
|
|
import Hash2Pub.FediChord
|
|
|
|
main :: IO ()
|
|
main = do
|
|
-- ToDo: parse and pass config
|
|
-- probably use `tomland` for that
|
|
conf <- readConfig
|
|
-- ToDo: load persisted caches, bootstrapping nodes …
|
|
(serverSock, thisNode) <- fediChordInit conf
|
|
print thisNode
|
|
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
|
|
}
|