Merge remote-tracking branch 'upstream/master' into font-merge

pull/16/head
Matthew Strasiotto 4 years ago
commit f47dfe2c0a

@ -4,7 +4,7 @@ go:
- 1.12.x
node_js:
- 12.4.0
- 12.18.4
# make frontend all won't work. The frontend assets have to be already built at the time of
# evaluating the Makefile first time, so for now I do it in two turns.

@ -1,28 +1,36 @@
TTY_SERVER=./tty-server
TTY_SERVER_ASSETS=$(wildcard frontend/public/*)
TTY_SERVER_ASSETS=$(wildcard frontend/public/*) frontend/public/index.html
TTY_SERVER_SRC=$(wildcard *.go) assets_bundle.go
.PHONY: all frontend clean cleanfront rebuild
all: $(TTY_SERVER)
@echo "Done"
rebuild: clean all
# Building the server and tty-share
$(TTY_SERVER): $(TTY_SERVER_SRC)
go build -o $@
assets_bundle.go: $(TTY_SERVER_ASSETS)
go get github.com/go-bindata/go-bindata/...
go-bindata --prefix frontend/public/ -o $@ $^
go-bindata --prefix frontend/public/ -o $@ frontend/public/*
%.zip: %
zip $@ $^
frontend: force
frontend: cleanfront frontend/public/index.html
frontend/public/index.html:
cd frontend && npm install && npm run build && cd -
force:
clean:
rm -fr tty-server assets_bundle.go frontend/public
cleanfront:
rm -fr frontend/public
clean: cleanfront
rm -fr tty-server assets_bundle.go
@echo "Cleaned"
## Development helper targets

@ -30,3 +30,66 @@ incoming shares (i.e. `tty-share` clients), and 5000 is the port of the web
interface through which remote users can connect. You can override the
defaults by specifying a different port mapping on the command line, e.g.
`-p 7654:6543 -p 80:5000` to listen on `7654` and serve on `80`.
## TLS Setup
You'll need a certificate and the associed key file.
Here is an example for a setup with `nginx` as proxy
The idea is use nginx as
* reverse proxy for the web interface at port 5000 (listen at 443, terminate the TLS, and redirect to localhost:5000)
* TLS endpoint at port 7654, and redirect to localhost:6543
The client usage (after this TLS setup): `tty-share -server server:7654`
### nginx config for the web/browser side (http+websockets connection)
This section can go for example in `/etc/nginx/site-enabled/default`
server {
server_name _;
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
ssl_certificate /etc/ssl/certs/server.crt;
ssl_certificate_key /etc/ssl/private/server.key;
proxy_send_timeout 1600;
proxy_read_timeout 1600;
########### tty-server application
# the /s/, /ws/ and /static/ locations - all used by the actual tty-server.
location / {
proxy_pass http://localhost:5000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Allow websocket upgrade
# https://iota.stackexchange.com/questions/2535/hornet-dashboard-not-working-the-client-is-not-using-the-websocket-protocol
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}
### nginx config for the tty-share command line client (TLS connection)
For the stream , you'll need the stream module from nginx. This configuration cannot go in the `site-enabled/` because it's limited to the http module and not the stream module. Store it in `/etc/nginx/modules-enabled/99-tty-server-stream.conf`, for example
stream {
server {
# https://nginx.org/en/docs/stream/ngx_stream_core_module.html#server
# the tty-server tcp connection ssl proxy
listen 7654 ssl so_keepalive=30m::10;
proxy_pass localhost:6543;
ssl_certificate /etc/ssl/certs/server.crt;
ssl_certificate_key /etc/ssl/private/server.key;
}
}
You'll have to adapt the URL variable to use the nginx URL:
docker run \
-p 6543:6543 -p 5000:5000 \
-e URL=https://server.domain.com \
--cap-drop=all --rm \
tty-server

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

@ -10,14 +10,14 @@
"author": "elisescu",
"license": "elisescu",
"dependencies": {
"copy-webpack-plugin": "4.5.1",
"css-loader": "^3.0.0",
"copy-webpack-plugin": "^6.0.0",
"css-loader": "^3.6.0",
"file-loader": "^6.1.0",
"style-loader": "^0.23.1",
"ts-loader": "^6.0.2",
"typescript": "^3.5.2",
"webpack": "^4.34.0",
"webpack-cli": "^3.3.4",
"xterm": "3.14.4"
"ts-loader": "^6.2.2",
"typescript": "^3.9.7",
"webpack": "^4.44.2",
"webpack-cli": "^3.3.12",
"xterm": "^4.9.0"
}
}

@ -1,4 +1,4 @@
import 'xterm/dist/xterm.css';
import 'xterm/css/xterm.css';
import './main.css';
import { Terminal } from 'xterm';

@ -61,8 +61,7 @@ class TTYReceiver {
}
}
// TODO: .on() is deprecated. Should be replaced.
this.xterminal.on('data', function (data) {
this.xterminal.onData(function (data:string) {
let writeMessage = {
Type: "Write",
Data: base64.encode(JSON.stringify({ Size: data.length, Data: base64.encode(data)})),

@ -47,12 +47,11 @@ let mainConfig = {
extensions: [".ts", ".tsx", ".js"],
},
plugins: [
new copyWebpackPlugin([
'static',
'templates',
], {
debug: 'info',
}),
new copyWebpackPlugin({
patterns: [
{from: 'static', },
{from: 'templates',},
]}),
],
};

@ -0,0 +1,45 @@
Vagrant.configure("2") do |config|
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "ubuntu/focal64"
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine.
# By connecting to localhost:8080 from the host, we can access the guest's
# webserver.
config.vm.network :forwarded_port, guest: 5000, host: 5000
config.vm.network :forwarded_port, guest: 22, host: 5522
config.vm.network :forwarded_port, guest: 6543, host: 6543
# Forward x11 via ssh.
# Handy if you need to share a clipboard, convey viewport info, etc.
config.ssh.forward_x11 = true
$install_script = <<-SCRIPT
build_deps="golang make go-dep"
runtime_deps="dumb-init git"
apt-get update && \
apt-get install -y $build_deps $runtime_deps && \
cd /home/vagrant/go/src/github.com/elisescu/tty-server && \
GOPATH=/home/vagrant/go dep ensure && \
GOPATH=/home/vagrant/go make all && \
ln -s /home/vagrant/go/src/github.com/elisescu/tty-server/tty-server /usr/bin/tty-server
SCRIPT
$serve_script = <<-'SCRIPT'
cat << EOD | sed -e "s#\\\\{#{#g; s#\\\\}#}#g" > /usr/bin/serve
#!/usr/bin/env bash
URL="$\\{1:-http://localhost:5000\\}"
/usr/bin/tty-server -web_address :5000 --sender_address :6543 -url "$\\{URL\\}"
EOD
chmod a+x /usr/bin/serve
SCRIPT
config.vm.provision "file", source: ".", destination: "$HOME/go/src/github.com/elisescu/tty-server"
# config.vm.provision "shell", inline: 'mv "/home/vagrant/go" "/go"', name: "move_go"
config.vm.provision "shell", inline: $install_script, name: "install"
config.vm.provision "shell", inline: $serve_script, name: "serve"
end
Loading…
Cancel
Save