summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2021-02-16 13:55:49 -0700
committerMatthew Holt <mholt@users.noreply.github.com>2021-02-16 14:05:31 -0700
commitec3ac840cf09ec43b9130b41a46c07827b2ff0b6 (patch)
tree9344a352fec0559ed75d30d5309940f877018b5a
parentfbd00e4b53226164a9aae5f44bd52328d4e59d96 (diff)
caddy: Support SetReadBuffer and SyscallConn for QUIC (fix #3998)
Supersedes #3999
-rw-r--r--listeners.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/listeners.go b/listeners.go
index 2c52d12..e1edcd6 100644
--- a/listeners.go
+++ b/listeners.go
@@ -22,6 +22,7 @@ import (
"strings"
"sync"
"sync/atomic"
+ "syscall"
"time"
)
@@ -230,6 +231,24 @@ func (fcpc *fakeClosePacketConn) Close() error {
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
// fakeCloseListener.Accept() after Close() has been called,
// indicating that it is pretending to be closed so that the
@@ -432,3 +451,11 @@ var (
)
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)
+)