unifi-parental
unifi-parental copied to clipboard
Quick and nasty time based parental controls for a Unifi based network
Unmaintained!
Please Note:
This project is no longer actively maintained by the original author as the teenagers have left the building and I don't have a use case for it any more.
Please feel free to fork, improve, customise and do what you wish with it.
Issues will no longer be actioned.
Thanks for the interest.
================================
Unifi-parental
Time based block/unblock of clients for a Unifi based network.
Requires
- a Unifi Controller accessible over the network
- NodeJS v7.10.x or later (the latest LTS should suffice)
- openssl installed to generate self signed ssl certificate
Uses:
- node-unifi to access the Unifi Controller.
- node-schedule for cron like scheduling of the block/unblock actions
Installation
Clone the repo and then do:
-
npm install
-
Generate a self signed certificate using
generate-ssl-cert.sh
- this requiresopenssl
to be installed. Alternatively a certificate from Lets Encrypt using standalone authintication with CertBot could be used. -
Add certificate information, Unifi Controller details and login information to
config.json
and.env
respectively - see-sample
files for examples
- if you copy the sample files, remove the comments ...
/* xxx */
- try this
sed
one liner if you are using Linux/MacOS
sed -r ':a; s%(.*)/\*.*\*/%\1%; ta; /\/\*/ !b; N; ba' config-sample.jsonc > config.json
- Start the server:
DEBUG=unifi-parental:* npm start
Fire up a browser and head to https://localhost:4000/ to access the interface.
Click Save
to send the schedule to the server and to schedule the block/unblock actions. This is required to be done initially every time the server is started. (ie: the schedule is not applied on startup of the server)
Note
The code (javascript, html, css, images and fonts) for the time schedule chart were saved using a browser from a Fritz!Box 7390 ADSL modem/router. The source files served to the browser contained no license information.
The file public\js\timer.js
has been modified to return data in a more usable format for both the client and server. Portions of this file have been used in the server side code for scheduling block/unblock actions.
TODO
- [x] Generate block/unblock schedule on startup
- [x] Check if clients should be blocked/unblocked at the time the schedule is applied
- [x] Keep track of the login state with the Unifi Controller better
- [x] Error handling if the login state is stale
- [x] Tidy up the client UI
- [x] ~~make the Cancel button actually do something~~
- [x] show some confirmation that the schedule has been applied on the server