Time for an 2014 update…
This commit is contained in:
parent
372c577f83
commit
09687c4926
2520 changed files with 34227 additions and 7318 deletions
14
Task/DNS-query/Go/dns-query.go
Normal file
14
Task/DNS-query/Go/dns-query.go
Normal 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)
|
||||
}
|
||||
}
|
||||
3
Task/DNS-query/Groovy/dns-query-1.groovy
Normal file
3
Task/DNS-query/Groovy/dns-query-1.groovy
Normal 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}"
|
||||
16
Task/DNS-query/Groovy/dns-query-2.groovy
Normal file
16
Task/DNS-query/Groovy/dns-query-2.groovy
Normal 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"
|
||||
21
Task/DNS-query/Groovy/dns-query-3.groovy
Normal file
21
Task/DNS-query/Groovy/dns-query-3.groovy
Normal 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
16
Task/DNS-query/REXX/dns-query.rexx
Normal file
16
Task/DNS-query/REXX/dns-query.rexx
Normal 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.*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue