diff --git a/extra/dns/dns.factor b/extra/dns/dns.factor index 61bdebfedd..4d14b27e89 100644 --- a/extra/dns/dns.factor +++ b/extra/dns/dns.factor @@ -4,11 +4,11 @@ USING: accessors alien.enums alien.syntax arrays assocs byte-arrays calendar combinators combinators.smart constructors destructors fry grouping io io.binary io.buffers io.encodings.binary io.encodings.string io.encodings.utf8 -io.files io.ports io.sockets io.streams.byte-array io.timeouts -kernel make math math.bitwise math.parser math.ranges -math.statistics memoize namespaces random sequences -slots.syntax splitting strings system unicode.categories -vectors nested-comments io.sockets.private ; +io.files io.ports io.sockets io.sockets.private +io.streams.byte-array io.timeouts kernel make math math.bitwise +math.parser math.ranges math.statistics memoize namespaces +nested-comments random sequences slots.syntax splitting strings +system unicode.categories vectors vocabs.loader ; IN: dns GENERIC: stream-peek1 ( stream -- byte/f ) @@ -59,17 +59,6 @@ SYMBOL: dns-servers : clear-dns-servers ( -- ) V{ } clone dns-servers set-global ; -! Google DNS servers -CONSTANT: initial-dns-servers { "8.8.8.8" "8.8.4.4" } - -: load-resolve.conf ( -- seq ) - "/etc/resolv.conf" utf8 file-lines - [ [ blank? ] trim ] map - [ "#" head? not ] filter - [ [ " " split1 swap ] dip push-at ] sequence>hashtable "nameserver" swap at ; - -dns-servers [ initial-dns-servers >vector ] initialize - : >dotted ( domain -- domain' ) dup "." tail? [ "." append ] unless ; @@ -406,3 +395,12 @@ M: SOA rdata>byte-array [ dns-A-query a-message. ] [ dns-AAAA-query a-message. ] [ dns-MX-query mx-message. ] tri ; + +HOOK: initial-dns-servers os ( -- seq ) + +{ + { [ os windows? ] [ "dns.windows" ] } + { [ os unix? ] [ "dns.unix" ] } +} cond require + +dns-servers [ initial-dns-servers >vector ] initialize diff --git a/extra/dns/unix/authors.txt b/extra/dns/unix/authors.txt new file mode 100644 index 0000000000..7c1b2f2279 --- /dev/null +++ b/extra/dns/unix/authors.txt @@ -0,0 +1 @@ +Doug Coleman diff --git a/extra/dns/unix/platforms.txt b/extra/dns/unix/platforms.txt new file mode 100644 index 0000000000..509143d863 --- /dev/null +++ b/extra/dns/unix/platforms.txt @@ -0,0 +1 @@ +unix diff --git a/extra/dns/unix/unix.factor b/extra/dns/unix/unix.factor new file mode 100644 index 0000000000..6c5a1b9bf0 --- /dev/null +++ b/extra/dns/unix/unix.factor @@ -0,0 +1,13 @@ +! Copyright (C) 2010 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: assocs dns io.encodings.utf8 io.files kernel +math.statistics sequences splitting system unicode.categories ; +IN: dns.unix + +: load-resolve.conf ( -- seq ) + "/etc/resolv.conf" utf8 file-lines + [ [ blank? ] trim ] map + [ "#" head? not ] filter + [ [ " " split1 swap ] dip push-at ] sequence>hashtable "nameserver" swap at ; + +M: unix initial-dns-servers load-resolve.conf ; \ No newline at end of file diff --git a/extra/dns/windows/authors.txt b/extra/dns/windows/authors.txt new file mode 100644 index 0000000000..7c1b2f2279 --- /dev/null +++ b/extra/dns/windows/authors.txt @@ -0,0 +1 @@ +Doug Coleman diff --git a/extra/dns/windows/platforms.txt b/extra/dns/windows/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/extra/dns/windows/platforms.txt @@ -0,0 +1 @@ +windows diff --git a/extra/dns/windows/windows.factor b/extra/dns/windows/windows.factor new file mode 100644 index 0000000000..a43eede183 --- /dev/null +++ b/extra/dns/windows/windows.factor @@ -0,0 +1,6 @@ +! Copyright (C) 2010 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: dns system windows.iphlpapi ; +IN: dns.windows + +M: windows initial-dns-servers dns-server-ips ; \ No newline at end of file