fix(sockopts): error handling in applyToUDPConn

This commit is contained in:
Haruue 2024-04-05 13:17:21 +08:00
parent 297d64e48f
commit 5bebfd5732
No known key found for this signature in database
GPG key ID: F6083B28CBCBC148

View file

@ -58,18 +58,21 @@ func (o *SocketOptions) applyToUDPConn(c *net.UDPConn) (err error) {
err = bindInterfaceFunc(c, *o.BindInterface)
if err != nil {
err = fmt.Errorf("failed to bind to interface: %w", err)
return
}
}
if o.FirewallMark != nil && firewallMarkFunc != nil {
err = firewallMarkFunc(c, *o.FirewallMark)
if err != nil {
err = fmt.Errorf("failed to set fwmark: %w", err)
return
}
}
if o.FdControlUnixSocket != nil && fdControlUnixSocketFunc != nil {
err = fdControlUnixSocketFunc(c, *o.FdControlUnixSocket)
if err != nil {
err = fmt.Errorf("failed to send fd to control unix socket: %w", err)
return
}
}
return