summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2020-01-03 15:35:23 -0500
committerJoe Crayne <joe@jerkface.net>2020-01-03 17:26:06 -0500
commit31b799222cb76cd0002d9a3cc5b340a7b6fed139 (patch)
tree8b834e455529fb270375e4967d1acad56553544f
parent1e03ed3670a8386ede93a09fa0c67785e7da6478 (diff)
server library.
-rw-r--r--cabal.project1
-rw-r--r--dht/dht-client.cabal20
-rw-r--r--dht/stack.yaml1
-rw-r--r--lifted-concurrent/lifted-concurrent.cabal3
-rw-r--r--lifted-concurrent/src/Control/Concurrent/ThreadUtil.hs (renamed from dht/src/Control/Concurrent/ThreadUtil.hs)0
-rw-r--r--lifted-concurrent/src/DebugUtil.hs (renamed from dht/src/DebugUtil.hs)1
-rw-r--r--server/server.cabal25
-rw-r--r--server/src/Connection.hs (renamed from dht/Connection.hs)0
-rw-r--r--server/src/Connection/Tcp.hs (renamed from dht/Connection/Tcp.hs)17
-rw-r--r--server/src/Control/Concurrent/Delay.hs (renamed from dht/src/Control/Concurrent/Delay.hs)1
-rw-r--r--server/src/Control/Concurrent/PingMachine.hs (renamed from dht/src/Control/Concurrent/PingMachine.hs)6
-rw-r--r--server/src/ControlMaybe.hs (renamed from dht/Presence/ControlMaybe.hs)0
-rw-r--r--server/src/DNSCache.hs (renamed from dht/Presence/DNSCache.hs)7
-rw-r--r--server/src/Data/TableMethods.hs (renamed from dht/src/Data/TableMethods.hs)0
-rw-r--r--server/src/DebugTag.hs24
-rw-r--r--server/src/ForkLabeled.hs16
-rw-r--r--server/src/GetHostByAddr.hs (renamed from dht/Presence/GetHostByAddr.hs)1
-rw-r--r--server/src/Network/QueryResponse.hs (renamed from dht/src/Network/QueryResponse.hs)0
-rw-r--r--server/src/Network/QueryResponse/TCP.hs (renamed from dht/src/Network/QueryResponse/TCP.hs)4
-rw-r--r--server/src/Network/SocketLike.hs (renamed from dht/src/Network/SocketLike.hs)0
-rw-r--r--server/src/Network/StreamServer.hs (renamed from dht/src/Network/StreamServer.hs)0
-rw-r--r--server/src/SockAddr.hs (renamed from dht/Presence/SockAddr.hs)0
22 files changed, 97 insertions, 30 deletions
diff --git a/cabal.project b/cabal.project
index 52755c6a..12f0fd90 100644
--- a/cabal.project
+++ b/cabal.project
@@ -11,6 +11,7 @@ packages:
11 kad/ 11 kad/
12 torrent-types/ 12 torrent-types/
13 dput-hslogger/ 13 dput-hslogger/
14 server/
14 bencoding/ 15 bencoding/
15 concurrent-supply/ 16 concurrent-supply/
16 base32-bytestring/ 17 base32-bytestring/
diff --git a/dht/dht-client.cabal b/dht/dht-client.cabal
index 64d48f53..0da181df 100644
--- a/dht/dht-client.cabal
+++ b/dht/dht-client.cabal
@@ -75,15 +75,10 @@ library
75 , RecordWildCards 75 , RecordWildCards
76 , NondecreasingIndentation 76 , NondecreasingIndentation
77 hs-source-dirs: src, ., Presence 77 hs-source-dirs: src, ., Presence
78 exposed-modules: Control.Concurrent.ThreadUtil 78 exposed-modules: Data.Digest.CRC32C
79 Network.SocketLike
80 Data.Digest.CRC32C
81 Data.Bits.ByteString 79 Data.Bits.ByteString
82 Data.TableMethods
83 Network.BitTorrent.DHT.ContactInfo 80 Network.BitTorrent.DHT.ContactInfo
84 Network.BitTorrent.DHT.Token 81 Network.BitTorrent.DHT.Token
85 Network.QueryResponse
86 Network.StreamServer
87 Data.BEncode.Pretty 82 Data.BEncode.Pretty
88 Network.BitTorrent.MainlineDHT 83 Network.BitTorrent.MainlineDHT
89 Network.BitTorrent.MainlineDHT.Symbols 84 Network.BitTorrent.MainlineDHT.Symbols
@@ -107,7 +102,6 @@ library
107 Network.Tox.Avahi 102 Network.Tox.Avahi
108 Network.Tox.RelayPinger 103 Network.Tox.RelayPinger
109 Network.UPNP 104 Network.UPNP
110 Network.QueryResponse.TCP
111 Network.Tox.Relay 105 Network.Tox.Relay
112 Network.Tox.TCP 106 Network.Tox.TCP
113 Data.Tox.Msg 107 Data.Tox.Msg
@@ -117,7 +111,6 @@ library
117 Network.Tox.ContactInfo 111 Network.Tox.ContactInfo
118 Announcer 112 Announcer
119 Announcer.Tox 113 Announcer.Tox
120 Control.Concurrent.Delay
121 ByteStringOperators 114 ByteStringOperators
122 ClientState 115 ClientState
123 ConfigFiles 116 ConfigFiles
@@ -126,19 +119,14 @@ library
126 Control.Concurrent.STM.StatusCache 119 Control.Concurrent.STM.StatusCache
127 Control.Concurrent.STM.UpdateStream 120 Control.Concurrent.STM.UpdateStream
128 Control.Concurrent.STM.Util 121 Control.Concurrent.STM.Util
129 ControlMaybe
130 Data.BitSyntax 122 Data.BitSyntax
131 DNSCache
132 EventUtil 123 EventUtil
133 FGConsole 124 FGConsole
134 GetHostByAddr
135 LocalPeerCred 125 LocalPeerCred
136 LockedChan 126 LockedChan
137 Logging 127 Logging
138 Nesting 128 Nesting
139 Paths 129 Paths
140 Connection.Tcp
141 SockAddr
142 UTmp 130 UTmp
143 MUC 131 MUC
144 LocalChat 132 LocalChat
@@ -149,13 +137,10 @@ library
149 XMPPServer 137 XMPPServer
150 Util 138 Util
151 Presence 139 Presence
152 Control.Concurrent.PingMachine
153 Connection
154 ToxChat 140 ToxChat
155 ToxToXMPP 141 ToxToXMPP
156 ToxManager 142 ToxManager
157 XMPPToTox 143 XMPPToTox
158 DebugUtil
159 Data.IntervalSet 144 Data.IntervalSet
160 Data.Tox.Message 145 Data.Tox.Message
161 HandshakeCache 146 HandshakeCache
@@ -233,6 +218,7 @@ library
233 , kad 218 , kad
234 , tasks 219 , tasks
235 , torrent-types 220 , torrent-types
221 , server
236 222
237 if impl(ghc < 8) 223 if impl(ghc < 8)
238 Build-depends: transformers 224 Build-depends: transformers
@@ -319,6 +305,7 @@ executable dhtd
319 , pretty 305 , pretty
320 , dependent-sum 306 , dependent-sum
321 , dht-client 307 , dht-client
308 , server
322 , dput-hslogger 309 , dput-hslogger
323 , word64-map 310 , word64-map
324 , tox-crypto 311 , tox-crypto
@@ -368,6 +355,7 @@ executable testTox
368 default-language: Haskell2010 355 default-language: Haskell2010
369 build-depends: base 356 build-depends: base
370 , dht-client 357 , dht-client
358 , server
371 , dput-hslogger 359 , dput-hslogger
372 , tox-crypto 360 , tox-crypto
373 , lifted-concurrent 361 , lifted-concurrent
diff --git a/dht/stack.yaml b/dht/stack.yaml
index 3ae992c7..5c6013a0 100644
--- a/dht/stack.yaml
+++ b/dht/stack.yaml
@@ -18,6 +18,7 @@ extra-deps:
18- "../concurrent-supply/" 18- "../concurrent-supply/"
19- "../base32-bytestring/" 19- "../base32-bytestring/"
20- "../dependent-map/" 20- "../dependent-map/"
21- "../server/"
21- cryptonite-0.23 22- cryptonite-0.23
22- reference-0.1 23- reference-0.1
23- avahi-0.2.0@sha256:eb725536d8427548685b531d4bf8271a3104da06f611ed38165a0e08e21c54eb,1799 24- avahi-0.2.0@sha256:eb725536d8427548685b531d4bf8271a3104da06f611ed38165a0e08e21c54eb,1799
diff --git a/lifted-concurrent/lifted-concurrent.cabal b/lifted-concurrent/lifted-concurrent.cabal
index bbf254e3..8fe4b6a9 100644
--- a/lifted-concurrent/lifted-concurrent.cabal
+++ b/lifted-concurrent/lifted-concurrent.cabal
@@ -19,6 +19,8 @@ library
19 exposed-modules: 19 exposed-modules:
20 Control.Concurrent.Lifted.Instrument 20 Control.Concurrent.Lifted.Instrument
21 , Control.Concurrent.Async.Lifted.Instrument 21 , Control.Concurrent.Async.Lifted.Instrument
22 , DebugUtil
23 , Control.Concurrent.ThreadUtil
22 other-modules: DebugTag 24 other-modules: DebugTag
23 other-extensions: FlexibleContexts 25 other-extensions: FlexibleContexts
24 build-depends: 26 build-depends:
@@ -32,3 +34,4 @@ library
32 , transformers-base 34 , transformers-base
33 hs-source-dirs: src 35 hs-source-dirs: src
34 default-language: Haskell2010 36 default-language: Haskell2010
37 cpp-options: -DTHREAD_DEBUG
diff --git a/dht/src/Control/Concurrent/ThreadUtil.hs b/lifted-concurrent/src/Control/Concurrent/ThreadUtil.hs
index a258d933..a258d933 100644
--- a/dht/src/Control/Concurrent/ThreadUtil.hs
+++ b/lifted-concurrent/src/Control/Concurrent/ThreadUtil.hs
diff --git a/dht/src/DebugUtil.hs b/lifted-concurrent/src/DebugUtil.hs
index 96ab8cc5..e73f9061 100644
--- a/dht/src/DebugUtil.hs
+++ b/lifted-concurrent/src/DebugUtil.hs
@@ -1,4 +1,5 @@
1{-# LANGUAGE CPP #-} 1{-# LANGUAGE CPP #-}
2{-# LANGUAGE RecordWildCards #-}
2module DebugUtil where 3module DebugUtil where
3 4
4import Control.Monad 5import Control.Monad
diff --git a/server/server.cabal b/server/server.cabal
new file mode 100644
index 00000000..95d7aacf
--- /dev/null
+++ b/server/server.cabal
@@ -0,0 +1,25 @@
1cabal-version: 2.2
2-- Initial package description 'server.cabal' generated by 'cabal init'.
3-- For further documentation, see http://haskell.org/cabal/users-guide/
4
5name: server
6version: 0.1.0.0
7synopsis: TCP/UDP server library.
8-- description:
9-- bug-reports:
10license: NONE
11-- license-file: LICENSE
12author: Joe Crayne
13maintainer: joe@jerkface.net
14-- copyright:
15category: Network
16extra-source-files: CHANGELOG.md
17
18library
19 exposed-modules: Network.QueryResponse, Network.StreamServer, Network.SocketLike, Network.QueryResponse.TCP, Data.TableMethods, Connection.Tcp, Control.Concurrent.Delay, DNSCache, GetHostByAddr, ControlMaybe, SockAddr, Control.Concurrent.PingMachine, Connection
20 other-modules: ForkLabeled, DebugTag
21 other-extensions: CPP, GADTs, LambdaCase, PartialTypeSignatures, RankNTypes, ScopedTypeVariables, TupleSections, TypeFamilies, TypeOperators, OverloadedStrings, GeneralizedNewtypeDeriving, DoAndIfThenElse, FlexibleInstances, StandaloneDeriving
22 build-depends: base, stm, bytestring, dependent-map, dependent-sum, contravariant, containers, time, network, cpu, dput-hslogger, directory, lifted-base, hashable, conduit, text, psq-wrap, minmax-psq, lifted-concurrent, word64-map, network-addr
23 hs-source-dirs: src
24 default-language: Haskell2010
25 cpp-options: -DTHREAD_DEBUG
diff --git a/dht/Connection.hs b/server/src/Connection.hs
index ea86f4bb..ea86f4bb 100644
--- a/dht/Connection.hs
+++ b/server/src/Connection.hs
diff --git a/dht/Connection/Tcp.hs b/server/src/Connection/Tcp.hs
index 4d50d47f..7d93e7de 100644
--- a/dht/Connection/Tcp.hs
+++ b/server/src/Connection/Tcp.hs
@@ -1,12 +1,13 @@
1{-# OPTIONS_HADDOCK prune #-} 1{-# OPTIONS_HADDOCK prune #-}
2{-# LANGUAGE CPP #-} 2{-# LANGUAGE CPP #-}
3{-# LANGUAGE DoAndIfThenElse #-} 3{-# LANGUAGE DoAndIfThenElse #-}
4{-# LANGUAGE FlexibleInstances #-} 4{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE OverloadedStrings #-} 5{-# LANGUAGE LambdaCase #-}
6{-# LANGUAGE RankNTypes #-} 6{-# LANGUAGE NondecreasingIndentation #-}
7{-# LANGUAGE StandaloneDeriving #-} 7{-# LANGUAGE OverloadedStrings #-}
8{-# LANGUAGE TupleSections #-} 8{-# LANGUAGE RankNTypes #-}
9{-# LANGUAGE LambdaCase #-} 9{-# LANGUAGE StandaloneDeriving #-}
10{-# LANGUAGE TupleSections #-}
10----------------------------------------------------------------------------- 11-----------------------------------------------------------------------------
11-- | 12-- |
12-- Module : Connection.Tcp 13-- Module : Connection.Tcp
diff --git a/dht/src/Control/Concurrent/Delay.hs b/server/src/Control/Concurrent/Delay.hs
index 67dcd451..5cc1f99a 100644
--- a/dht/src/Control/Concurrent/Delay.hs
+++ b/server/src/Control/Concurrent/Delay.hs
@@ -1,3 +1,4 @@
1{-# LANGUAGE NondecreasingIndentation #-}
1module Control.Concurrent.Delay where 2module Control.Concurrent.Delay where
2 3
3import Control.Concurrent 4import Control.Concurrent
diff --git a/dht/src/Control/Concurrent/PingMachine.hs b/server/src/Control/Concurrent/PingMachine.hs
index a8f10e83..5de0e2e5 100644
--- a/dht/src/Control/Concurrent/PingMachine.hs
+++ b/server/src/Control/Concurrent/PingMachine.hs
@@ -1,5 +1,6 @@
1{-# LANGUAGE CPP #-} 1{-# LANGUAGE CPP #-}
2{-# LANGUAGE TupleSections #-} 2{-# LANGUAGE NondecreasingIndentation #-}
3{-# LANGUAGE TupleSections #-}
3module Control.Concurrent.PingMachine where 4module Control.Concurrent.PingMachine where
4 5
5import Control.Monad 6import Control.Monad
@@ -7,6 +8,7 @@ import Data.Function
7#ifdef THREAD_DEBUG 8#ifdef THREAD_DEBUG
8import Control.Concurrent.Lifted.Instrument 9import Control.Concurrent.Lifted.Instrument
9#else 10#else
11import Control.Concurrent (forkIO)
10import Control.Concurrent.Lifted 12import Control.Concurrent.Lifted
11import GHC.Conc (labelThread) 13import GHC.Conc (labelThread)
12#endif 14#endif
diff --git a/dht/Presence/ControlMaybe.hs b/server/src/ControlMaybe.hs
index a101d667..a101d667 100644
--- a/dht/Presence/ControlMaybe.hs
+++ b/server/src/ControlMaybe.hs
diff --git a/dht/Presence/DNSCache.hs b/server/src/DNSCache.hs
index 9bb354e1..f539c71f 100644
--- a/dht/Presence/DNSCache.hs
+++ b/server/src/DNSCache.hs
@@ -8,9 +8,10 @@
8-- to build with GHC's -threaded option. Otherwise, if the wrapped FFI calls 8-- to build with GHC's -threaded option. Otherwise, if the wrapped FFI calls
9-- to resolve the address will block Haskell threads. Note: I didn't verify 9-- to resolve the address will block Haskell threads. Note: I didn't verify
10-- this. 10-- this.
11{-# LANGUAGE TupleSections #-} 11{-# LANGUAGE CPP #-}
12{-# LANGUAGE RankNTypes #-} 12{-# LANGUAGE NondecreasingIndentation #-}
13{-# LANGUAGE CPP #-} 13{-# LANGUAGE RankNTypes #-}
14{-# LANGUAGE TupleSections #-}
14module DNSCache 15module DNSCache
15 ( DNSCache 16 ( DNSCache
16 , reverseResolve 17 , reverseResolve
diff --git a/dht/src/Data/TableMethods.hs b/server/src/Data/TableMethods.hs
index e4208a69..e4208a69 100644
--- a/dht/src/Data/TableMethods.hs
+++ b/server/src/Data/TableMethods.hs
diff --git a/server/src/DebugTag.hs b/server/src/DebugTag.hs
new file mode 100644
index 00000000..9ac04bb0
--- /dev/null
+++ b/server/src/DebugTag.hs
@@ -0,0 +1,24 @@
1module DebugTag where
2
3import Data.Typeable
4
5-- | Debug Tags, add more as needed, but ensure XAnnounce is always first, XMisc last
6data DebugTag
7 = XAnnounce
8 | XBitTorrent
9 | XDHT
10 | XLan
11 | XMan
12 | XNetCrypto
13 | XNetCryptoOut
14 | XOnion
15 | XRoutes
16 | XPing
17 | XRefresh
18 | XJabber
19 | XTCP
20 | XMisc
21 | XNodeinfoSearch
22 | XUnexpected -- Used only for special anomalous errors that we didn't expect to happen.
23 | XUnused -- Never commit code that uses XUnused.
24 deriving (Eq, Ord, Show, Read, Enum, Bounded,Typeable)
diff --git a/server/src/ForkLabeled.hs b/server/src/ForkLabeled.hs
new file mode 100644
index 00000000..50b5d76c
--- /dev/null
+++ b/server/src/ForkLabeled.hs
@@ -0,0 +1,16 @@
1{-# LANGUAGE CPP #-}
2module ForkLabeled where
3
4#ifdef THREAD_DEBUG
5import Control.Concurrent.Lifted.Instrument
6#else
7import Control.Concurrent.Lifted
8import GHC.Conc (labelThread,forkIO)
9#endif
10
11forkLabeled :: String -> IO () -> IO ThreadId
12forkLabeled s io = do
13 t <- forkIO io
14 labelThread t s
15 return t
16
diff --git a/dht/Presence/GetHostByAddr.hs b/server/src/GetHostByAddr.hs
index 45bca5e9..068fc93d 100644
--- a/dht/Presence/GetHostByAddr.hs
+++ b/server/src/GetHostByAddr.hs
@@ -1,4 +1,5 @@
1{-# LANGUAGE ForeignFunctionInterface #-} 1{-# LANGUAGE ForeignFunctionInterface #-}
2{-# LANGUAGE NondecreasingIndentation #-}
2module GetHostByAddr where 3module GetHostByAddr where
3 4
4import Network.BSD 5import Network.BSD
diff --git a/dht/src/Network/QueryResponse.hs b/server/src/Network/QueryResponse.hs
index 20e7ecf0..20e7ecf0 100644
--- a/dht/src/Network/QueryResponse.hs
+++ b/server/src/Network/QueryResponse.hs
diff --git a/dht/src/Network/QueryResponse/TCP.hs b/server/src/Network/QueryResponse/TCP.hs
index 0028a5b6..8b1b432b 100644
--- a/dht/src/Network/QueryResponse/TCP.hs
+++ b/server/src/Network/QueryResponse/TCP.hs
@@ -1,13 +1,15 @@
1{-# LANGUAGE CPP #-} 1{-# LANGUAGE CPP #-}
2{-# LANGUAGE GeneralizedNewtypeDeriving #-} 2{-# LANGUAGE GeneralizedNewtypeDeriving #-}
3{-# LANGUAGE LambdaCase #-} 3{-# LANGUAGE LambdaCase #-}
4{-# LANGUAGE OverloadedStrings #-}
4module Network.QueryResponse.TCP where 5module Network.QueryResponse.TCP where
5 6
6#ifdef THREAD_DEBUG 7#ifdef THREAD_DEBUG
7import Control.Concurrent.Lifted.Instrument 8import Control.Concurrent.Lifted.Instrument
8#else 9#else
9import Control.Concurrent.Lifted 10import Control.Concurrent.Lifted
10import GHC.Conc (labelThread) 11import GHC.Conc (labelThread,forkIO)
12import ForkLabeled
11#endif 13#endif
12 14
13import Control.Arrow 15import Control.Arrow
diff --git a/dht/src/Network/SocketLike.hs b/server/src/Network/SocketLike.hs
index 37891cfd..37891cfd 100644
--- a/dht/src/Network/SocketLike.hs
+++ b/server/src/Network/SocketLike.hs
diff --git a/dht/src/Network/StreamServer.hs b/server/src/Network/StreamServer.hs
index 1da612ce..1da612ce 100644
--- a/dht/src/Network/StreamServer.hs
+++ b/server/src/Network/StreamServer.hs
diff --git a/dht/Presence/SockAddr.hs b/server/src/SockAddr.hs
index b5fbf16e..b5fbf16e 100644
--- a/dht/Presence/SockAddr.hs
+++ b/server/src/SockAddr.hs