diff --git a/app/tun/handler_tcp.go b/app/tun/handler_tcp.go index 3102ad8df..e40f0789a 100644 --- a/app/tun/handler_tcp.go +++ b/app/tun/handler_tcp.go @@ -55,8 +55,10 @@ func SetTCPHandler(ctx context.Context, dispatcher routing.Dispatcher, policyMan } defer r.Complete(false) - if err := applySocketOptions(s, linkedEndpoint, config.SocketSettings); err != nil { - newError("failed to apply socket options: ", err).WriteToLog(session.ExportIDToError(ctx)) + if config.SocketSettings != nil { + if err := applySocketOptions(s, linkedEndpoint, config.SocketSettings); err != nil { + newError("failed to apply socket options: ", err).WriteToLog(session.ExportIDToError(ctx)) + } } conn := &tcpConn{ diff --git a/app/tun/stack.go b/app/tun/stack.go index ee28e0105..4b104a95e 100644 --- a/app/tun/stack.go +++ b/app/tun/stack.go @@ -39,12 +39,14 @@ func (t *TUN) CreateStack(linkedEndpoint stack.LinkEndpoint) (*stack.Stack, erro SetSpoofing(nicID, t.config.EnableSpoofing), } - if size := t.config.SocketSettings.TxBufSize; size != 0 { - opts = append(opts, SetTCPSendBufferSize(int(size))) - } + if t.config.SocketSettings != nil { + if size := t.config.SocketSettings.TxBufSize; size != 0 { + opts = append(opts, SetTCPSendBufferSize(int(size))) + } - if size := t.config.SocketSettings.RxBufSize; size != 0 { - opts = append(opts, SetTCPReceiveBufferSize(int(size))) + if size := t.config.SocketSettings.RxBufSize; size != 0 { + opts = append(opts, SetTCPReceiveBufferSize(int(size))) + } } for _, opt := range opts {