Time for an 2014 update…

This commit is contained in:
Ingy döt Net 2014-01-17 05:32:22 +00:00
parent 372c577f83
commit 09687c4926
2520 changed files with 34227 additions and 7318 deletions

View file

@ -0,0 +1,14 @@
package main
import (
"fmt"
"net"
)
func main() {
if addrs, err := net.LookupHost("www.kame.net"); err == nil {
fmt.Println(addrs)
} else {
fmt.Println(err)
}
}

View file

@ -0,0 +1,3 @@
def addresses = InetAddress.getAllByName('www.kame.net')
println "IPv4: ${addresses.find { it instanceof Inet4Address }?.hostAddress}"
println "IPv6: ${addresses.find { it instanceof Inet6Address }?.hostAddress}"

View file

@ -0,0 +1,16 @@
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"

View file

@ -0,0 +1,21 @@
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");
}
}
}

View file

@ -0,0 +1,16 @@
/*REXX pgm displays IPv4 and IPv6 addresses for a supplied domain name. */
trace off /*don't show the PING return code*/
parse arg dn . /*get the optional domain name. */
if dn=='' then dn='www.kame.net' /*Not specified? Then use default*/
tmp='\TEMP\TEMP.PING' /*define temp file to store IPv4.*/
do j=4 to 6 by 2 /*handle IPv4 and IPv6 addresses.*/
'PING' (-j) '-l 0 -n 1' dn ">" tmp /*restrict PING's output to min. */
q=charin(tmp,1,999) /*read output file from PING cmd.*/
parse var q '[' IPA ']' /*parse IP a ddress from output.*/
say 'IPv'j 'for domain name ' dn " is " IPA /*IPv4 | IPv6 addr.*/
call lineout tmp /*needed by most REXXes to force */
end /*j*/ /* [↑] file integrity. */
'ERASE' tmp /*clean up the temporary file. */
/*stick a fork in it, we're done.*/