diff --git a/basis/io/servers/connection/connection.factor b/basis/io/servers/connection/connection.factor index a6e13090a1..e16f94e505 100644 --- a/basis/io/servers/connection/connection.factor +++ b/basis/io/servers/connection/connection.factor @@ -87,9 +87,12 @@ M: f (>insecure) ; >insecure [ dup { [ secure? ] [ not ] } 1|| [ <secure> ] unless ] map ; +: filter-ipv6 ( seq -- seq' ) + ipv6-supported? [ [ ipv6? not ] filter ] unless ; + : listen-on ( threaded-server -- addrspecs ) [ secure>> >secure ] [ insecure>> >insecure ] bi append - [ resolve-host ] map concat ; + [ resolve-host ] map concat filter-ipv6 ; : accepted-connection ( remote local -- ) [ diff --git a/basis/io/sockets/sockets.factor b/basis/io/sockets/sockets.factor index b1175a9bb5..220587ef1f 100644 --- a/basis/io/sockets/sockets.factor +++ b/basis/io/sockets/sockets.factor @@ -6,7 +6,7 @@ arrays io.encodings io.ports io.streams.duplex io.encodings.ascii alien.strings io.binary accessors destructors classes byte-arrays parser alien.c-types math.parser splitting grouping math assocs summary system vocabs.loader combinators present fry vocabs.parser -classes.struct alien.data strings ; +classes.struct alien.data strings io.encodings.binary ; IN: io.sockets << { @@ -380,6 +380,9 @@ M: invalid-local-address summary [ invalid-local-address ] if ] dip with-variable ; inline +: ipv6-supported? ( -- ? ) + [ "::1" 0 <inet6> binary <server> dispose t ] [ drop f ] recover ; + { { [ os unix? ] [ "io.sockets.unix" require ] } { [ os windows? ] [ "io.sockets.windows" require ] }