mirror of
https://github.com/soypat/lneto.git
synced 2026-08-21 06:59:04 +00:00
Error rewrites (#43)
* pcap: reuse Frame memory * slog: reduce heap allocations of addresses; also prevent heap alloc of dhcp options in pcap * dns: heapless improvement; add StackAsync buffer for more heapless operation; start thinking of errors * errors: begin standardise errors in lneto * errors: finish standardization of errors * fix merge issues * add more lneto errors to rest of package * format errors.go
This commit is contained in:
@@ -2,12 +2,12 @@ package xnet
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net"
|
||||
"net/netip"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/soypat/lneto"
|
||||
"github.com/soypat/lneto/tcp"
|
||||
)
|
||||
|
||||
@@ -36,7 +36,7 @@ func (s StackBerkeley) Socket(ctx context.Context, network string, family, sotyp
|
||||
switch family {
|
||||
case syscall.AF_INET:
|
||||
default:
|
||||
return nil, errors.New("unsupported address family")
|
||||
return nil, lneto.ErrUnsupported
|
||||
}
|
||||
var local, remote netip.AddrPort
|
||||
if laddr != nil {
|
||||
@@ -54,10 +54,10 @@ func (s StackBerkeley) Socket(ctx context.Context, network string, family, sotyp
|
||||
|
||||
switch network {
|
||||
case "udp", "udp4":
|
||||
return nil, errors.New("udp not yet supported")
|
||||
return nil, lneto.ErrUnsupported
|
||||
case "tcp", "tcp4":
|
||||
if sotype != sockSTREAM {
|
||||
return nil, errors.New("unsupported socket type")
|
||||
return nil, lneto.ErrUnsupported
|
||||
}
|
||||
|
||||
if raddr != nil {
|
||||
@@ -106,7 +106,7 @@ func (s StackBerkeley) Socket(ctx context.Context, network string, family, sotyp
|
||||
return &l, nil
|
||||
}
|
||||
}
|
||||
return nil, errors.New("unsupported network")
|
||||
return nil, lneto.ErrUnsupported
|
||||
}
|
||||
|
||||
type tcplistener struct {
|
||||
|
||||
Reference in New Issue
Block a user