0.0.1 • Published 6 years ago
sf2018-cb v0.0.1
Features
- Uses NodeJS, MySQL as backend and flavored with native WebSocket
- JSON data transmitting
- HTTPS backend and WebSocketSecure (wss://) supported
- Message delivery checking
- XSS Blocked
- Friendly UI
- Easily switch to backup backend
- Completed Logging System
TODOS
- Improve
clients/client-user.html
; Major problem is the UI & Animation; - Improve
clients/client-bigboard.html
; Major problem is object alignment; - Make
clients/admin.html
usable; - Complete test script;
- Make it more school...
Server Configuration
if (iCanUseSchoolsServer) {
deployAt(SchoolsServer)
} else {
deployAt(vultr)
setUpPrivateNetwork()
setUpStatusMonitor({ enable: ['dns', 'adminUI'] })
}
Artitecture
+-----------+
| |
| Clients |
| |
+-----+-----+
^
|
|
+-----+
| CN2 |
+-----+
|
|
+-----------------------------------------------------------------------------------------------------------+
| | |
| | |
| +------------+-------------+ +----------------------------------+ |
| | | | | |
| | Main Server (run NodeJS) | +-------+ | Main Database Server (run MySQL) | |
| | [Provide] | |Vultr's| | [Provide] <----------+ |
| +---------> : HTTPS <-+Private+-> : MySQL Database | | |
| | | : WSS | |Network| | : MySQL Hot Backup | | |
| | | : MySQL Actions | +-------+ | | | |
| | | | +------------------^---------------+ | |
| | +------------^-------------+ | | |
| | | | | |
| | | | | |
| | | +-----------------------+ | | |
+----------------------------------------+ Hardware WAF by Vultr +------------------------------------------+
| | | +-----------------------+ | | |
| | | | | |
| | | | | |
| | | +----------------------v------------------+ | |
| | +--------------v---------------+ | | | |
| | | | | Backup Database Server (run MySQL) | | |
| | | Backup Server (run NodeJS) | | [Provide] | | |
| +-------> [Provide] <-----> : Fully capability of the Main Server <-------+ |
| | | : {Fully Support on running | | [Settings] | | |
| | | : the Main Server Service } | | : MySQL will run in duplicate mode | | |
| | | | | | | |
| | +------------------------------+ +-----------------------------------------+ | |
| | | |
| | | |
| | | |
| | +-----------------------------+ | |
| | | | | |
| +------------------------------> Service Monitor (run:) <---------------------------------+ |
| | : ServerStatus | |
| | : Down Detection | |
| | : DNS Switcher | |
| | [Provide] | |
| | : { Switch DNS to Backup | |
| | : Server when Main Server | |
| | : down } | |
| | : Provide Status Page | |
| | | +-----------------------+
| +-----------------------------+ | |
| | Software WAF by Vultr |
| | |
+-----------------------------------------------------------------------------------+-----------------------+
Install
Ready the environment
$ chmod -R 777 deploy.sh
$ ./deploy.sh
$ mysql -u [your_mysql_username_here] -p sfcomments < create-tables.sql
Go!
$ node server.js
Interface
WebSocket Client -> Server {Request}
Actions & Data Arguments
String post
: Post new comments to the server.
String name
: Comment's name.String comment
: Comment content.Int time
: Client time.
Structure
{
"action": "post | ...",
"time": $current-client-time,
"data": {
"name": $name,
"message": $message,
"time": $message-send-time
}
}
WebSocket Server -> Client {Response}
Structure
{
"status": "ok | warn | error | fatal",
"time": $server-time,
"type": "received | newmessage | history(php-api)",
"hash": $data-md5-hash,
"data": @SEE-BELOW@
}
data
Structure
action: post
{
"name": $posted-name,
"comment": $posted-comment,
"time": $posted-time
}
action: rce
{
"code": "javascript",
"evalcode": $javascript-code-to-execure,
"time": $execute-time
}
action: checkcount
(Deprecated)
{
"count": $server-comments-count,
"counttime": $counted-at-this-time
}
event: newmessage
! IMPORTANT: When event is received and check it is valid, then broadcast to all other clients. !
{
"name": $other-post-name,
"comment": $other-post-comment,
"time": $other-post-time
}
historyFetch Client(ajax) -https-> Server(php) {Response}
Structure
response.data.status === "ok"
{
"status": "ok",
"type": "history",
"data": [
"name": $history-post-data-name,
"message": $history-post-data-message,
"time": $history-post-data-time
]
}
response.data.status === "error"
{
"status": "error",
"message": $backend-error-message
}
License
0.0.1
6 years ago