Skip to content

Commit

Permalink
Fix the error types.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbruens committed Dec 16, 2024
1 parent f7b5d75 commit 85b8d1e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion service/udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (h *packetHandler) Handle(clientConn net.PacketConn) {

udpConn, err := h.targetListener.ListenPacket(context.Background())
if err != nil {
return nil
return onet.NewConnectionError("ERR_CREATE_SOCKET", "Failed to create a `PacketConn`", err)
}

targetConn = nm.Add(clientAddr, clientConn, cryptoKey, udpConn, keyID)
Expand Down
5 changes: 2 additions & 3 deletions service/udp_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"net"

"github.com/Jigsaw-Code/outline-sdk/transport"
onet "github.com/Jigsaw-Code/outline-ss-server/net"
)

type udpListener struct {
Expand All @@ -41,7 +40,7 @@ func MakeTargetUDPListener(fwmark uint) transport.PacketListener {
func (ln *udpListener) ListenPacket(ctx context.Context) (net.PacketConn, error) {
conn, err := net.ListenUDP("udp", nil)
if err != nil {
return nil, onet.NewConnectionError("ERR_CREATE_SOCKET", "Failed to create UDP socket", err)
return nil, fmt.Errorf("Failed to create UDP socket: %w", err)
}

if ln.fwmark > 0 {
Expand All @@ -54,7 +53,7 @@ func (ln *udpListener) ListenPacket(ctx context.Context) (net.PacketConn, error)
err = SetFwmark(rawConn, ln.fwmark)
if err != nil {
conn.Close()
return nil, onet.NewConnectionError("ERR_CREATE_SOCKET", "Failed to set `fwmark`", err)
return nil, fmt.Errorf("Failed to set `fwmark`: %w", err)

}
}
Expand Down

0 comments on commit 85b8d1e

Please sign in to comment.