@@ -448,6 +448,10 @@ unpackBits ((k,v):xs) r
448
448
-----------------------------------------------------------------------------
449
449
-- SockAddr
450
450
451
+ -- |
452
+ --
453
+ -- >>> SockAddrInet6 80 0 (0,0,0xffff,0x01020304) 0
454
+ -- [::ffff:1.2.3.4]:80
451
455
instance Show SockAddr where
452
456
showsPrec _ (SockAddrUnix str) = showString str
453
457
showsPrec _ (SockAddrInet port ha)
@@ -467,6 +471,11 @@ showHostAddress ip =
467
471
let (u3, u2, u1, u0) = hostAddressToTuple ip in
468
472
foldr1 (.) . intersperse (showChar ' .' ) $ map showInt [u3, u2, u1, u0]
469
473
474
+ showHostAddress' :: HostAddress -> ShowS
475
+ showHostAddress' ip =
476
+ let (u3, u2, u1, u0) = hostAddressToTuple' ip in
477
+ foldr1 (.) . intersperse (showChar ' .' ) $ map showInt [u3, u2, u1, u0]
478
+
470
479
-- Taken from showIPv6 in Data.IP.Addr.
471
480
472
481
-- | Show an IPv6 address in the most appropriate notation, based on recommended
@@ -478,10 +487,10 @@ showHostAddress6 :: HostAddress6 -> ShowS
478
487
showHostAddress6 ha6@ (a1, a2, a3, a4)
479
488
-- IPv4-Mapped IPv6 Address
480
489
| a1 == 0 && a2 == 0 && a3 == 0xffff =
481
- showString " ::ffff:" . showHostAddress a4
490
+ showString " ::ffff:" . showHostAddress' a4
482
491
-- IPv4-Compatible IPv6 Address (exclude IPRange ::/112)
483
492
| a1 == 0 && a2 == 0 && a3 == 0 && a4 >= 0x10000 =
484
- showString " ::" . showHostAddress a4
493
+ showString " ::" . showHostAddress' a4
485
494
-- length of longest run > 1, replace it with "::"
486
495
| end - begin > 1 =
487
496
showFields prefix . showString " ::" . showFields suffix
0 commit comments