Skip to content

Support passing key as argument for One-way mode #38

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

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
12 changes: 6 additions & 6 deletions host.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down
10 changes: 9 additions & 1 deletion web-client/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down