diff options
| author | Roman Smrž <roman.smrz@seznam.cz> | 2026-08-22 15:39:40 +0200 |
|---|---|---|
| committer | Roman Smrž <roman.smrz@seznam.cz> | 2026-08-25 20:15:42 +0200 |
| commit | ef8bab8568b5263797d5534202ac192839663ce7 (patch) | |
| tree | 4749975f540d1d9c079072dbf37bb52a081fbeb2 /src/Erebos/Network/Address.hs | |
| parent | 6cede13cdadb3e9085cffaae0442d4b9503312ac (diff) | |
Discovery on localhost
Changelog: Discovery is now working also on localhost without need for external interface.
Diffstat (limited to 'src/Erebos/Network/Address.hs')
| -rw-r--r-- | src/Erebos/Network/Address.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Erebos/Network/Address.hs b/src/Erebos/Network/Address.hs index 63f6af1..8dedecd 100644 --- a/src/Erebos/Network/Address.hs +++ b/src/Erebos/Network/Address.hs @@ -2,6 +2,8 @@ module Erebos.Network.Address ( InetAddress(..), inetFromSockAddr, inetToSockAddr, + makeLocalhostAddress, + getLocalhostPort, SockAddr, PortNumber, ) where @@ -63,3 +65,11 @@ inetFromSockAddr saddr = first InetAddress <$> IP.fromSockAddr saddr inetToSockAddr :: ( InetAddress, PortNumber ) -> SockAddr inetToSockAddr = IP.toSockAddr . first fromInetAddress + + +makeLocalhostAddress :: PortNumber -> SockAddr +makeLocalhostAddress port = SockAddrInet6 port 0 ( 0, 0, 0, 1 ) 0 + +getLocalhostPort :: SockAddr -> Maybe PortNumber +getLocalhostPort (SockAddrInet6 port _ ( 0, 0, 0, 1 ) _) = Just port +getLocalhostPort _ = Nothing |