Skip to content

Commit

Permalink
Rename WebRTTY > WebTTY
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmcd committed Nov 13, 2018
1 parent 5c1b6b8 commit 46e93f6
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 38 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ version: 2
jobs:
build:
docker:
- image: maxmcd/webrtty-node-go:latest
working_directory: /go/src/github.com/maxmcd/webrtty
- image: maxmcd/webtty-node-go:latest
working_directory: /go/src/github.com/maxmcd/webtty
steps:
- restore_cache:
keys:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.DS_Store
/webrtty
/webtty
coverage.out

3 changes: 1 addition & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"syscall"

"github.com/kr/pty"
"github.com/maxmcd/webrtty/pkg/sd"
"github.com/maxmcd/webtty/pkg/sd"
"github.com/mitchellh/colorstring"
"github.com/pions/webrtc"
"github.com/pions/webrtc/pkg/datachannel"
Expand Down Expand Up @@ -156,7 +156,6 @@ func (cs *clientSession) run() (err error) {

encodedAnswer := sd.Encode(answerSd)
if cs.offer.TenKbSiteLoc == "" {
// Get the LocalDescription and take it to base64 so we can paste in browser
fmt.Printf("Answer created. Send the following answer to the host:\n\n")
fmt.Println(encodedAnswer)
} else {
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ version: '3.3'
services:
app:
build: .
image: maxmcd/webrtty-node-go
image: maxmcd/webtty-node-go
15 changes: 7 additions & 8 deletions host.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"time"

"github.com/kr/pty"
"github.com/maxmcd/webrtty/pkg/sd"
"github.com/maxmcd/webtty/pkg/sd"
"github.com/mitchellh/colorstring"
"github.com/pions/webrtc"
"github.com/pions/webrtc/pkg/datachannel"
Expand Down Expand Up @@ -92,7 +92,6 @@ func (hs *hostSession) dataChannelOnOpen() func() {
}
}


func (hs *hostSession) dataChannelOnMessage() func(payload datachannel.Payload) {
return func(payload datachannel.Payload) {

Expand Down Expand Up @@ -152,7 +151,7 @@ func (hs *hostSession) dataChannelOnMessage() func(payload datachannel.Payload)
return
}
hs.errChan <- fmt.Errorf(
`Unmatched string message: "%s"`,
`Unmatched string message: "%s"`,
string(p.Data),
)
case *datachannel.PayloadBinary:
Expand All @@ -163,7 +162,7 @@ func (hs *hostSession) dataChannelOnMessage() func(payload datachannel.Payload)
}
default:
hs.errChan <- fmt.Errorf(
"Message with type %s from DataChannel has no payload",
"Message with type %s from DataChannel has no payload",
p.PayloadType().String())
}
}
Expand Down Expand Up @@ -210,11 +209,11 @@ func (hs *hostSession) run() (err error) {
if err = hs.init(); err != nil {
return
}
colorstring.Printf("[bold]Setting up a WebRTTY connection.\n\n")
colorstring.Printf("[bold]Setting up a WebTTY connection.\n\n")
if hs.oneWay {
colorstring.Printf(
"Warning: One-way connections rely on a third party to connect. " +
"More info here: https://github.com/maxmcd/webrtty#one-way-connections\n\n")
"More info here: https://github.com/maxmcd/webtty#one-way-connections\n\n")
}

if err = hs.createOffer(); err != nil {
Expand All @@ -224,8 +223,8 @@ func (hs *hostSession) run() (err error) {
// 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 webrtty command` +
"\n[bold]Or in a browser: [reset]https://maxmcd.github.io/webrtty/\n\n")
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 {
colorstring.Println("[bold]When you have the answer, paste it below and hit enter:")
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func main() {
_ = flag.Bool("cmd", false, "The command to run. Default is \"bash -l\"\n"+
"Because this flag consumes the remainder of the command line,\n"+
"all other args (if present) must appear before this flag.\n"+
"eg: webrtty -o -v -ni -cmd docker run -it --rm alpine:latest sh")
"eg: webtty -o -v -ni -cmd docker run -it --rm alpine:latest sh")
stunServer := flag.String("s", "stun:stun.l.google.com:19302", "The stun server to use")

cmd := []string{"bash", "-l"}
Expand Down
34 changes: 17 additions & 17 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
![](https://maxmcd.github.io/webrtty/out.gif)
![](https://maxmcd.github.io/webtty/out.gif)

# WebRTTY
# WebTTY

WebRTTY allows you to share a terminal session from your machine using WebRTC. You can pair with a friend without setting up a proxy server, debug servers behind NATs, and more. WebRTTY also works in-browser. You can connect to a WebRTTY session from this static page: https://maxmcd.github.io/webrtty/
WebTTY allows you to share a terminal session from your machine using WebRTC. You can pair with a friend without setting up a proxy server, debug servers behind NATs, and more. WebTTY also works in-browser. You can connect to a WebTTY session from this static page: https://maxmcd.github.io/webtty/

### Status

There are a handful of bugs to fix, but everything works pretty well at the moment. Please open an issue if you find a bug.

### Installation
```bash
go get -u github.com/maxmcd/webrtty
go get -u github.com/maxmcd/webtty
```
WebRTTY uses the wonderful [pions/webrtc](https://github.com/pions/webrtc) for WebRTC communication. It currently requires OpenSSL to build. More here: https://github.com/pions/webrtc#install
WebTTY uses the wonderful [pions/webrtc](https://github.com/pions/webrtc) for WebRTC communication. It currently requires OpenSSL to build. More here: https://github.com/pions/webrtc#install

### Running

```shell
> webrtty -h
Usage of webrtty:
> webtty -h
Usage of webtty:
-cmd
The command to run. Default is "bash -l"
Because this flag consumes the remainder of the command line,
all other args (if present) must appear before this flag.
eg: webrtty -o -v -ni -cmd docker run -it --rm alpine:latest sh
eg: webtty -o -v -ni -cmd docker run -it --rm alpine:latest sh
-ni
Set host to non-interactive
-non-interactive
Expand All @@ -34,39 +34,39 @@ Usage of webrtty:

```shell
# On the host computer
> webrtty
Setting up a WebRTTY connection.
> webtty
Setting up a WebTTY connection.

Connection ready. Here is your connection data:

25FrtDEjh7yuGdWMk7R9PhzPmphst7FdsotL11iXa4r9xyTM4koAauQYivKViWYBskf8habEc5vHf3DZge5VivuAT79uSCvzc6aL2M11kcUn9rzb4DX4...

Paste it in the terminal after the webrtty command
Or in a browser: https://maxmcd.github.io/webrtty/
Paste it in the terminal after the webtty command
Or in a browser: https://maxmcd.github.io/webtty/

When you have the answer, paste it below and hit enter:
# On the client computer
webrtty 25FrtDEjh7yuGdWMk7R9PhzPmphst7FdsotL11iXa4r9xyTM4koAauQYivKViWYBskf8habEc5vHf3DZge5VivuAT79uSCvzc6aL2M11kcUn9rzb4DX4...
webtty 25FrtDEjh7yuGdWMk7R9PhzPmphst7FdsotL11iXa4r9xyTM4koAauQYivKViWYBskf8habEc5vHf3DZge5VivuAT79uSCvzc6aL2M11kcUn9rzb4DX4...


```

### Terminal Size

By default WebRTTY forces the size of the client terminal. This means the host size can frequently render incorrectly. One way you can fix this is by using tmux:
By default WebTTY forces the size of the client terminal. This means the host size can frequently render incorrectly. One way you can fix this is by using tmux:

```bash
tmux new-session -s shared
# in another terminal
webrtty -ni -cmd tmux attach-session -t shared
webtty -ni -cmd tmux attach-session -t shared
```
Tmux will now resize the session to the smallest terminal viewport.

### One-way Connections

One-way connections can be enabled with the `-o` flag. A typical webrtc connection requires an SDP exchange between both parties. By default, WebRTTY will create an SDP offer and wait for you to enter the SDP answer. With the `-o` flag the initial offer is sent along with a public url that the receiver is expected to post their response to. This uses my service [10kb.site](https://www.10kb.site). The host then polls the url continually until it gets an answer.
One-way connections can be enabled with the `-o` flag. A typical webrtc connection requires an SDP exchange between both parties. By default, WebTTY will create an SDP offer and wait for you to enter the SDP answer. With the `-o` flag the initial offer is sent along with a public url that the receiver is expected to post their response to. This uses my service [10kb.site](https://www.10kb.site). The host then polls the url continually until it gets an answer.

I think this somewhat violates the spirit of this tool because it relies on a third party service. However, one-way connections allow you to do very cool things. Eg: I can have a build server output a WebRTTY connection string on error and allow anyone to attach to the session.
I think this somewhat violates the spirit of this tool because it relies on a third party service. However, one-way connections allow you to do very cool things. Eg: I can have a build server output a WebTTY connection string on error and allow anyone to attach to the session.

SDP descriptions are encrypted when uploaded and encryption keys are shared with the connection data to decrypt. So presumably the service being compromised is not problematic.

Expand Down
2 changes: 1 addition & 1 deletion session.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"log"
"os"

"github.com/maxmcd/webrtty/pkg/sd"
"github.com/maxmcd/webtty/pkg/sd"
"github.com/pions/webrtc"
"github.com/pions/webrtc/pkg/datachannel"
"github.com/pions/webrtc/pkg/ice"
Expand Down
5 changes: 3 additions & 2 deletions web-client/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "webrtty",
"name": "webtty",
"version": "0.0.1",
"description": "",
"main": "app.js",
"scripts": {
"build": "npm run go-build && parcel build src/index.html --public-url .",
"go-build": "mkdir -p ./dist/ && touch ./dist/foo && rm ./dist/* && GOOS=js GOARCH=wasm go build -o ./dist/main.wasm ./src",
"go-build":
"mkdir -p ./dist/ && touch ./dist/foo && rm ./dist/* && GOOS=js GOARCH=wasm go build -o ./dist/main.wasm ./src",
"serve": "parcel serve src/index.html",
"test": "echo notests",
"deploy": "npm run build && gh-pages -d dist"
Expand Down
4 changes: 2 additions & 2 deletions web-client/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ term.fit();
window.onresize = () => {
term.fit();
};
term.write("Welcome to the WebRTTY web client.\n\r");
term.write("Welcome to the WebTTY web client.\n\r");

let pc = new RTCPeerConnection({
iceServers: [
Expand Down Expand Up @@ -136,7 +136,7 @@ if (urlData != "") {
}

if (firstInput == false) {
term.write("Run webrtty and paste the offer message below:\n\r");
term.write("Run webtty and paste the offer message below:\n\r");
}

term.on("data", data => {
Expand Down
2 changes: 1 addition & 1 deletion web-client/src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"syscall/js"

"github.com/maxmcd/webrtty/pkg/sd"
"github.com/maxmcd/webtty/pkg/sd"
)

func main() {
Expand Down

0 comments on commit 46e93f6

Please sign in to comment.