summaryrefslogtreecommitdiffhomepage
path: root/tunnel/tools/libwg-go/dhcp.go
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2023-06-02 22:50:10 +0200
committerMikael Magnusson <mikma@users.sourceforge.net>2023-10-26 23:10:49 +0200
commit7f58506d3eaff8c26fad336a6fc3caa97e287dd3 (patch)
tree839db63a8b122f95f8d0e1cd0f5a277e92160c2e /tunnel/tools/libwg-go/dhcp.go
parent5f6e909e610147c9f0d38e72457c79896c3e3e04 (diff)
tunnel: renew DHCP leases
* Add valid and preferred lifetime to dhcp leases * Delay renew until VPN network is available
Diffstat (limited to 'tunnel/tools/libwg-go/dhcp.go')
-rw-r--r--tunnel/tools/libwg-go/dhcp.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/tunnel/tools/libwg-go/dhcp.go b/tunnel/tools/libwg-go/dhcp.go
index b7919151..4af5b0cb 100644
--- a/tunnel/tools/libwg-go/dhcp.go
+++ b/tunnel/tools/libwg-go/dhcp.go
@@ -12,6 +12,7 @@ import (
"github.com/insomniacslk/dhcp/iana"
gen "golang.zx2c4.com/wireguard/android/gen"
+ "google.golang.org/protobuf/types/known/durationpb"
)
const (
@@ -131,13 +132,13 @@ func getAddressesFromReply(reply *dhcpv6.Message) []*gen.Lease{
ianaOpts := iana.Options.Get(dhcpv6.OptionIAAddr)
for _, opt := range ianaOpts {
- addr :=opt.(*dhcpv6.OptIAAddress).IPv6Addr
+ addrOpt := opt.(*dhcpv6.OptIAAddress)
lease := &gen.Lease{
Address: &gen.InetAddress{
- Address: addr,
+ Address: addrOpt.IPv6Addr,
},
- // PreferredLifetime: ,
- // ValidLifetime: ,
+ PreferredLifetime: durationpb.New(addrOpt.PreferredLifetime),
+ ValidLifetime: durationpb.New(addrOpt.ValidLifetime),
}
leases = append(leases, lease)
}