Better fix for ipv6
parent
ef5baa5b67
commit
af96673458
|
@ -52,6 +52,9 @@ io.streams.string ;
|
||||||
[ B{ 0 0 0 0 0 0 0 0 0 127 0 0 0 0 0 1 } ]
|
[ B{ 0 0 0 0 0 0 0 0 0 127 0 0 0 0 0 1 } ]
|
||||||
[ "::127.0.0.1" T{ inet6 } inet-pton ] unit-test
|
[ "::127.0.0.1" T{ inet6 } inet-pton ] unit-test
|
||||||
|
|
||||||
|
[ B{ 0 2 0 0 0 0 0 9 0 127 0 0 0 0 0 1 } ]
|
||||||
|
[ "2::9:127.0.0.1" T{ inet6 } inet-pton ] unit-test
|
||||||
|
|
||||||
[ "2001:6f8:37a:5:0:0:0:1" ]
|
[ "2001:6f8:37a:5:0:0:0:1" ]
|
||||||
[ "2001:6f8:37a:5::1" T{ inet6 } [ inet-pton ] [ inet-ntop ] bi ] unit-test
|
[ "2001:6f8:37a:5::1" T{ inet6 } [ inet-pton ] [ inet-ntop ] bi ] unit-test
|
||||||
|
|
||||||
|
|
|
@ -120,19 +120,16 @@ ERROR: bad-ipv6-component obj ;
|
||||||
|
|
||||||
ERROR: bad-ipv4-embedded-prefix obj ;
|
ERROR: bad-ipv4-embedded-prefix obj ;
|
||||||
|
|
||||||
: ensure-zero-prefix ( seq -- seq )
|
: parse-ipv6-component ( seq -- seq' )
|
||||||
dup [ hex> ] map
|
[ dup hex> [ nip ] [ bad-ipv6-component ] if* ] { } map-as ;
|
||||||
[ { f 0 } swap member? ] all? [ bad-ipv4-embedded-prefix ] unless ;
|
|
||||||
|
|
||||||
: parse-inet6 ( string -- seq )
|
: parse-inet6 ( string -- seq )
|
||||||
[ f ] [
|
[ f ] [
|
||||||
":" split CHAR: . over last member? [
|
":" split CHAR: . over last member? [
|
||||||
unclip-last
|
unclip-last
|
||||||
[ ensure-zero-prefix drop ] [ parse-inet4 ] bi*
|
[ parse-ipv6-component ] [ parse-inet4 ] bi* append
|
||||||
] [
|
] [
|
||||||
[
|
parse-ipv6-component
|
||||||
dup hex> [ nip ] [ bad-ipv6-component ] if*
|
|
||||||
] { } map-as
|
|
||||||
] if
|
] if
|
||||||
] if-empty ;
|
] if-empty ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue