TUN-3764: Actively flush data for TCP streams

This commit is contained in:
cthuang
2021-01-15 17:25:56 +00:00
committed by Nuno Diegues
parent b4700a52e3
commit 3b93914612
2 changed files with 73 additions and 33 deletions

View File

@@ -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
}