diff --git a/host.go b/host.go index f7faa1c..8dcfc9a 100644 --- a/host.go +++ b/host.go @@ -232,13 +232,12 @@ func (hs *hostSession) run() (err error) { return } - // Output the offer in base64 so we can paste it in browser - colorstring.Printf("[bold]Connection ready. Here is your connection data:\n\n") - fmt.Printf("%s\n\n", sd.Encode(hs.offer)) - colorstring.Printf(`[bold]Paste it in the terminal after the webtty command` + - "\n[bold]Or in a browser: [reset]https://maxmcd.github.io/webtty/\n\n") - if hs.oneWay == false { + // Output the offer in base64 so we can paste it in browser + colorstring.Printf("[bold]Connection ready. Here is your connection data:\n\n") + fmt.Printf("%s\n\n", sd.Encode(hs.offer)) + colorstring.Printf(`[bold]Paste it in the terminal after the webtty command` + + "\n[bold]Or in a browser: [reset]https://maxmcd.github.io/webtty/\n\n") colorstring.Println("[bold]When you have the answer, paste it below and hit enter:") // Wait for the answer to be pasted hs.answer.Sdp, err = hs.mustReadStdin() @@ -248,6 +247,7 @@ func (hs *hostSession) run() (err error) { } fmt.Println("Answer recieved, connecting...") } else { + colorstring.Printf("[bold]Open in a browser: [reset]https://maxmcd.github.io/webtty/?key=%s\n\n", sd.Encode(hs.offer)) body, err := pollForResponse(hs.offer.TenKbSiteLoc) if err != nil { log.Println(err) diff --git a/web-client/src/app.ts b/web-client/src/app.ts index a3abb36..a15e291 100644 --- a/web-client/src/app.ts +++ b/web-client/src/app.ts @@ -155,11 +155,19 @@ if (firstInput == false) { term.write("Run webtty and paste the offer message below:\n\r"); } +const urlParams = new URLSearchParams(window.location.search); +const key = urlParams.get('key'); + term.on("data", data => { if (!firstInput) { term.reset(); try { - startSession(data); + if (key != null) { + startSession(key); + } + else { + startSession(data); + } } catch (err) { console.log(err); term.write(`There was an error with the offer: ${data}\n\r`);