diff --git a/README.md b/README.md index e40fae4..0180007 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,57 @@ -# websocket-FileTransfer -Using Xianbei233's test project to see if i can push files to a lockeddown client over websockets +# Websocket File Downloading +I made a quick fork of Xianbei233's test project to see if i can push files to a lockeddown client over websockets, small files seem to work and big files i haven't tested yet. + +**changes i made:** + +- Translated to english +- used the secure websocket example to make this work over https +- changed port `8989` to `443` since it will be the only server i'll be hosting + +## Getting started: + +### client: + +Upload the contents of `_client` to a capable webserver over https. + +edit `ajax.js` and change the `const ws = new WebSocket("wss://HOSTNAMEHERE:443");` +to your domain name + +Point the browser to `file.html` + +### server: +clone my repo +`git clone https://github.com/SEPPDROID/websocket-FileTransfer.git` + +jump to the folder +`cd websocket-FileTransfer/` + +like all nodeprojects just execute npm +`npm install` + +jump to the src folder +`cd src` + +but wait! we need a domain, cert & a key for secure support. +you can also use self signed certificates but i reccommend certbot and a example can be found below + +jump to the cert folder +`cd sec_certs/` + +and link (or copy) your `fullchain.pem` and `privkey.pem` + +then go back to the `src` folder (with `cd ..`) and launch the node app by executing +`node server.js` + +*tip use npm forever to make it a background process or service* +### certbot: +install certbot + +then execute the certonly tag w/ the command +`sudo certbot certonly --standalone --preferred-challenges http -d EXAMPLE.DOMAIN.COM` + +your `fullchain.pem` and `privkey.pem` will be available at + +` /etc/letsencrypt/live/EXAMPLE.DOMAIN.COM/fullchain.pem` +` /etc/letsencrypt/live/EXAMPLE.DOMAIN.COM/privkey.pem` diff --git a/_client.zip b/_client.zip new file mode 100644 index 0000000..f74e9d3 Binary files /dev/null and b/_client.zip differ diff --git a/FileSaver.js b/_client/FileSaver.js similarity index 100% rename from FileSaver.js rename to _client/FileSaver.js diff --git a/ajax.js b/_client/ajax.js similarity index 97% rename from ajax.js rename to _client/ajax.js index 8c01865..fb76f4e 100644 --- a/ajax.js +++ b/_client/ajax.js @@ -36,7 +36,7 @@ ws.onmessage = (message) => { } } - if (isJSON(data) == false && data == 'con. Succ') { + if (isJSON(data) == false && data == 'hello, connection success!') { document.getElementById('message').append(data) diff --git a/base64.js b/_client/base64.js similarity index 100% rename from base64.js rename to _client/base64.js diff --git a/file.html b/_client/file.html similarity index 59% rename from file.html rename to _client/file.html index 6194834..c4bfbac 100644 --- a/file.html +++ b/_client/file.html @@ -8,14 +8,14 @@ -