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

Now twilio is no longer being used, consider trying to go fully static? #219

Open
wants to merge 2 commits 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
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
node_modules

secret/*
!secret/index-sample.js

static/main.css
static/bundle.js
static/__rtcConfig__.json
6 changes: 6 additions & 0 deletions Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
localhost
gzip
rewrite /__rtcConfig__ /__rtcConfig__.json # Backwards compatability
file_server {
root static
}
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,31 @@ console and refresh to get detailed log output.

## Install

If you just want to do file transfer on your site, or fetch/seed files over WebTorrent, then there's no need to run a copy of instant.io on your own server. Just use the WebTorrent script directly. You can learn more at https://webtorrent.io.
instant.io is a completely static site, and is a demonstration of how little code is required to use WebTorrent.

The client-side code that instant.io uses is [here](https://github.com/webtorrent/instant.io/blob/master/client/index.js).
Almost all the client-side code that instant.io uses is [here](./client/index.js).

### Run a copy of this site on your own server
### Build

To get a clone of https://instant.io running on your own server, follow these instructions.

Get the code:
To build a copy of the https://instant.io front-end, follow these instructions.

```
git clone https://github.com/webtorrent/instant.io
cd instant.io
npm install
```

Modify the configuration options in [`config.js`](https://github.com/webtorrent/instant.io/blob/master/config.js) to set the IP/port you want the server to listen on.
### Serve

All instant.io requires to run is a static file server, and some [NAT Traversal](https://www.html5rocks.com/en/tutorials/webrtc/infrastructure/#after-signaling-using-ice-to-cope-with-nats-and-firewalls) services.

There are example nginx and Caddy configs in this repo, but any static file server can be used to serve instant.io

Copy [`secret/index-sample.js`](https://github.com/webtorrent/instant.io/blob/master/secret/index-sample.js) to `secret/index.js` and set the Twilio API key if you want a [NAT traversal service](https://www.twilio.com/stun-turn) (to help peers connect when behind a firewall).
1. Build the client (as explained above)
2. Serve the `static` directory using a static file server
3. Redirect `/__rtConfig__` to a JSON file with a single `iceServers` key conforming to the [WebRTC Spec](https://w3c.github.io/webrtc-pc/#dom-rtcconfiguration)

To start the server, run `npm start`. That should be it!
That's it!

## Mirrors

Expand All @@ -51,7 +55,7 @@ To start the server, run `npm start`. That should be it!
## Tips

1. Create a shareable link by adding a torrent infohash or magnet link to the end
of the URL. For example: `https://instant.io#INFO_HASH` or `https://instant.io/#MAGNET_LINK`.
of the URL. For example: `https://instant.io/#INFO_HASH` or `https://instant.io/#MAGNET_LINK`.

2. You can add multiple torrents in the same browser window.

Expand Down
4 changes: 0 additions & 4 deletions config.js

This file was deleted.

17 changes: 13 additions & 4 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
server {
listen 23.239.22.146:80;
listen 23.239.22.146:443 http2 ssl;
server_name instant.io www.instant.io;

ssl_certificate /etc/letsencrypt/live/instant.io/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/instant.io/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/instant.io/chain.pem;

location / {
proxy_pass http://127.0.0.1:7010;
include /home/feross/config/nginx/_proxy.include;
gzip on;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;

root /home/feross/www/instant.io/static;

location __rtcConfig__ {
try_files __rtcConfig__.json =404;
}

include /home/feross/config/nginx/_server.include;
}

server {
listen 23.239.22.146:80;
server_name instant.io www.instant.io;
return 301 https://$server_name$request_uri;
}
14 changes: 3 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,22 @@
"url": "https://github.com/webtorrent/instant.io/issues"
},
"dependencies": {
"compression": "^1.7.4",
"cors": "^2.8.5",
"create-torrent": "^4.4.1",
"date-fns": "^2.6.0",
"debug": "^4.1.1",
"drag-drop": "^6.0.0",
"escape-html": "^1.0.3",
"express": "^4.17.1",
"jszip": "^3.2.2",
"prettier-bytes": "^1.0.4",
"pug": "^2.0.4",
"rollbar": "^2.13.0",
"simple-get": "^3.1.0",
"throttleit": "^1.0.0",
"thunky": "^1.1.0",
"twilio": "^3.36.0",
"upload-element": "^1.0.1",
"webtorrent": "^0.107.6"
},
"devDependencies": {
"browserify": "^16.5.0",
"husky": "^3.0.9",
"nodemon": "^1.19.4",
"standard": "*",
"stylus": "^0.54.7",
"tinyify": "^2.5.2",
Expand Down Expand Up @@ -63,15 +56,14 @@
"build-css": "stylus css/main.styl -o static/ -c",
"build-js": "browserify --plugin tinyify client > static/bundle.js",
"deploy": "./tools/trigger-deploy.sh",
"secret-download": "rsync -a -O -v --delete -e \"ssh -p 44444\" feross@webtorrent:\"/home/feross/www/instant.io/secret/\" secret/",
"secret-upload": "rsync -a -O -v --delete -e \"ssh -p 44444\" secret/ feross@webtorrent:/home/feross/www/instant.io/secret/",
"secret-download": "rsync -a -O -v --delete -e \"ssh -p 44444\" feross@webtorrent:\"/home/feross/www/instant.io/secret/rtcConfig.json\" static/rtcConfig.json",
"secret-upload": "rsync -a -O -v --delete -e \"ssh -p 44444\" static/rtcConfig.json feross@webtorrent:/home/feross/www/instant.io/secret/rtcConfig.json",
"size": "npm run size-js && npm run size-css",
"size-css": "npm run build-css && cat static/main.css | gzip | wc -c",
"size-js": "npm run build-js && cat static/bundle.js | gzip | wc -c",
"start": "npm run build && node server",
"test": "standard",
"update-authors": "./tools/update-authors.sh",
"watch": "npm run watch-css & npm run watch-js & DEBUG=instant* nodemon server",
"watch": "npm run watch-css & npm run watch-js",
"watch-css": "stylus css/main.styl -o static/ -w",
"watch-js": "watchify client -o static/bundle.js -dv"
}
Expand Down
29 changes: 0 additions & 29 deletions secret/index-sample.js

This file was deleted.

173 changes: 0 additions & 173 deletions server/index.js

This file was deleted.

34 changes: 0 additions & 34 deletions server/rollbar.js

This file was deleted.

4 changes: 0 additions & 4 deletions server/views/error.pug

This file was deleted.

Loading