aboutsummaryrefslogtreecommitdiff
path: root/cmd/example/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/example/main.go')
-rw-r--r--cmd/example/main.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/cmd/example/main.go b/cmd/example/main.go
new file mode 100644
index 0000000..383e490
--- /dev/null
+++ b/cmd/example/main.go
@@ -0,0 +1,31 @@
+package main
+
+import (
+ "fmt"
+ "iptcp/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())
+
+ fmt.Printf(iface.UDPAddr.String() + "\n")
+ fmt.Printf(iface.AssignedIP.String() + "\n")
+ }
+}