September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -5,34 +5,34 @@
|
|||
|
||||
set "domain=www.kame.net"
|
||||
echo DOMAIN: "%domain%"
|
||||
echo.
|
||||
echo(
|
||||
call :DNS_Lookup "%domain%"
|
||||
echo.
|
||||
pause
|
||||
exit /b
|
||||
|
||||
::Main Procedure
|
||||
::Uses NSLOOKUP Command and a Temporary File
|
||||
::Also uses a dirty "parsing" to detect IP addresses.
|
||||
|
||||
::Uses NSLOOKUP Command. Also uses a dirty "parsing" to detect IP addresses.
|
||||
:DNS_Lookup [domain]
|
||||
setlocal enabledelayedexpansion
|
||||
for /f "delims=" %%T in ('forfiles /p "%~dp0." /m "%~nx0" /c "cmd /c echo(0x09"') do set "TAB=%%T"
|
||||
set "temp_file=%TMP%\NSLOOKUP_%RANDOM%.TMP"
|
||||
|
||||
::Define Variables and the TAB Character
|
||||
set "dom=%~1"
|
||||
set "record="
|
||||
for /f "tokens=1* delims=:" %%x in ('nslookup "%~1" 2^>nul') do (
|
||||
set "line=%%x"
|
||||
if "!line:~0,4!"=="Name" set "record=yes"
|
||||
if "!line:~0,5!"=="Alias" set "record="
|
||||
if "!record!"=="yes" (
|
||||
if "%%y"=="" (echo %%x>>"%temp_file%") else (echo %%x:%%y>>"%temp_file%")
|
||||
)
|
||||
set "reccnt=0"
|
||||
for /f "delims=" %%T in ('forfiles /p "%~dp0." /m "%~nx0" /c "cmd /c echo(0x09"') do set "TAB=%%T"
|
||||
|
||||
setlocal enabledelayedexpansion
|
||||
for /f "tokens=1* delims=:" %%x in ('nslookup "!dom!" 2^>nul') do (
|
||||
set "line=%%x"
|
||||
if /i "!line:~0,4!"=="Name" set "record=yes"
|
||||
if /i "!line:~0,5!"=="Alias" set "record="
|
||||
if "!record!"=="yes" (
|
||||
set /a reccnt+=1
|
||||
if "%%y"=="" (set "catch_!reccnt!=%%x") else (set "catch_!reccnt!=%%x:%%y")
|
||||
)
|
||||
)
|
||||
if exist "%temp_file%" (
|
||||
for /f "tokens=*" %%a in (
|
||||
'findstr /BC:"Address" "%temp_file%" ^& findstr /BC:"%TAB%" "%temp_file%"'
|
||||
) do (set "data=%%a"&echo !data:*s: =!)
|
||||
del /q "%temp_file%"
|
||||
) else (echo Connection to domain failed.)
|
||||
for /l %%c in (1,1,%reccnt%) do (
|
||||
if /i "!catch_%%c:~0,7!"=="Address" echo(!catch_%%c:*s: =!
|
||||
if /i "!catch_%%c:~0,1!"=="%TAB%" echo(!catch_%%c:%TAB% =!
|
||||
)
|
||||
endlocal
|
||||
goto :EOF
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import std.stdio, std.socket;
|
|||
void main() {
|
||||
auto domain = "www.kame.net", port = "80";
|
||||
|
||||
auto a = getAddressInfo(domain, port);
|
||||
auto a = getAddressInfo(domain, port, AddressFamily.INET);
|
||||
writefln("IPv4 address for %s: %s", domain, a[0].address);
|
||||
|
||||
a = getAddressInfo(domain, port, AddressFamily.INET6);
|
||||
|
|
|
|||
14
Task/DNS-query/Erlang/dns-query.erl
Normal file
14
Task/DNS-query/Erlang/dns-query.erl
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
33> {ok, {hostent, Host, Aliases, AddrType, Bytes, AddrList}} = inet:gethostbyname("www.kame.net", inet).
|
||||
{ok,{hostent,"orange.kame.net",
|
||||
["www.kame.net"],
|
||||
inet,4,
|
||||
[{203,178,141,194}]}}
|
||||
34> [inet_parse:ntoa(Addr) || Addr <- AddrList].
|
||||
["203.178.141.194"]
|
||||
35> f().
|
||||
ok
|
||||
36> {ok, {hostent, Host, Aliases, AddrType, Bytes, AddrList}} = inet:gethostbyname("www.kame.net", inet6).
|
||||
{ok,{hostent,"orange.kame.net",[],inet6,16,
|
||||
[{8193,512,3583,65521,534,16127,65201,17623}]}}
|
||||
37> [inet_parse:ntoa(Addr) || Addr <- AddrList].
|
||||
["2001:200:DFF:FFF1:216:3EFF:FEB1:44D7"]
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if addrs, err := net.LookupHost("www.kame.net"); err == nil {
|
||||
fmt.Println(addrs)
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
module Main where
|
||||
|
||||
import Network.Socket
|
||||
|
||||
getWebAddresses :: HostName -> IO [SockAddr]
|
||||
getWebAddresses host = do
|
||||
results <- getAddrInfo (Just defaultHints) (Just host) (Just "http")
|
||||
return [ addrAddress a | a <- results, addrSocketType a == Stream ]
|
||||
|
||||
showIPs :: HostName -> IO ()
|
||||
showIPs host = do
|
||||
putStrLn $ "IP addresses for " ++ host ++ ":"
|
||||
addresses <- getWebAddresses host
|
||||
mapM_ (putStrLn . (" "++) . show) addresses
|
||||
|
||||
main = showIPs "www.kame.net"
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
import java.net.InetAddress;
|
||||
import java.net.Inet4Address;
|
||||
import java.net.Inet6Address;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
class DnsQuery {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
InetAddress[] ipAddr = InetAddress.getAllByName("www.kame.net");
|
||||
for(int i=0; i < ipAddr.length ; i++) {
|
||||
if (ipAddr[i] instanceof Inet4Address) {
|
||||
System.out.println("IPv4 : " + ipAddr[i].getHostAddress());
|
||||
} else if (ipAddr[i] instanceof Inet6Address) {
|
||||
System.out.println("IPv6 : " + ipAddr[i].getHostAddress());
|
||||
}
|
||||
}
|
||||
} catch (UnknownHostException uhe) {
|
||||
System.err.println("unknown host");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref symbols nobinary
|
||||
|
||||
ir = InetAddress
|
||||
addresses = InetAddress[] InetAddress.getAllByName('www.kame.net')
|
||||
loop ir over addresses
|
||||
if ir <= Inet4Address then do
|
||||
say 'IPv4 :' ir.getHostAddress
|
||||
end
|
||||
if ir <= Inet6Address then do
|
||||
say 'IPv6 :' ir.getHostAddress
|
||||
end
|
||||
end ir
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
import java.net.InetAddress;
|
||||
import java.net.Inet4Address;
|
||||
import java.net.Inet6Address;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
class DnsQuery {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
InetAddress[] ipAddr = InetAddress.getAllByName("www.kame.net");
|
||||
for(int i=0; i < ipAddr.length ; i++) {
|
||||
if (ipAddr[i] instanceof Inet4Address) {
|
||||
System.out.println("IPv4 : " + ipAddr[i].getHostAddress());
|
||||
} else if (ipAddr[i] instanceof Inet6Address) {
|
||||
System.out.println("IPv6 : " + ipAddr[i].getHostAddress());
|
||||
}
|
||||
}
|
||||
} catch (UnknownHostException uhe) {
|
||||
System.err.println("unknown host");
|
||||
}
|
||||
}
|
||||
}
|
||||
27
Task/DNS-query/Kotlin/dns-query.kotlin
Normal file
27
Task/DNS-query/Kotlin/dns-query.kotlin
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// version 1.1.3
|
||||
|
||||
import java.net.InetAddress
|
||||
import java.net.Inet4Address
|
||||
import java.net.Inet6Address
|
||||
|
||||
fun showIPAddresses(host: String) {
|
||||
try {
|
||||
val ipas = InetAddress.getAllByName(host)
|
||||
println("The IP address(es) for '$host' is/are:\n")
|
||||
for (ipa in ipas) {
|
||||
print(when (ipa) {
|
||||
is Inet4Address -> " ipv4 : "
|
||||
is Inet6Address -> " ipv6 : "
|
||||
else -> " ipv? : "
|
||||
})
|
||||
println(ipa.hostAddress)
|
||||
}
|
||||
}
|
||||
catch (ex: Exception) {
|
||||
println(ex.message)
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
showIPAddresses("www.kame.net")
|
||||
}
|
||||
9
Task/DNS-query/Perl-6/dns-query.pl6
Normal file
9
Task/DNS-query/Perl-6/dns-query.pl6
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
use Net::DNS;
|
||||
|
||||
my $resolver = Net::DNS.new('8.8.8.8');
|
||||
|
||||
my $ip4 = $resolver.lookup('A', 'orange.kame.net');
|
||||
my $ip6 = $resolver.lookup('AAAA', 'orange.kame.net');
|
||||
|
||||
say $ip4[0].octets.join: '.';
|
||||
say $ip6[0].octets.».fmt("%.2X").join.comb(4).join: ':';
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
irb(main):001:0> require 'socket'
|
||||
=> true
|
||||
irb(main):002:0> Addrinfo.getaddrinfo("www.kame.net", nil, nil, :DGRAM) \
|
||||
irb(main):003:0* .map! { |ai| ai.ip_address }
|
||||
=> ["203.178.141.194", "2001:200:dff:fff1:216:3eff:feb1:44d7"]
|
||||
2
Task/DNS-query/Pike/dns-query.pike
Normal file
2
Task/DNS-query/Pike/dns-query.pike
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
> array ips = Protocols.DNS.gethostbyname("www.kame.net")[1] || ({});
|
||||
> write(ips*"\n");
|
||||
2
Task/DNS-query/PowerShell/dns-query-1.psh
Normal file
2
Task/DNS-query/PowerShell/dns-query-1.psh
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
$DNS = Resolve-DnsName -Name www.kame.net
|
||||
Write-Host "IPv4:" $DNS.IP4Address "`nIPv6:" $DNS.IP6Address
|
||||
16
Task/DNS-query/Rust/dns-query.rust
Normal file
16
Task/DNS-query/Rust/dns-query.rust
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
use std::net::ToSocketAddrs;
|
||||
|
||||
fn main() {
|
||||
let host = "www.kame.net";
|
||||
// Ideally, we would want to use std::net::lookup_host to resolve the host ips,
|
||||
// but at time of writing this, it is still unstable. Fortunately, we can
|
||||
// still resolve using the ToSocketAddrs trait, but we need to add a port,
|
||||
// so we use the dummy port 0.
|
||||
let host_port = (host, 0);
|
||||
let ip_iter = host_port.to_socket_addrs().unwrap();
|
||||
|
||||
|
||||
for ip_port in ip_iter {
|
||||
println!("{}", ip_port.ip());
|
||||
}
|
||||
}
|
||||
2
Task/DNS-query/Zkl/dns-query.zkl
Normal file
2
Task/DNS-query/Zkl/dns-query.zkl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
zkl: Network.TCPClientSocket.addrInfo("www.kame.net")
|
||||
L("orange.kame.net",L("203.178.141.194","2001:200:dff:fff1:216:3eff:feb1:44d7"))
|
||||
Loading…
Add table
Add a link
Reference in a new issue