mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 23:47:07 -05:00
fix crash when tun app has no socket option
This commit is contained in:
parent
263fbf5765
commit
e87af12bf8
@ -55,9 +55,11 @@ func SetTCPHandler(ctx context.Context, dispatcher routing.Dispatcher, policyMan
|
||||
}
|
||||
defer r.Complete(false)
|
||||
|
||||
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{
|
||||
TCPConn: gonet.NewTCPConn(wg, linkedEndpoint),
|
||||
|
@ -39,6 +39,7 @@ func (t *TUN) CreateStack(linkedEndpoint stack.LinkEndpoint) (*stack.Stack, erro
|
||||
SetSpoofing(nicID, t.config.EnableSpoofing),
|
||||
}
|
||||
|
||||
if t.config.SocketSettings != nil {
|
||||
if size := t.config.SocketSettings.TxBufSize; size != 0 {
|
||||
opts = append(opts, SetTCPSendBufferSize(int(size)))
|
||||
}
|
||||
@ -46,6 +47,7 @@ func (t *TUN) CreateStack(linkedEndpoint stack.LinkEndpoint) (*stack.Stack, erro
|
||||
if size := t.config.SocketSettings.RxBufSize; size != 0 {
|
||||
opts = append(opts, SetTCPReceiveBufferSize(int(size)))
|
||||
}
|
||||
}
|
||||
|
||||
for _, opt := range opts {
|
||||
if err := opt(s); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user