refactor: merge dnsx and errorsx into netxlite (#517)
When preparing a tutorial for netxlite, I figured it is easier to tell people "hey, this is the package you should use for all low-level networking stuff" rather than introducing people to a set of packages working together where some piece of functionality is here and some other piece is there. Part of https://github.com/ooni/probe/issues/1591
This commit is contained in:
parent
de130d249c
commit
6d3a4f1db8
169 changed files with 575 additions and 671 deletions
|
|
@ -9,7 +9,6 @@ import (
|
|||
"sync"
|
||||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/quicx"
|
||||
)
|
||||
|
||||
|
|
@ -360,8 +359,7 @@ var _ QUICListener = &quicListenerErrWrapper{}
|
|||
func (qls *quicListenerErrWrapper) Listen(addr *net.UDPAddr) (quicx.UDPLikeConn, error) {
|
||||
pconn, err := qls.QUICListener.Listen(addr)
|
||||
if err != nil {
|
||||
return nil, errorsx.NewErrWrapper(
|
||||
errorsx.ClassifyGenericError, errorsx.QUICListenOperation, err)
|
||||
return nil, NewErrWrapper(ClassifyGenericError, QUICListenOperation, err)
|
||||
}
|
||||
return &quicErrWrapperUDPLikeConn{pconn}, nil
|
||||
}
|
||||
|
|
@ -378,8 +376,7 @@ var _ quicx.UDPLikeConn = &quicErrWrapperUDPLikeConn{}
|
|||
func (c *quicErrWrapperUDPLikeConn) WriteTo(p []byte, addr net.Addr) (int, error) {
|
||||
count, err := c.UDPLikeConn.WriteTo(p, addr)
|
||||
if err != nil {
|
||||
return 0, errorsx.NewErrWrapper(
|
||||
errorsx.ClassifyGenericError, errorsx.WriteToOperation, err)
|
||||
return 0, NewErrWrapper(ClassifyGenericError, WriteToOperation, err)
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
|
|
@ -388,8 +385,7 @@ func (c *quicErrWrapperUDPLikeConn) WriteTo(p []byte, addr net.Addr) (int, error
|
|||
func (c *quicErrWrapperUDPLikeConn) ReadFrom(b []byte) (int, net.Addr, error) {
|
||||
n, addr, err := c.UDPLikeConn.ReadFrom(b)
|
||||
if err != nil {
|
||||
return 0, nil, errorsx.NewErrWrapper(
|
||||
errorsx.ClassifyGenericError, errorsx.ReadFromOperation, err)
|
||||
return 0, nil, NewErrWrapper(ClassifyGenericError, ReadFromOperation, err)
|
||||
}
|
||||
return n, addr, nil
|
||||
}
|
||||
|
|
@ -398,8 +394,7 @@ func (c *quicErrWrapperUDPLikeConn) ReadFrom(b []byte) (int, net.Addr, error) {
|
|||
func (c *quicErrWrapperUDPLikeConn) Close() error {
|
||||
err := c.UDPLikeConn.Close()
|
||||
if err != nil {
|
||||
return errorsx.NewErrWrapper(
|
||||
errorsx.ClassifyGenericError, errorsx.ReadFromOperation, err)
|
||||
return NewErrWrapper(ClassifyGenericError, ReadFromOperation, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -415,8 +410,8 @@ func (d *quicDialerErrWrapper) DialContext(
|
|||
tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlySession, error) {
|
||||
sess, err := d.QUICDialer.DialContext(ctx, network, host, tlsCfg, cfg)
|
||||
if err != nil {
|
||||
return nil, errorsx.NewErrWrapper(
|
||||
errorsx.ClassifyQUICHandshakeError, errorsx.QUICHandshakeOperation, err)
|
||||
return nil, NewErrWrapper(
|
||||
ClassifyQUICHandshakeError, QUICHandshakeOperation, err)
|
||||
}
|
||||
return sess, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue