This repository is in public archive. It has a bunch of design flaws, but I will not fix it, since there is no good usecase. It was fun to learn though.
Build your own device, that will be available via Web-Interface.
Here is your Build a web_device check-list
:
- create a file for your device:
src/web_device.rs
- add its name to the
src/lib.rs
:
pub mod web_device;
- Implement Device Traits, defined in the
src/device_trait.rs
- Add your device name into the
src/dashboard.rs
into the functionDispatch::resolve_by_name
and add initializer intoDispatch::new
- Add new web services in the
src/server.rs
, if you want to receive specific data (not necessary) - Add new groups for your device into
src/device.rs
enum Devices
,DEV_NAMES
andDEV_GROUPS
You can see the working example at src/printer_device.rs
.
- It's quick - most requests are handled less than 10ms
- It's modest - release binary is 10 MB after stripping
- Small runtime - you can easily deploy it to your Raspberry Pi
- Secure in mind - starting from idea
- Strong user access rights - easily define, what each user can perform
You'll need the Rust Lang compiler (at least 1.62). You can easily install it on Manjaro:
$ sudo pacman -S rust cargo openssl redis sqlite # for building only
$ sudo pacman -S rust cargo openssl redis sqlite rust-src rust-doc \
rust-debugger-common rust-lldb rust-gdb rustfmt rust-packaging # for developing
As Webify works with SQLite as database, make sure you have installed the libsqlite3-dev
on Debian or sqlite-devel
on Fedora, sqlite
on Manjaro. You'll also need redis
to have caching enabled.
Build on Linux is pretty simple:
$ ./build.sh build # for debug version
$ ./build.sh build --release # for release version
After this you can copy the target/[release, debug]/static
and target/[release, debug]/webify
to place you want. Go to that place and run:
$ ./webify --setup # configure the database, address and printer
$ ./webify --uadd # add your first user, remember that it must contain all the groups you need
$ openssl genrsa 4096 > key.pem # generate key for TLS
$ openssl req -x509 -days 1000 -new -key key.pem -out cert.pem # generate certificate for TLS
Suggested groups for your first user: rstatus,filer_read,filer_write,root_write,root_read,printer_read,printer_write,printer_request,printer_confirm,blogdev_write,blogdev_request,blogdev_read
.
Suggested groups for your basic users: rstatus,filer_read,printer_read,printer_request,blogdev_request,blogdev_read
.
After this you can just run the server:
$ ./run.sh
If you need additional documentation, you can run:
$ cargo doc
And see it at target/doc/webify/index.html
.