mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-26 13:43:47 +03:00
caddy: Support SetReadBuffer and SyscallConn for QUIC (fix #3998)
Supersedes #3999
This commit is contained in:
parent
fbd00e4b53
commit
ec3ac840cf
1 changed files with 27 additions and 0 deletions
27
listeners.go
27
listeners.go
|
@ -22,6 +22,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -230,6 +231,24 @@ func (fcpc *fakeClosePacketConn) Close() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Supports QUIC implementation: https://github.com/caddyserver/caddy/issues/3998
|
||||||
|
func (fcpc fakeClosePacketConn) SetReadBuffer(bytes int) error {
|
||||||
|
if conn, ok := fcpc.PacketConn.(interface{ SetReadBuffer(int) error }); ok {
|
||||||
|
return conn.SetReadBuffer(bytes)
|
||||||
|
}
|
||||||
|
return fmt.Errorf("SetReadBuffer() not implemented for %T", fcpc.PacketConn)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Supports QUIC implementation: https://github.com/caddyserver/caddy/issues/3998
|
||||||
|
func (fcpc fakeClosePacketConn) SyscallConn() (syscall.RawConn, error) {
|
||||||
|
if conn, ok := fcpc.PacketConn.(interface {
|
||||||
|
SyscallConn() (syscall.RawConn, error)
|
||||||
|
}); ok {
|
||||||
|
return conn.SyscallConn()
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("SyscallConn() not implemented for %T", fcpc.PacketConn)
|
||||||
|
}
|
||||||
|
|
||||||
// ErrFakeClosed is the underlying error value returned by
|
// ErrFakeClosed is the underlying error value returned by
|
||||||
// fakeCloseListener.Accept() after Close() has been called,
|
// fakeCloseListener.Accept() after Close() has been called,
|
||||||
// indicating that it is pretending to be closed so that the
|
// indicating that it is pretending to be closed so that the
|
||||||
|
@ -432,3 +451,11 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxPortSpan = 65535
|
const maxPortSpan = 65535
|
||||||
|
|
||||||
|
// Interface guards (see https://github.com/caddyserver/caddy/issues/3998)
|
||||||
|
var (
|
||||||
|
_ (interface{ SetReadBuffer(int) error }) = (*fakeClosePacketConn)(nil)
|
||||||
|
_ (interface {
|
||||||
|
SyscallConn() (syscall.RawConn, error)
|
||||||
|
}) = (*fakeClosePacketConn)(nil)
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue