From 77a1e3a6532e3892dc061a98e85b302d9bc6cc56 Mon Sep 17 00:00:00 2001 From: Dreamacro <8615343+Dreamacro@users.noreply.github.com> Date: Thu, 30 Jun 2022 17:27:38 +0800 Subject: [PATCH] Chore: cleanup bind mark code --- component/dialer/mark_linux.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/component/dialer/mark_linux.go b/component/dialer/mark_linux.go index e54873b..759097d 100644 --- a/component/dialer/mark_linux.go +++ b/component/dialer/mark_linux.go @@ -31,13 +31,13 @@ func bindMarkToControl(mark int, chain controlFn) controlFn { } } - return c.Control(func(fd uintptr) { - switch network { - case "tcp4", "udp4": - syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_MARK, mark) - case "tcp6", "udp6": - syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_MARK, mark) - } + var innerErr error + err = c.Control(func(fd uintptr) { + innerErr = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_MARK, mark) }) + if innerErr != nil { + err = innerErr + } + return } }