diff options
author | sotech117 <michael_foiani@brown.edu> | 2023-10-08 23:05:53 -0400 |
---|---|---|
committer | sotech117 <michael_foiani@brown.edu> | 2023-10-08 23:05:53 -0400 |
commit | 4966c054b3f462f6eaf24591c4ab1a945e72bb6f (patch) | |
tree | b33ce376ceeadaecb926f0daa841f6d11f56442f /cmd | |
parent | 5a5dec572c01a7d306c3bdd3fd0ad8cec63c6049 (diff) |
fix heiarchy. rewrite routing table code
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/example/main.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/cmd/example/main.go b/cmd/example/main.go new file mode 100644 index 0000000..5b6ae61 --- /dev/null +++ b/cmd/example/main.go @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "iptcp-jailpt2/pkg/lnxconfig" + "net/netip" + "os" +) + +func main() { + if len(os.Args) != 2 { + fmt.Printf("Usage: %s <configFile>\n", os.Args[0]) + os.Exit(1) + } + fileName := os.Args[1] + + // Parse the file + lnxConfig, err := lnxconfig.ParseConfig(fileName) + if err != nil { + panic(err) + } + + // Demo: print out the IP for each interface in this config + for _, iface := range lnxConfig.Interfaces { + prefixForm := netip.PrefixFrom(iface.AssignedIP, iface.AssignedPrefix.Bits()) + fmt.Printf("%s has IP %s\n", iface.Name, prefixForm.String()) + } +} |