At this point, the ioctl success without any error, but no address
appears on the interface.
Turns out telling NDP to not expire helps.
Congrats, yggdrasil is now operational on OpenBSD.
An ioctl request to set an address without gateway address or prefix mask
is rather unproductive.
Reuse code my moving it into a helper function; again the net package
does all the parsing for us.
The net package has all we need and internally repesents addresses
as byte arrays.
<netinet6/in6.h> `struct in6_addr` is just a union over differnt sized
byte arrays, so chosing u_int8_t[16] lets us access addresses byte-wise
and thus no longer need to fiddle with multi-byte values and host vs.
network byte order.
SIOCSIFADDR_IN6 simply does not exist, on no system out there.
SIOCSIFADDR exists, but long ago was deprecated by
SIOCAIFADDR which is IPv4-only, see netintro(4).
SIOCAIFADDR_IN6 is correct, but does uses a different struct,
so bring that in, also.
NB: The reason we have to handroll ioctl(2) ourselves is because
golang.org/sys/unix does ship IPv6 ioctl and/or struct definitions.
That should really be fixed upstream.
Start by deleting stuff we will not need or want in the end.
This also seems to be the only code doing execve(2), which is best
to be prevented from ever being called via pledge(2), but that is another
story (I am already running yggdrasil with pledge(2) and unveil(2)).
The address ioctl code is just plain broken.
I fixed it for OpenBSD, but have no resources or time for FreeBSD,
so there the code will stay as-is.
FreeBSD also supports stuff like netlink, so perhaps a future rewrite
will look different from OpenBSD's ioctl code (the only approach) anyway.
different from
https://github.com/yggdrasil-network/yggdrasil-go/pull/817 in that it
can resolve user names, automatically use user's primary gid & allows
specifying gid in the same argument, with `:` eg `username:groupname`.
feel free to criticize & suggest different argument name & description
because i didn't put much of thought to that.
---------
Co-authored-by: Neil <git@neilalexander.dev>
Co-authored-by: VNAT <xepjk@protonmail.com>
Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
This PR updates Ironwood to include the new RTT-based link costing and
updates `yggdrasilctl` to report the cost in `getPeers`.
Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
So, the function waiting for TUN to come up never succeeds:
```
func waitForTUNUp(ch <-chan wgtun.Event) bool {
t := time.After(time.Second * 5)
for {
select {
case ev := <-ch:
if ev == wgtun.EventUp {
return true
}
case <-t:
return false
}
}
}
```
I've tried the sleep for one second, and it works flawlessly on several
PCs.
Another point - sometimes, if the service stop abruptly (in case of some
errors) there is an old hidden device in the system, that we need to
uninstall, and then create new.
ws:// can be listened and dialed
wss:// is a convenience link for ws:// that supports dialing to ws://
peer.
---------
Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
This PR updates the Wireguard dependency and updates to use new
vectorised reads/writes, which should reduce the number of syscalls and
improve performance.
This will only make a difference on Linux as this is the only platform
for which the Wireguard TUN library supports vectorised reads/writes.
For other platforms, single reads and writes will be performed as usual.
---------
Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>