mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 20:59:58 +00:00
TUN-3764: Actively flush data for TCP streams
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package connection
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
@@ -56,9 +57,35 @@ type Type int
|
||||
const (
|
||||
TypeWebsocket Type = iota
|
||||
TypeTCP
|
||||
TypeControlStream
|
||||
TypeHTTP
|
||||
)
|
||||
|
||||
// ShouldFlush returns whether this kind of connection should actively flush data
|
||||
func (t Type) shouldFlush() bool {
|
||||
switch t {
|
||||
case TypeWebsocket, TypeTCP, TypeControlStream:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func (t Type) String() string {
|
||||
switch t {
|
||||
case TypeWebsocket:
|
||||
return "websocket"
|
||||
case TypeTCP:
|
||||
return "tcp"
|
||||
case TypeControlStream:
|
||||
return "control stream"
|
||||
case TypeHTTP:
|
||||
return "http"
|
||||
default:
|
||||
return fmt.Sprintf("Unknown Type %d", t)
|
||||
}
|
||||
}
|
||||
|
||||
type OriginProxy interface {
|
||||
Proxy(w ResponseWriter, req *http.Request, sourceConnectionType Type) error
|
||||
}
|
||||
|
Reference in New Issue
Block a user