]> www.infradead.org Git - users/dwmw2/openconnect.git/commit
Use hostname as Wintun ifname (if ifname not specified), v2
authorMarios Paouris <mspaourh@gmail.com>
Mon, 7 Oct 2024 05:53:35 +0000 (08:53 +0300)
committerMarios Paouris <mspaourh@gmail.com>
Tue, 5 Nov 2024 07:16:50 +0000 (09:16 +0200)
commitf359a42a91fb925f37b2ca4e7157acda9a4794ee
tree347ac109f3049dae99b60a947a8b4434910c96c6
parent136ffea0bbd2545a1392510daa58d6acdee6bdba
Use hostname as Wintun ifname (if ifname not specified), v2

The intention for the commit 48bd28aa was a bit different
from what was actually implemented.

Although it states that "Instead, we should use the VPN server's hostname
as a sane default interface name with Wintun, and only attempt to use
TAP-Windows as a fallback in the case where Wintun can't be initialized.",
it first tries with an empty interface name, which uses the first available
interface found, whether it is tap or tun, and if that fails then creates
the same default with the server name, which will prioritize wintun over
tap.

Instead, implement the following flow:

If the user did specify an interface name:
  - Try to find an adapter with the specified name (whether it's tun
    or tap) and use it.
  - If no adapter found, try to create a wintun adapter. If wintun is
    not available then bail out.
If the user did not specify an interface name:
  - Generate a default interface name based on the server URL.
  - If the generated interface already exists don't try to use it
    and fallback to using the first available adapter.
  - If the generated interface doesn't exist, try to create a wintun
    adapter. If wintun in not available then fallback to using the first
    available adapter.

See https://gitlab.com/openconnect/openconnect-gui/-/issues/357#note_1758999655
and https://gitlab.com/openconnect/openconnect/-/issues/699#note_1762029017

Signed-off-by: Marios Paouris <mspaourh@gmail.com>
tests/list-taps.c
tests/wintun-names.c
tun-win32.c
wintun.c