]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commit
Kit: Adapter: iterate through all FDs to find UTUN
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 16 Jun 2021 13:56:21 +0000 (15:56 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Wed, 16 Jun 2021 13:56:21 +0000 (15:56 +0200)
commit7f5ad3e503f231893dc5d298f703c4b72b83bdb9
treed2b68174c2af236d5181dcc7cac0248c9e37f716
parent820fa55380b529704945b32e5d990f690c03b2e2
Kit: Adapter: iterate through all FDs to find UTUN

This is a bit of a kludge, until I find something better. We simply
iterate through all FDs, and call getsockopt on each one until we find
the utun FD. This works, and completes rather quickly (fd is usually 6
or 7). Rather than maintain the old path for older kernels, just use
this for all versions, to get more coverage. Other techniques involve
undocumented APIs; this one has the advantage of using nothing
undocumented.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Sources/WireGuardKit/WireGuardAdapter.swift