Skip to content

Commit

Permalink
Check CLI arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
corny committed Nov 7, 2017
1 parent 3bdce6d commit 76e0314
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmd/dhclient/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"log"
"net"
"os"
Expand All @@ -13,12 +14,18 @@ import (
func main() {
log.SetFlags(log.Ltime | log.Lshortfile)

if len(os.Args) != 2 {
fmt.Println("syntax:", os.Args[0], "IFNAME")
os.Exit(1)
}

hostname, _ := os.Hostname()
ifname := os.Args[1]

iface, err := net.InterfaceByName(ifname)
if err != nil {
panic(err)
fmt.Printf("unable to find interface %s: %s\n", ifname, err)
os.Exit(1)
}

client := dhclient.Client{
Expand Down

0 comments on commit 76e0314

Please sign in to comment.