diff --git a/README.md b/README.md index 6a892333..cbce0215 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ By default, GoTTY starts a web server at port 8080. Open the URL on your web bro --max-connection value Maximum connection to gotty (default: 0) [$GOTTY_MAX_CONNECTION] --once Accept only one client and exit on disconnection [$GOTTY_ONCE] --timeout value Timeout seconds for waiting a client(0 to disable) (default: 0) [$GOTTY_TIMEOUT] ---permit-arguments Permit clients to send command line arguments in URL (e.g. http://example.com:8080/?arg=AAA&arg=BBB) [$GOTTY_PERMIT_ARGUMENTS] +--permit-arguments Permit clients to send command line arguments in URL or in Arguments HTTP header (e.g. http://example.com:8080/?arg=AAA&arg=BBB) [$GOTTY_PERMIT_ARGUMENTS] --width value Static width of the screen, 0(default) means dynamically resize (default: 0) [$GOTTY_WIDTH] --height value Static height of the screen, 0(default) means dynamically resize (default: 0) [$GOTTY_HEIGHT] --ws-origin value A regular expression that matches origin URLs to be accepted by WebSocket. No cross origin requests are acceptable by default [$GOTTY_WS_ORIGIN] diff --git a/server/handlers.go b/server/handlers.go index f1a2f9b9..39b4a09b 100644 --- a/server/handlers.go +++ b/server/handlers.go @@ -72,7 +72,7 @@ func (server *Server) generateHandleWS(ctx context.Context, cancel context.Cance } defer conn.Close() - err = server.processWSConn(ctx, conn) + err = server.processWSConn(ctx, conn, r.Header) switch err { case ctx.Err(): @@ -87,7 +87,7 @@ func (server *Server) generateHandleWS(ctx context.Context, cancel context.Cance } } -func (server *Server) processWSConn(ctx context.Context, conn *websocket.Conn) error { +func (server *Server) processWSConn(ctx context.Context, conn *websocket.Conn, header http.Header) error { typ, initLine, err := conn.ReadMessage() if err != nil { return errors.Wrapf(err, "failed to authenticate websocket connection") @@ -109,13 +109,17 @@ func (server *Server) processWSConn(ctx context.Context, conn *websocket.Conn) e if server.options.PermitArguments && init.Arguments != "" { queryPath = init.Arguments } - + headerArguments := header.Get("Arguments") + if server.options.PermitArguments && headerArguments != "" { + queryPath = queryPath + "&" + headerArguments + } query, err := url.Parse(queryPath) if err != nil { return errors.Wrapf(err, "failed to parse arguments") } params := query.Query() var slave Slave + slave, err = server.factory.New(params) if err != nil { return errors.Wrapf(err, "failed to create backend")