Set the dns server based on the platform
parent
b052aa61cb
commit
ea9918e099
|
@ -4,11 +4,11 @@ USING: accessors alien.enums alien.syntax arrays assocs
|
||||||
byte-arrays calendar combinators combinators.smart constructors
|
byte-arrays calendar combinators combinators.smart constructors
|
||||||
destructors fry grouping io io.binary io.buffers
|
destructors fry grouping io io.binary io.buffers
|
||||||
io.encodings.binary io.encodings.string io.encodings.utf8
|
io.encodings.binary io.encodings.string io.encodings.utf8
|
||||||
io.files io.ports io.sockets io.streams.byte-array io.timeouts
|
io.files io.ports io.sockets io.sockets.private
|
||||||
kernel make math math.bitwise math.parser math.ranges
|
io.streams.byte-array io.timeouts kernel make math math.bitwise
|
||||||
math.statistics memoize namespaces random sequences
|
math.parser math.ranges math.statistics memoize namespaces
|
||||||
slots.syntax splitting strings system unicode.categories
|
nested-comments random sequences slots.syntax splitting strings
|
||||||
vectors nested-comments io.sockets.private ;
|
system unicode.categories vectors vocabs.loader ;
|
||||||
IN: dns
|
IN: dns
|
||||||
|
|
||||||
GENERIC: stream-peek1 ( stream -- byte/f )
|
GENERIC: stream-peek1 ( stream -- byte/f )
|
||||||
|
@ -59,17 +59,6 @@ SYMBOL: dns-servers
|
||||||
: clear-dns-servers ( -- )
|
: clear-dns-servers ( -- )
|
||||||
V{ } clone dns-servers set-global ;
|
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' )
|
: >dotted ( domain -- domain' )
|
||||||
dup "." tail? [ "." append ] unless ;
|
dup "." tail? [ "." append ] unless ;
|
||||||
|
|
||||||
|
@ -406,3 +395,12 @@ M: SOA rdata>byte-array
|
||||||
[ dns-A-query a-message. ]
|
[ dns-A-query a-message. ]
|
||||||
[ dns-AAAA-query a-message. ]
|
[ dns-AAAA-query a-message. ]
|
||||||
[ dns-MX-query mx-message. ] tri ;
|
[ 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
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Doug Coleman
|
|
@ -0,0 +1 @@
|
||||||
|
unix
|
|
@ -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 ;
|
|
@ -0,0 +1 @@
|
||||||
|
Doug Coleman
|
|
@ -0,0 +1 @@
|
||||||
|
windows
|
|
@ -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 ;
|
Loading…
Reference in New Issue