Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving args to querystring #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ if (elem !== null) {
term = new OurXterm(elem);

const httpsEnabled = window.location.protocol == "https:";
const url = (httpsEnabled ? 'wss://' : 'ws://') + window.location.host + window.location.pathname + 'ws';
const args = window.location.search;
const url = (httpsEnabled ? 'wss://' : 'ws://') + window.location.host + window.location.pathname + 'ws' + args;
const factory = new ConnectionFactory(url, protocols);
const wt = new WebTTY(term, factory, args, gotty_auth_token);
const closer = wt.open();
Expand Down
8 changes: 4 additions & 4 deletions server/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.URL.RawQuery)

switch err {
case ctx.Err():
Expand All @@ -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, rawquery string) error {
typ, initLine, err := conn.ReadMessage()
if err != nil {
return errors.Wrapf(err, "failed to authenticate websocket connection")
Expand All @@ -106,8 +106,8 @@ func (server *Server) processWSConn(ctx context.Context, conn *websocket.Conn) e
}

queryPath := "?"
if server.options.PermitArguments && init.Arguments != "" {
queryPath = init.Arguments
if server.options.PermitArguments && rawquery != "" {
queryPath += rawquery
}

query, err := url.Parse(queryPath)
Expand Down