WireGuard / wgctrl-go

Package wgctrl enables control of WireGuard interfaces on multiple platforms.
https://godoc.org/golang.zx2c4.com/wireguard/wgctrl
MIT License
730 stars 85 forks source link

LatestHandshakeTime is set to Unix epoch zero, not zero-valued time.Time as documented #24

Closed cespare closed 5 years ago

cespare commented 5 years ago

wgtypes.Peer.LastHandshakeTime docs say:

    // A zero-value time.Time indicates that no handshake has taken place with
    // this peer.

However, empirically it seems to use the zero Unix time (i.e., time.Unix(0, 0)), not time.Time{}.

mdlayher commented 5 years ago

Are you using the Linux kernel (genetlink interface) implementation?

Sounds like an oversight on my part. I'll compare what the userspace device and kernel interface send for this situation, but I suspect it'd make sense to make the value a zero-value time.Time since January 1, 1970 is also unlikely to come up in practice.

cespare commented 5 years ago

Are you using the Linux kernel (genetlink interface) implementation?

Yep.

Sounds like an oversight on my part. I'll compare what the userspace device and kernel interface send for this situation, but I suspect it'd make sense to make the value a zero-value time.Time since January 1, 1970 is also unlikely to come up in practice.

Yeah, the solution in #25 is what I had in mind. Thanks.

mdlayher commented 5 years ago

Thanks for the bug report! Let me know if you find anything else that seems off. I'm happy to continue making improvements to both the internals and ergonomics of this package.