diff options
author | Joe Crayne <joe@jerkface.net> | 2018-07-05 21:47:28 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2018-07-05 21:48:09 -0400 |
commit | 3e451443ea432a0c5c3ed1f85953188529c1a754 (patch) | |
tree | 806785ce62fe21b56b0b2bf4c850cf91d4fde1cc /ToxToXMPP.hs | |
parent | 93bfd69110df060a9c8ec6c194e0d30553d6e20d (diff) |
Use ordinary (.tox) hostnames in JIDs from Tox peers to clients.
Diffstat (limited to 'ToxToXMPP.hs')
-rw-r--r-- | ToxToXMPP.hs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/ToxToXMPP.hs b/ToxToXMPP.hs index 9e72da72..8b2544d7 100644 --- a/ToxToXMPP.hs +++ b/ToxToXMPP.hs | |||
@@ -21,15 +21,19 @@ import Network.Tox.NodeId | |||
21 | import Util (unsplitJID) | 21 | import Util (unsplitJID) |
22 | import XMPPServer as XMPP | 22 | import XMPPServer as XMPP |
23 | 23 | ||
24 | xmppHostname :: PublicKey -> Text | ||
25 | xmppHostname k = T.pack $ show (key2id k) ++ ".tox" | ||
26 | |||
24 | toxToXmpp :: Monad m => SockAddr -> PublicKey -> Text -> Conduit Tox.CryptoMessage m XML.Event | 27 | toxToXmpp :: Monad m => SockAddr -> PublicKey -> Text -> Conduit Tox.CryptoMessage m XML.Event |
25 | toxToXmpp laddr me theirhost = do | 28 | toxToXmpp laddr me theirhost = do |
26 | CL.sourceList $ XMPP.greet' "jabber:server" theirhost | 29 | CL.sourceList $ XMPP.greet' "jabber:server" theirhost |
27 | let me_u = T.pack $ show (key2id me) | 30 | let me_u = Nothing |
28 | im_from = (Just $ "root@" <> theirhost) -- /from/ | 31 | me_h = xmppHostname me |
32 | im_from = (Just $ unsplitJID (Nothing, theirhost, Nothing)) -- /from/ | ||
29 | im_to = (Just $ unsplitJID | 33 | im_to = (Just $ unsplitJID |
30 | ( Just me_u | 34 | ( me_u |
31 | -- /to/ should match local address of this node. | 35 | -- /to/ should match local address of this node. |
32 | , T.pack (show laddr) | 36 | , me_h |
33 | , Nothing)) | 37 | , Nothing)) |
34 | awaitForever $ \case | 38 | awaitForever $ \case |
35 | 39 | ||
@@ -44,8 +48,8 @@ toxToXmpp laddr me theirhost = do | |||
44 | 48 | ||
45 | toxmsg -> do | 49 | toxmsg -> do |
46 | xmppInstantMessage "jabber:server" | 50 | xmppInstantMessage "jabber:server" |
47 | (Just theirhost) -- /from/ | 51 | im_from |
48 | (Just $ unsplitJID (Just me_u,T.pack (show laddr),Nothing)) -- /to/ should match local address of this node. | 52 | im_to -- /to/ should match local address of this node. |
49 | [ attr "style" "font-weight:bold; color:red" ] | 53 | [ attr "style" "font-weight:bold; color:red" ] |
50 | (T.pack $ show $ msgID toxmsg) | 54 | (T.pack $ show $ msgID toxmsg) |
51 | 55 | ||