Class Methods
4.0
View on GitHub
static VALUE
get_dns_server_list(VALUE self)
{
FIXED_INFO *fixedinfo = NULL;
ULONG buflen = 0;
DWORD ret;
VALUE buf, nameservers = Qnil;
ret = GetNetworkParams(NULL, &buflen);
if (ret != ERROR_BUFFER_OVERFLOW) w32error_check(ret);
fixedinfo = ALLOCV(buf, buflen);
ret = GetNetworkParams(fixedinfo, &buflen);
if (ret == NO_ERROR) {
const IP_ADDR_STRING *ipaddr = &fixedinfo->DnsServerList;
nameservers = rb_ary_new();
do {
const char *s = ipaddr->IpAddress.String;
if (!*s) continue;
if (strcmp(s, "0.0.0.0") == 0) continue;
rb_ary_push(nameservers, rb_str_new_cstr(s));
} while ((ipaddr = ipaddr->Next) != NULL);
}
ALLOCV_END(buf);
w32error_check(ret);
return nameservers;
}
No documentation available
4.0
View on GitHub
# File tmp/rubies/ruby-4.0.0/ext/win32/lib/win32/resolv.rb, line 50
def get_hosts_dir
tcpip_params do |params|
params.value('DataBasePath')
end
end
No documentation available
4.0
View on GitHub
# File tmp/rubies/ruby-4.0.0/ext/win32/lib/win32/resolv.rb, line 24
def self.get_hosts_path
path = get_hosts_dir
path = File.expand_path('hosts', path)
File.exist?(path) ? path : nil
end
No documentation available
.
4.0
View on GitHub
# File tmp/rubies/ruby-4.0.0/ext/win32/lib/win32/resolv.rb, line 56
def get_info
search = nil
nameserver = get_dns_server_list
tcpip_params do |params|
slist = params.value('SearchList')
search = slist.split(/,\s*/) if slist and !slist.empty?
if add_search = search.nil?
search = []
domain = params.value('Domain')
if domain and !domain.empty?
search = [ domain ]
udmnd = params.value('UseDomainNameDevolution')
if udmnd&.nonzero?
if /^\w+\./ =~ domain
devo = $'
end
end
end
end
params.open('Interfaces') do |reg|
reg.each_key do |iface|
next unless ns = %w[NameServer DhcpNameServer].find do |key|
ns = iface.value(key)
break ns.split(/[,\s]\s*/) if ns and !ns.empty?
end
next if (nameserver & ns).empty?
if add_search
[ 'Domain', 'DhcpDomain' ].each do |key|
dom = iface.value(key)
if dom and !dom.empty?
search.concat(dom.split(/,\s*/))
break
end
end
end
end
end
search << devo if add_search and devo
end
[ search.uniq, nameserver.uniq ]
end
No documentation available
4.0
View on GitHub
# File tmp/rubies/ruby-4.0.0/ext/win32/lib/win32/resolv.rb, line 30
def self.get_resolv_info
search, nameserver = get_info
if search.empty?
search = nil
else
search.delete("")
search.uniq!
end
if nameserver.empty?
nameserver = nil
else
nameserver.delete("")
nameserver.delete("0.0.0.0")
nameserver.uniq!
end
[ search, nameserver ]
end
No documentation available
4.0
View on GitHub
static VALUE
tcpip_params_open(VALUE klass)
{
return reg_open_key(reg_key_class, HKEY_LOCAL_MACHINE, TCPIP_Params);
}
No documentation available