Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
9
Task/DNS-query/Wren/dns-query-1.wren
Normal file
9
Task/DNS-query/Wren/dns-query-1.wren
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
/* 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"))
|
||||
31
Task/DNS-query/Wren/dns-query-2.wren
Normal file
31
Task/DNS-query/Wren/dns-query-2.wren
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/* 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()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue