mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-05-14 00:51:12 +03:00
Fix naive quic error message
This commit is contained in:
@@ -29,7 +29,10 @@ import (
|
|||||||
"golang.org/x/net/http2/h2c"
|
"golang.org/x/net/http2/h2c"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ConfigureHTTP3ListenerFunc func(ctx context.Context, logger logger.Logger, listener *listener.Listener, handler http.Handler, tlsConfig tls.ServerConfig, options option.NaiveInboundOptions) (io.Closer, error)
|
var (
|
||||||
|
ConfigureHTTP3ListenerFunc func(ctx context.Context, logger logger.Logger, listener *listener.Listener, handler http.Handler, tlsConfig tls.ServerConfig, options option.NaiveInboundOptions) (io.Closer, error)
|
||||||
|
WrapError func(error) error
|
||||||
|
)
|
||||||
|
|
||||||
func RegisterInbound(registry *inbound.Registry) {
|
func RegisterInbound(registry *inbound.Registry) {
|
||||||
inbound.Register[option.NaiveInboundOptions](registry, C.TypeNaive, NewInbound)
|
inbound.Register[option.NaiveInboundOptions](registry, C.TypeNaive, NewInbound)
|
||||||
|
|||||||
@@ -179,18 +179,18 @@ type naiveConn struct {
|
|||||||
|
|
||||||
func (c *naiveConn) Read(p []byte) (n int, err error) {
|
func (c *naiveConn) Read(p []byte) (n int, err error) {
|
||||||
n, err = c.readWithPadding(c.Conn, p)
|
n, err = c.readWithPadding(c.Conn, p)
|
||||||
return n, baderror.WrapH2(err)
|
return n, wrapError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *naiveConn) Write(p []byte) (n int, err error) {
|
func (c *naiveConn) Write(p []byte) (n int, err error) {
|
||||||
n, err = c.writeChunked(c.Conn, p)
|
n, err = c.writeChunked(c.Conn, p)
|
||||||
return n, baderror.WrapH2(err)
|
return n, wrapError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *naiveConn) WriteBuffer(buffer *buf.Buffer) error {
|
func (c *naiveConn) WriteBuffer(buffer *buf.Buffer) error {
|
||||||
defer buffer.Release()
|
defer buffer.Release()
|
||||||
err := c.writeBufferWithPadding(c.Conn, buffer)
|
err := c.writeBufferWithPadding(c.Conn, buffer)
|
||||||
return baderror.WrapH2(err)
|
return wrapError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *naiveConn) FrontHeadroom() int { return c.frontHeadroom() }
|
func (c *naiveConn) FrontHeadroom() int { return c.frontHeadroom() }
|
||||||
@@ -210,7 +210,7 @@ type naiveH2Conn struct {
|
|||||||
|
|
||||||
func (c *naiveH2Conn) Read(p []byte) (n int, err error) {
|
func (c *naiveH2Conn) Read(p []byte) (n int, err error) {
|
||||||
n, err = c.readWithPadding(c.reader, p)
|
n, err = c.readWithPadding(c.reader, p)
|
||||||
return n, baderror.WrapH2(err)
|
return n, wrapError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *naiveH2Conn) Write(p []byte) (n int, err error) {
|
func (c *naiveH2Conn) Write(p []byte) (n int, err error) {
|
||||||
@@ -218,7 +218,7 @@ func (c *naiveH2Conn) Write(p []byte) (n int, err error) {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
c.flusher.Flush()
|
c.flusher.Flush()
|
||||||
}
|
}
|
||||||
return n, baderror.WrapH2(err)
|
return n, wrapError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *naiveH2Conn) WriteBuffer(buffer *buf.Buffer) error {
|
func (c *naiveH2Conn) WriteBuffer(buffer *buf.Buffer) error {
|
||||||
@@ -227,7 +227,15 @@ func (c *naiveH2Conn) WriteBuffer(buffer *buf.Buffer) error {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
c.flusher.Flush()
|
c.flusher.Flush()
|
||||||
}
|
}
|
||||||
return baderror.WrapH2(err)
|
return wrapError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func wrapError(err error) error {
|
||||||
|
err = baderror.WrapH2(err)
|
||||||
|
if WrapError != nil {
|
||||||
|
err = WrapError(err)
|
||||||
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *naiveH2Conn) Close() error {
|
func (c *naiveH2Conn) Close() error {
|
||||||
|
|||||||
@@ -124,4 +124,5 @@ func init() {
|
|||||||
|
|
||||||
return quicListener, nil
|
return quicListener, nil
|
||||||
}
|
}
|
||||||
|
naive.WrapError = qtls.WrapError
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user