From 201e79ac718d3d421e3c300e6917d2c9478e6719 Mon Sep 17 00:00:00 2001 From: xjasonlyu Date: Tue, 29 Mar 2022 13:22:50 +0800 Subject: [PATCH] Fix: nil options panic --- component/dialer/sockopt_darwin.go | 2 +- component/dialer/sockopt_linux.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/component/dialer/sockopt_darwin.go b/component/dialer/sockopt_darwin.go index 7aea95a..659a963 100644 --- a/component/dialer/sockopt_darwin.go +++ b/component/dialer/sockopt_darwin.go @@ -23,7 +23,7 @@ func resolveInterfaceByName(name string) (*net.Interface, error) { } func setSocketOptions(network, address string, c syscall.RawConn, opts *Options) (err error) { - if !isTCPSocket(network) && !isUDPSocket(network) { + if opts == nil || !isTCPSocket(network) && !isUDPSocket(network) { return } diff --git a/component/dialer/sockopt_linux.go b/component/dialer/sockopt_linux.go index 0dd5217..f3eb849 100644 --- a/component/dialer/sockopt_linux.go +++ b/component/dialer/sockopt_linux.go @@ -8,7 +8,7 @@ import ( ) func setSocketOptions(network, address string, c syscall.RawConn, opts *Options) (err error) { - if !isTCPSocket(network) && !isUDPSocket(network) { + if opts == nil || !isTCPSocket(network) && !isUDPSocket(network) { return }