summaryrefslogtreecommitdiff
path: root/src/Network/Address.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/Address.hs')
-rw-r--r--src/Network/Address.hs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Network/Address.hs b/src/Network/Address.hs
index 0fbd191a..d34b0431 100644
--- a/src/Network/Address.hs
+++ b/src/Network/Address.hs
@@ -83,6 +83,7 @@ module Network.Address
83 -- * Utils 83 -- * Utils
84 , libUserAgent 84 , libUserAgent
85 , sockAddrPort 85 , sockAddrPort
86 , withPort
86 , getBindAddress 87 , getBindAddress
87 ) where 88 ) where
88 89
@@ -147,6 +148,12 @@ sockAddrPort (SockAddrInet6 p _ _ _) = Just p
147sockAddrPort _ = Nothing 148sockAddrPort _ = Nothing
148{-# INLINE sockAddrPort #-} 149{-# INLINE sockAddrPort #-}
149 150
151withPort :: SockAddr -> PortNumber -> SockAddr
152withPort (SockAddrInet _ ip ) port = SockAddrInet port ip
153withPort (SockAddrInet6 _ flow ip scope) port = SockAddrInet6 port flow ip scope
154withPort addr _ = addr
155{-# INLINE withPort #-}
156
150instance Address a => Address (NodeAddr a) where 157instance Address a => Address (NodeAddr a) where
151 toSockAddr NodeAddr {..} = setPort nodePort $ toSockAddr nodeHost 158 toSockAddr NodeAddr {..} = setPort nodePort $ toSockAddr nodeHost
152 fromSockAddr sa = NodeAddr <$> fromSockAddr sa <*> sockAddrPort sa 159 fromSockAddr sa = NodeAddr <$> fromSockAddr sa <*> sockAddrPort sa