From: Guus Sliepen Date: Sat, 27 Feb 2016 13:46:01 +0000 (+0100) Subject: Add warnings for bad combinations of Device and Interface. X-Git-Tag: release-1.0.27~18 X-Git-Url: https://tinc-vpn.org/git/browse?a=commitdiff_plain;h=2f03a5d94c0bb6732fd65263217e3aa2b72f18ff;p=tinc Add warnings for bad combinations of Device and Interface. On Linux, the name of the tun/tap interface can be set freely. However, on most other operating systems, tinc cannot change the name of the interface. In those situations, it is possible to specify a Device and an Interface that conflict with each other. On BSD, this can cause $INTERFACE to be set incorrectly, on Windows, this results in a potentially unreliable way in which a TAP-Win32 interface is selected. --- diff --git a/src/bsd/device.c b/src/bsd/device.c index 3e9cfb27..377d4a7b 100644 --- a/src/bsd/device.c +++ b/src/bsd/device.c @@ -75,6 +75,8 @@ static bool setup_device(void) { if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) iface = xstrdup(strrchr(device, '/') ? strrchr(device, '/') + 1 : device); + else if(strcmp(iface, strrchr(device, '/') ? strrchr(device, '/') + 1 : device)) + logger(LOG_WARNING, "Warning: Interface does not match Device. $INTERFACE might be set incorrectly."); if(get_config_string(lookup_config(config_tree, "DeviceType"), &type)) { if(!strcasecmp(type, "tun")) diff --git a/src/cygwin/device.c b/src/cygwin/device.c index b582a6a9..47867a49 100644 --- a/src/cygwin/device.c +++ b/src/cygwin/device.c @@ -61,6 +61,9 @@ static bool setup_device(void) { get_config_string(lookup_config(config_tree, "Device"), &device); get_config_string(lookup_config(config_tree, "Interface"), &iface); + if(device && interface) + logger(LOG_WARNING, "Warning: both Device and Interface specified, results may not be as expected"); + /* Open registry and look for network adapters */ if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, NETWORK_CONNECTIONS_KEY, 0, KEY_READ, &key)) { diff --git a/src/mingw/device.c b/src/mingw/device.c index 49b833ab..b77282ad 100644 --- a/src/mingw/device.c +++ b/src/mingw/device.c @@ -113,6 +113,9 @@ static bool setup_device(void) { get_config_string(lookup_config(config_tree, "Device"), &device); get_config_string(lookup_config(config_tree, "Interface"), &iface); + if(device && interface) + logger(LOG_WARNING, "Warning: both Device and Interface specified, results may not be as expected"); + /* Open registry and look for network adapters */ if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, NETWORK_CONNECTIONS_KEY, 0, KEY_READ, &key)) {