summaryrefslogtreecommitdiff
path: root/xmppServer.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-02-17 11:40:10 -0500
committerjoe <joe@jerkface.net>2014-02-17 11:40:10 -0500
commit38f7f68475502bc8b4ce8c6154865d52845b0c30 (patch)
tree8ef9ca5cac16af9796dc2727fb1613294f43f3d3 /xmppServer.hs
parent24f0f7a50653223ea72c846a56817760a0bd63b9 (diff)
cloneTChan unavailable in wheezy :(
added reverse-lookups for peer names
Diffstat (limited to 'xmppServer.hs')
-rw-r--r--xmppServer.hs14
1 files changed, 8 insertions, 6 deletions
diff --git a/xmppServer.hs b/xmppServer.hs
index ec3a618d..80adaf21 100644
--- a/xmppServer.hs
+++ b/xmppServer.hs
@@ -9,6 +9,7 @@ import Network.Socket
9 , defaultHints 9 , defaultHints
10 , addrFlags 10 , addrFlags
11 , AddrInfoFlag(AI_CANONNAME) 11 , AddrInfoFlag(AI_CANONNAME)
12 , SockAddr
12 ) 13 )
13import Data.Monoid ( (<>) ) 14import Data.Monoid ( (<>) )
14import qualified Data.Text as Text 15import qualified Data.Text as Text
@@ -43,6 +44,7 @@ data ClientState = ClientState
43 44
44data PresenceState = PresenceState 45data PresenceState = PresenceState
45 { clients :: TVar (Map ConnectionKey ClientState) 46 { clients :: TVar (Map ConnectionKey ClientState)
47 , associatedPeers :: TVar (Map SockAddr ())
46 } 48 }
47 49
48getConsolePids :: PresenceState -> IO [(Text,ProcessID)] 50getConsolePids :: PresenceState -> IO [(Text,ProcessID)]
@@ -104,13 +106,13 @@ tellClientHisName state k = forClient state k fallback go
104 106
105 107
106main = runResourceT $ do 108main = runResourceT $ do
107 -- us <- liftIO UTmp.users 109 -- hostname <- liftIO textHostName
108 -- liftIO $ putStrLn (show us) 110 state <- liftIO . atomically $ do
109 hostname <- liftIO textHostName 111 clients <- newTVar Map.empty
110 state <- do 112 associatedPeers <- newTVar Map.empty
111 clients <- liftIO . atomically $ newTVar Map.empty
112 return PresenceState 113 return PresenceState
113 { clients = clients 114 { clients = clients
115 , associatedPeers = associatedPeers
114 } 116 }
115 sv <- xmppServer 117 sv <- xmppServer
116 XMPPServerParameters 118 XMPPServerParameters
@@ -119,6 +121,7 @@ main = runResourceT $ do
119 , xmppTellMyNameToClient = textHostName 121 , xmppTellMyNameToClient = textHostName
120 , xmppTellMyNameToPeer = \addr -> return $ addrToText addr 122 , xmppTellMyNameToPeer = \addr -> return $ addrToText addr
121 , xmppTellPeerHisName = return . peerKeyToText 123 , xmppTellPeerHisName = return . peerKeyToText
124 , xmppTellClientNameOfPeer = peerKeyToResolvedName
122 , xmppNewConnection = \k outchan -> return () 125 , xmppNewConnection = \k outchan -> return ()
123 , xmppEOF = \k -> return () 126 , xmppEOF = \k -> return ()
124 , xmppRosterBuddies = \k -> return [] 127 , xmppRosterBuddies = \k -> return []
@@ -126,7 +129,6 @@ main = runResourceT $ do
126 , xmppRosterSolicited = \k -> return [] 129 , xmppRosterSolicited = \k -> return []
127 , xmppRosterOthers = \k -> return [] 130 , xmppRosterOthers = \k -> return []
128 , xmppSubscribeToRoster = \k -> return () 131 , xmppSubscribeToRoster = \k -> return ()
129 , xmppLookupPeerName = \k -> return "localhost"
130 -- , xmppLookupClientJID = \k -> return $ "nobody@" <> hostname <> "/tty666" 132 -- , xmppLookupClientJID = \k -> return $ "nobody@" <> hostname <> "/tty666"
131 , xmppDeliverMessage = \fail msg -> do 133 , xmppDeliverMessage = \fail msg -> do
132 let msgs = msgLangMap (stanzaType msg) 134 let msgs = msgLangMap (stanzaType msg)