final
i'm sleepy so english not very good looking
This commit is contained in:
57
README.md
57
README.md
@@ -1,4 +1,57 @@
|
|||||||
# websocket-FileTransfer
|
# Websocket File Downloading
|
||||||
Using Xianbei233's test project to see if i can push files to a lockeddown client over websockets
|
|
||||||
|
|
||||||
|
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`
|
||||||
|
|
||||||
|
BIN
_client.zip
Normal file
BIN
_client.zip
Normal file
Binary file not shown.
@@ -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)
|
document.getElementById('message').append(data)
|
||||||
|
|
@@ -8,14 +8,14 @@
|
|||||||
<script src="FileSaver.js"></script>
|
<script src="FileSaver.js"></script>
|
||||||
<script src="base64.js"> </script>
|
<script src="base64.js"> </script>
|
||||||
<script src="ajax.js" defer></script>
|
<script src="ajax.js" defer></script>
|
||||||
<title>WS FileTransfer</title>
|
<title>sWS FileTransfer</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body style="text-align: center;">
|
||||||
<button onclick=getFileList()>ListFiles</button>
|
<button onclick=getFileList()>ListFiles</button><br><br>
|
||||||
<ul id="FileList"></ul>
|
<div id="FileList"></div><br><br>
|
||||||
<div id="PictureShow"></div>
|
<div id="PictureShow"></div><br>
|
||||||
<div id="message"></div>
|
<div id="message"></div><br>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
Reference in New Issue
Block a user