Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
caddy: Support SetReadBuffer and SyscallConn for QUIC (fix #3998)
Supersedes #3999
Matthew Holt committed
Feb 16, 2021 at 13:55 UTC
ec3ac840cf09ec43b9130b41a46c07827b2ff0b6
1 file changed
+27
listeners.go
+27
@@ -22,6 +22,7 @@ import (
22
"strings"
23
"sync"
24
"sync/atomic"
25
+ "syscall"
26
"time"
27
)
28
@@ -230,6 +231,24 @@ func (fcpc *fakeClosePacketConn) Close() error {
231
return nil
232
}
233
234
+// Supports QUIC implementation: https://github.com/caddyserver/caddy/issues/3998
235
+func (fcpc fakeClosePacketConn) SetReadBuffer(bytes int) error {
236
+ if conn, ok := fcpc.PacketConn.(interface{ SetReadBuffer(int) error }); ok {
237
+ return conn.SetReadBuffer(bytes)
238
+ }
239
+ return fmt.Errorf("SetReadBuffer() not implemented for %T", fcpc.PacketConn)
240
+}
241
+
242
+// Supports QUIC implementation: https://github.com/caddyserver/caddy/issues/3998
243
+func (fcpc fakeClosePacketConn) SyscallConn() (syscall.RawConn, error) {
244
+ if conn, ok := fcpc.PacketConn.(interface {
245
+ SyscallConn() (syscall.RawConn, error)
246
+ }); ok {
247
+ return conn.SyscallConn()
248
+ }
249
+ return nil, fmt.Errorf("SyscallConn() not implemented for %T", fcpc.PacketConn)
250
+}
251
+
252
// ErrFakeClosed is the underlying error value returned by
253
// fakeCloseListener.Accept() after Close() has been called,
254
// indicating that it is pretending to be closed so that the
@@ -432,3 +451,11 @@ var (
451
)
452
453
const maxPortSpan = 65535
454
+
455
+// Interface guards (see https://github.com/caddyserver/caddy/issues/3998)
456
+var (
457
+ _ (interface{ SetReadBuffer(int) error }) = (*fakeClosePacketConn)(nil)
458
+ _ (interface {
459
+ SyscallConn() (syscall.RawConn, error)
460
+ }) = (*fakeClosePacketConn)(nil)
461
+)