From 42f5331a0c254a9a31ad6b6f575050ba54e7503e Mon Sep 17 00:00:00 2001
From: kr328 <kr328app@outlook.com>
Date: Sat, 22 May 2021 01:26:02 +0800
Subject: [PATCH] Fix: should close TCP/UDP endpoint on exit

---
 core/src/main/golang/tun/tun.go | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/core/src/main/golang/tun/tun.go b/core/src/main/golang/tun/tun.go
index 9ae7d2bb..68d6932d 100644
--- a/core/src/main/golang/tun/tun.go
+++ b/core/src/main/golang/tun/tun.go
@@ -72,6 +72,8 @@ func Start(fd, mtu int, dns string) error {
 	go func() {
 		// lwip tcp
 
+		defer stack.TCP().Close()
+
 		for {
 			conn, err := stack.TCP().Accept()
 			if err != nil {
@@ -94,6 +96,8 @@ func Start(fd, mtu int, dns string) error {
 	go func() {
 		// lwip udp
 
+		defer stack.UDP().Close()
+
 		for {
 			buf := allocUDP(mtu)
 
-- 
GitLab