Browse Source

initial commit

main
Nicolas Massé 5 years ago
commit
fe4bda67a7
  1. 10
      build.sh
  2. 32
      main.go
  3. 4
      run.sh

10
build.sh

@ -0,0 +1,10 @@
#!/bin/sh
go build -o dnstiming main.go
container=$(buildah from fedora:33)
mnt=$(buildah mount $container)
cp dnstiming $mnt
chmod 755 $mnt/dnstiming
buildah config --cmd /dnstiming $container
buildah commit $container dnstiming
buildah unmount $container

32
main.go

@ -0,0 +1,32 @@
package main
import (
"fmt"
"net"
"os"
"time"
)
func main() {
if len(os.Args) != 2 {
fmt.Printf("Usage: %s hostname\n", os.Args[0])
os.Exit(1)
}
start := time.Now()
addrs, err := net.LookupHost(os.Args[1])
end := time.Now()
elapsed := end.Sub(start)
if err != nil {
fmt.Println(err)
os.Exit(2)
}
for _, addr := range addrs {
fmt.Println(addr)
}
fmt.Println()
fmt.Printf("Elapsed: %d ms\n", elapsed.Milliseconds())
}

4
run.sh

@ -0,0 +1,4 @@
#!/bin/sh
podman run --rm --name fedora -d fedora sleep 60
podman run --rm --name dnstiming -t dnstiming /dnstiming fedora
Loading…
Cancel
Save