[Openvpn-devel,3/3] netsh: Delete WINS servers on TUN close

Message ID 20200924064452.1001-3-simon@rozman.si
State Accepted
Headers show
Series
  • [Openvpn-devel,1/3] netsh: Specify interfaces by index rather than name
Related show

Commit Message

Simon Rozman via Openvpn-devel Sept. 24, 2020, 6:44 a.m.
Signed-off-by: Simon Rozman <simon@rozman.si>
---
 src/openvpn/tun.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Lev Stipakov Sept. 24, 2020, 9:24 a.m. | #1
Hi,

> +                    "%s%s interface ipv4 delete winsservers %lu all",

For DNS we use "dns", so it would be nice to unify it - either use
dnsservers/winsservers or dns/wins. But that could be done later.

Code makes sense, compiled/tested on MSVC/Win10.

Acked-by: Lev Stipakov <lstipakov@gmail.com>
Gert Doering Sept. 24, 2020, 11:38 a.m. | #2
Your patch has been applied to the master and release/2.5 branch.

I have not tested this at all (no WINS infra), but "it looks 
reasonable and compiles" (Ubuntu 18, mingw).

commit 370395b3348c4307cdea955abaa36ba315cc128e (master)
commit b77fc7121003d988eaa3eaeef2ec46bff73202cf (release/2.5)
Author: Simon Rozman via Openvpn-devel
Date:   Thu Sep 24 08:44:52 2020 +0200

     netsh: Delete WINS servers on TUN close

     Signed-off-by: Simon Rozman <simon@rozman.si>
     Acked-by: Lev Stipakov <lstipakov@gmail.com>
     Message-Id: <20200924064452.1001-3-simon@rozman.si>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21075.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index b1cd7a1b..80ae6958 100644
--- a/src/openvpn/tun.c
+++ b/src/openvpn/tun.c
@@ -6706,6 +6706,16 @@  netsh_delete_address_dns(const struct tuntap *tt, bool ipv6, struct gc_arena *gc
         netsh_command(&argv, 1, M_WARN);
     }
 
+    if (!ipv6 && tt->options.wins_len > 0)
+    {
+        argv_printf(&argv,
+                    "%s%s interface ipv4 delete winsservers %lu all",
+                    get_win_sys_path(),
+                    NETSH_PATH_SUFFIX,
+                    tt->adapter_index);
+        netsh_command(&argv, 1, M_WARN);
+    }
+
     if (ipv6 && tt->type == DEV_TYPE_TUN)
     {
         delete_route_connected_v6_net(tt);