Data update
This commit is contained in:
parent
8e4e15fa56
commit
72eb4943cb
1853 changed files with 35514 additions and 9441 deletions
|
|
@ -1,9 +0,0 @@
|
|||
/* DNS_query.wren */
|
||||
|
||||
class Net {
|
||||
foreign static lookupHost(host)
|
||||
}
|
||||
|
||||
var host = "orange.kame.net"
|
||||
var addrs = Net.lookupHost(host).split(", ")
|
||||
System.print(addrs.join("\n"))
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
/* go run DNS_query.go */
|
||||
|
||||
package main
|
||||
|
||||
import(
|
||||
wren "github.com/crazyinfin8/WrenGo"
|
||||
"net"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type any = interface{}
|
||||
|
||||
func lookupHost(vm *wren.VM, parameters []any) (any, error) {
|
||||
host := parameters[1].(string)
|
||||
addrs, err := net.LookupHost(host)
|
||||
if err != nil {
|
||||
return nil, nil
|
||||
}
|
||||
return strings.Join(addrs, ", "), nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
vm := wren.NewVM()
|
||||
fileName := "DNS_query.wren"
|
||||
methodMap := wren.MethodMap{"static lookupHost(_)": lookupHost}
|
||||
classMap := wren.ClassMap{"Net": wren.NewClass(nil, nil, methodMap)}
|
||||
module := wren.NewModule(classMap)
|
||||
vm.SetModule(fileName, module)
|
||||
vm.InterpretFile(fileName)
|
||||
vm.Free()
|
||||
}
|
||||
18
Task/DNS-query/Wren/dns-query.wren
Normal file
18
Task/DNS-query/Wren/dns-query.wren
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import "os" for Process
|
||||
|
||||
var domainName = "www.kame.net"
|
||||
System.print(domainName)
|
||||
var ipvs = ["IPv4", "IPv6"]
|
||||
var args = ["A", "AAAA"]
|
||||
for (i in 0..1) {
|
||||
var cmd = "nslookup -querytype=%(args[i]) %(domainName)"
|
||||
var lines = Process.read(cmd).split("\n")
|
||||
var addresses = []
|
||||
for (line in lines.skip(3)) {
|
||||
if (line.startsWith("Address:")) {
|
||||
var address = line[8..-1].trim()
|
||||
addresses.add(address)
|
||||
}
|
||||
}
|
||||
for (address in addresses) System.print("%(ipvs[i]): %(address)")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue