diff options
Diffstat (limited to 'Presence/XMPPServer.hs')
-rw-r--r-- | Presence/XMPPServer.hs | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/Presence/XMPPServer.hs b/Presence/XMPPServer.hs index f607989d..ff50ab1c 100644 --- a/Presence/XMPPServer.hs +++ b/Presence/XMPPServer.hs | |||
@@ -67,9 +67,6 @@ import qualified Data.Set as Set | |||
67 | import GetHostByAddr | 67 | import GetHostByAddr |
68 | import XMPPTypes | 68 | import XMPPTypes |
69 | 69 | ||
70 | is_remote (RemotePeer _) = True | ||
71 | is_remote _ = False | ||
72 | |||
73 | getNamesForPeer :: Peer -> IO [ByteString] | 70 | getNamesForPeer :: Peer -> IO [ByteString] |
74 | getNamesForPeer LocalHost = fmap ((:[]) . pack) getHostName | 71 | getNamesForPeer LocalHost = fmap ((:[]) . pack) getHostName |
75 | getNamesForPeer peer@(RemotePeer addr) = do | 72 | getNamesForPeer peer@(RemotePeer addr) = do |
@@ -85,10 +82,6 @@ getNamesForPeer peer@(RemotePeer addr) = do | |||
85 | return . map pack $ names | 82 | return . map pack $ names |
86 | 83 | ||
87 | 84 | ||
88 | peerAddr :: Peer -> SockAddr | ||
89 | peerAddr (RemotePeer addr) = addr | ||
90 | -- peerAddr LocalHost = throw exception | ||
91 | |||
92 | 85 | ||
93 | xmlifyPresenceForPeer sock (Presence jid stat) = do | 86 | xmlifyPresenceForPeer sock (Presence jid stat) = do |
94 | -- TODO: accept socket argument and determine local ip address | 87 | -- TODO: accept socket argument and determine local ip address |
@@ -587,62 +580,6 @@ connect_to_server chan peer = (>> return ()) . runMaybeT $ do | |||
587 | L.putStrLn $ "OUT peer: </stream>" | 580 | L.putStrLn $ "OUT peer: </stream>" |
588 | 581 | ||
589 | 582 | ||
590 | splitJID :: ByteString -> (Maybe ByteString,ByteString,Maybe ByteString) | ||
591 | splitJID bjid = | ||
592 | let xs = L.splitWith (=='@') bjid | ||
593 | ys = L.splitWith (=='/') (last xs) | ||
594 | server = head ys | ||
595 | name | ||
596 | = case xs of | ||
597 | (n:s:_) -> Just n | ||
598 | (s:_) -> Nothing | ||
599 | rsrc = case ys of | ||
600 | (s:_:_) -> Just $ last ys | ||
601 | _ -> Nothing | ||
602 | in (name,server,rsrc) | ||
603 | |||
604 | strip_brackets s = | ||
605 | case L.uncons s of | ||
606 | Just ('[',t) -> L.takeWhile (/=']') t | ||
607 | _ -> s | ||
608 | |||
609 | parseAddressJID :: ByteString -> IO JID | ||
610 | parseAddressJID jid = do | ||
611 | let (name,peer_string,rsc) = splitJID jid | ||
612 | hints = Just $ defaultHints { addrFlags = [ {- AI_NUMERICHOST, -} AI_CANONNAME ] } | ||
613 | peer_string' = unpack . strip_brackets $ peer_string | ||
614 | peer <- do | ||
615 | -- putStrLn $ "getAddrInfo 2 " ++ Prelude.show ( Just (unpack peer_string)) | ||
616 | info <- getAddrInfo hints (Just peer_string') Nothing -- (Just "xmpp-server") | ||
617 | let info0 = head info | ||
618 | return . RemotePeer . addrAddress $ info0 | ||
619 | return $ JID name peer rsc | ||
620 | |||
621 | parseHostNameJID :: ByteString -> IO JID | ||
622 | parseHostNameJID jid = do | ||
623 | let (name,peer_string,rsc) = splitJID jid | ||
624 | hints = Just $ defaultHints { addrFlags = [ AI_CANONNAME ] } | ||
625 | peer <- do | ||
626 | if peer_string=="localhost" | ||
627 | then return LocalHost | ||
628 | else do | ||
629 | -- putStrLn $ "getAddrInfo 3 " ++ Prelude.show ( Just (unpack peer_string)) | ||
630 | info <- getAddrInfo hints (Just (unpack peer_string)) Nothing -- (Just "xmpp-server") | ||
631 | let info0 = head info | ||
632 | cname = addrCanonName info0 | ||
633 | if cname==Just "localhost" | ||
634 | then return LocalHost | ||
635 | else do | ||
636 | self <- getHostName | ||
637 | return $ if Just self==cname | ||
638 | then LocalHost | ||
639 | else RemotePeer (addrAddress info0) | ||
640 | return $ JID name peer rsc | ||
641 | |||
642 | socketFamily (SockAddrInet _ _) = AF_INET | ||
643 | socketFamily (SockAddrInet6 _ _ _ _) = AF_INET6 | ||
644 | socketFamily (SockAddrUnix _) = AF_UNIX | ||
645 | |||
646 | connect' :: SockAddr -> Int -> IO (Maybe Socket) | 583 | connect' :: SockAddr -> Int -> IO (Maybe Socket) |
647 | connect' addr port = do | 584 | connect' addr port = do |
648 | proto <- getProtocolNumber "tcp" | 585 | proto <- getProtocolNumber "tcp" |