diff --git a/default.nix b/default.nix index 81752db..2b7e29c 100644 --- a/default.nix +++ b/default.nix @@ -1,9 +1,17 @@ -{ buildGoModule, ... }: +{ lib, buildGoModule }: buildGoModule { pname = "ipwatch"; version = "0.2.3"; - src = ./.; - vendorHash = "sha256-VG1ZVwO78KUqyQpQw8hbjJm6AxvudoiNQbjYevd+qj8="; + src = lib.fileset.toSource { + root = ./.; + fileset = lib.fileset.unions [ + ./go.mod + ./go.sum + ./cmd + ./ipwatch + ]; + }; + vendorHash = "sha256-SG/XqEXKTqmWbfe4H9+yVDp4YKicm2fP+tVV5bCtIpk="; ldflags = [ "-s" "-w" diff --git a/go.mod b/go.mod index bdf9dc2..aa5b163 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.21 toolchain go1.21.3 require ( + github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf github.com/mdlayher/netlink v1.7.2 golang.org/x/sys v0.26.0 ) diff --git a/go.sum b/go.sum index 87d8993..e825d81 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf h1:iW4rZ826su+pqaw19uhpSCzhj44qo35pNgKFGqzDKkU= +github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA= diff --git a/ipwatch/ipwatch.go b/ipwatch/ipwatch.go index cb0aefe..e5f7a79 100644 --- a/ipwatch/ipwatch.go +++ b/ipwatch/ipwatch.go @@ -15,6 +15,7 @@ import ( "time" "unsafe" + systemdDaemon "github.com/coreos/go-systemd/daemon" "github.com/mdlayher/netlink" "golang.org/x/sys/unix" ) @@ -456,6 +457,8 @@ func (w *Watcher) Watch(cfg WatchConfig) error { ) } + systemdDaemon.SdNotify(false, systemdDaemon.SdNotifyReady) + w.log.Println("Opening netlink socket") conn, err := netlink.Dial(unix.NETLINK_ROUTE, &netlink.Config{ Groups: unix.RTMGRP_IPV4_IFADDR | unix.RTMGRP_IPV6_IFADDR,