git.iko.soy/distributed-process
on master help sign in
Allow for colons in hostnames. Bumb to 0.2.0.3.
ceb7e5aEdsko de Vries
network-transport-tcp/ChangeLog+4
@@ -1,3 +1,7 @@
1+2012-08-20 Edsko de Vries <edsko@well-typed.com> 0.2.0.3
2+
3+* Allow for colons in hostnames (for IPv6)
4+
12012-07-16 Edsko de Vries <edsko@well-typed.com> 0.2.0.2
52012-07-16 Edsko de Vries <edsko@well-typed.com> 0.2.0.2
2
6
3* Base 4.6 compatibility
7* Base 4.6 compatibility
network-transport-tcp/network-transport-tcp.cabal+1−1
@@ -1,5 +1,5 @@
1Name: network-transport-tcp
1Name: network-transport-tcp
2−Version: 0.2.0.2
2+Version: 0.2.0.3
3Cabal-Version: >=1.8
3Cabal-Version: >=1.8
4Build-Type: Simple
4Build-Type: Simple
5License: BSD3
5License: BSD3
network-transport-tcp/src/Network/Transport/TCP.hs+17−2
@@ -97,7 +97,7 @@ import Control.Exception ( IOException
97import Data.IORef (IORef, newIORef, writeIORef, readIORef)
97import Data.IORef (IORef, newIORef, writeIORef, readIORef)
98import Data.ByteString (ByteString)
98import Data.ByteString (ByteString)
99import qualified Data.ByteString as BS (concat)
99import qualified Data.ByteString as BS (concat)
100−import qualified Data.ByteString.Char8 as BSC (pack, unpack, split)
100+import qualified Data.ByteString.Char8 as BSC (pack, unpack)
101import Data.Int (Int32)
101import Data.Int (Int32)
102import Data.IntMap (IntMap)
102import Data.IntMap (IntMap)
103import qualified Data.IntMap as IntMap (empty)
103import qualified Data.IntMap as IntMap (empty)
@@ -1539,7 +1539,7 @@ encodeEndPointAddress host port ix = EndPointAddress . BSC.pack $
1539decodeEndPointAddress :: EndPointAddress
1539decodeEndPointAddress :: EndPointAddress
1540 -> Maybe (N.HostName, N.ServiceName, EndPointId)
1540 -> Maybe (N.HostName, N.ServiceName, EndPointId)
1541decodeEndPointAddress (EndPointAddress bs) =
1541decodeEndPointAddress (EndPointAddress bs) =
1542− case map BSC.unpack $ BSC.split ':' bs of
1542+ case splitMaxFromEnd (== ':') 2 $ BSC.unpack bs of
1543 [host, port, endPointIdStr] ->
1543 [host, port, endPointIdStr] ->
1544 case reads endPointIdStr of
1544 case reads endPointIdStr of
1545 [(endPointId, "")] -> Just (host, port, endPointId)
1545 [(endPointId, "")] -> Just (host, port, endPointId)
@@ -1547,6 +1547,21 @@ decodeEndPointAddress (EndPointAddress bs) =
1547 _ ->
1547 _ ->
1548 Nothing
1548 Nothing
1549
1549
1550+-- | @spltiMaxFromEnd p n xs@ splits list @xs@ at elements matching @p@,
1551+-- returning at most @p@ segments -- counting from the /end/
1552+--
1553+-- > splitMaxFromEnd (== ':') 2 "ab:cd:ef:gh" == ["ab:cd", "ef", "gh"]
1554+splitMaxFromEnd :: (a -> Bool) -> Int -> [a] -> [[a]]
1555+splitMaxFromEnd p = \n -> go [[]] n . reverse
1556+ where
1557+ -- go :: [[a]] -> Int -> [a] -> [[a]]
1558+ go accs _ [] = accs
1559+ go ([] : accs) 0 xs = reverse xs : accs
1560+ go (acc : accs) n (x:xs) =
1561+ if p x then go ([] : acc : accs) (n - 1) xs
1562+ else go ((x : acc) : accs) n xs
1563+ go _ _ _ = error "Bug in splitMaxFromEnd"
1564+
1550--------------------------------------------------------------------------------
1565--------------------------------------------------------------------------------
1551-- Functions from TransportInternals --
1566-- Functions from TransportInternals --
1552--------------------------------------------------------------------------------
1567--------------------------------------------------------------------------------