From ec75161b687f02b91026439d7228f21c4464c710 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 11 Apr 2023 15:24:43 -0500 Subject: [PATCH] works against gocui Signed-off-by: Jeff Carr --- net.go | 1 - netlink.go | 66 ------------------------------------------------------ unix.go | 2 -- 3 files changed, 69 deletions(-) delete mode 100644 netlink.go diff --git a/net.go b/net.go index 58970e4..fb3b417 100644 --- a/net.go +++ b/net.go @@ -4,7 +4,6 @@ package main import ( "net" "strings" - // "git.wit.org/wit/gui" ) var DEBUGNET bool = false diff --git a/netlink.go b/netlink.go deleted file mode 100644 index 7d3c3f5..0000000 --- a/netlink.go +++ /dev/null @@ -1,66 +0,0 @@ -package main - -// examples of what ifconfig does -// example of AF_NETLINK change: -// https://stackoverflow.com/questions/579783/how-to-detect-ip-address-change-programmatically-in-linux/2353441#2353441 -// from that page, a link to watch for any ip event: -// https://github.com/angt/ipevent/blob/master/ipevent.c - -// https://github.com/mdlayher/talks : Linux, Netlink, and Go in 7 minutes or less! (GopherCon 2018, lightning talk) - -/* - c example from ipevent.c : - int fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE); - - struct sockaddr_nl snl = { - .nl_family = AF_NETLINK, - .nl_groups = RTMGRP_IPV4_IFADDR | RTMGRP_IPV6_IFADDR, - }; -*/ - -/* -import ( -// "os" -// "os/exec" - // "log" - // "net" - // "unix" - "github.com/vishvananda/netlink" - "github.com/jsimonetti/rtnetlink" -// "git.wit.org/wit/gui" -// "github.com/davecgh/go-spew/spew" -) - -// In golang, write a function to register with netlink to detect changes to any network interface Use tab indentation. Do not include example usage. - -func registerNetlink() error { - // Create netlink socket - sock, err := netlink.Socket(rtnetlink.NETLINK_ROUTE, 0) - if err != nil { - return err - } - // Register for interface change events - err = netlink.AddMembership(sock, netlink.RTNLGRP_LINK) - if err != nil { - return err - } - // Close the socket - defer sock.Close() - // Handle incoming notifications - for { - msgs, _, err := sock.Receive() - if err != nil { - return err - } - for _, msg := range msgs { - switch msg.Header.Type { - case unix.RTM_NEWLINK: - // Do something with new link - case unix.RTM_DELLINK: - // Do something with deleted link - } - } - } - return nil -} -*/ diff --git a/unix.go b/unix.go index 09635d8..3660095 100644 --- a/unix.go +++ b/unix.go @@ -8,8 +8,6 @@ import ( "os" "os/exec" "net" -// "git.wit.org/wit/gui" -// "github.com/davecgh/go-spew/spew" ) func CheckSuperuser() bool {