Skip to content

Commit

Permalink
add enable_compression option
Browse files Browse the repository at this point in the history
  • Loading branch information
azonti committed Aug 27, 2019
1 parent b4e6052 commit a6a2da3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
20 changes: 11 additions & 9 deletions handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,30 @@ var (

// Handler handlers
type Handler struct {
logger *zap.Logger
upgrader websocket.Upgrader
dialTimeout time.Duration
writeTimeout time.Duration
mp *mapping.Mapping
pk *publickey.Publickey
dumpTCP uint
sq *seq.Seq
logger *zap.Logger
upgrader websocket.Upgrader
dialTimeout time.Duration
writeTimeout time.Duration
enableCompression bool
mp *mapping.Mapping
pk *publickey.Publickey
dumpTCP uint
sq *seq.Seq
}

// New new handler
func New(
handshakeTimeout time.Duration,
dialTimeout time.Duration,
writeTimeout time.Duration,
enableCompression bool,
mp *mapping.Mapping,
pk *publickey.Publickey,
dumpTCP uint,
logger *zap.Logger) (*Handler, error) {

upgrader := websocket.Upgrader{
EnableCompression: true,
EnableCompression: enableCompression,
ReadBufferSize: BufferSize,
WriteBufferSize: BufferSize,
HandshakeTimeout: handshakeTimeout,
Expand Down
24 changes: 13 additions & 11 deletions wsgate-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,18 @@ import (

var (
// Version wsgate-server version
Version string
showVersion = flag.Bool("version", false, "show version")
listen = flag.String("listen", "127.0.0.1:8086", "Address to listen to.")
handshakeTimeout = flag.Duration("handshake_timeout", 10*time.Second, "Handshake timeout.")
dialTimeout = flag.Duration("dial_timeout", 10*time.Second, "Dial timeout.")
writeTimeout = flag.Duration("write_timeout", 10*time.Second, "Write timeout.")
shutdownTimeout = flag.Duration("shutdown_timeout", 86400*time.Second, "timeout to wait for all connections to be closed")
mapFile = flag.String("map", "", "path and proxy host mapping file")
publicKeyFile = flag.String("public-key", "", "public key for verifying JWT auth header")
jwtFreshness = flag.Duration("jwt-freshness", 3600*time.Second, "time in seconds to allow generated jwt tokens")
dumpTCP = flag.Uint("dump-tcp", 0, "Dump TCP. 0 = disable, 1 = src to dest, 2 = both")
Version string
showVersion = flag.Bool("version", false, "Show version")
listen = flag.String("listen", "127.0.0.1:8086", "Address to listen to")
handshakeTimeout = flag.Duration("handshake_timeout", 10*time.Second, "Handshake timeout")
dialTimeout = flag.Duration("dial_timeout", 10*time.Second, "Dial timeout")
writeTimeout = flag.Duration("write_timeout", 10*time.Second, "Write timeout")
shutdownTimeout = flag.Duration("shutdown_timeout", 86400*time.Second, "Timeout to wait for all connections to be closed")
enableCompression = flag.Bool("enable_compression", false, "To enable WebSocket Per-Message Compression Extensions (RFC 7692)")
mapFile = flag.String("map", "", "Path and proxy host mapping file")
publicKeyFile = flag.String("public-key", "", "Public key for verifying JWT auth header")
jwtFreshness = flag.Duration("jwt-freshness", 3600*time.Second, "Time in seconds to allow generated jwt tokens")
dumpTCP = flag.Uint("dump-tcp", 0, "Dump TCP. 0 = disable, 1 = src to dest, 2 = both")
)

func printVersion() {
Expand Down Expand Up @@ -68,6 +69,7 @@ func main() {
*handshakeTimeout,
*dialTimeout,
*writeTimeout,
*enableCompression,
mp,
pk,
*dumpTCP,
Expand Down

0 comments on commit a6a2da3

Please sign in to comment.