diplonat/README.md

57 lines
1.8 KiB
Markdown
Raw Normal View History

2020-05-08 08:57:10 +00:00
Diplonat
========
2020-05-09 14:56:39 +00:00
## Feature set
2020-05-09 14:57:33 +00:00
* [ ] (Re)Configure NAT via UPNP/IGD (prio: high)
* [ ] (Re)Configure nftable (prio: low)
* [ ] (Re)Configure DNS via ??? (prio: low)
2020-05-09 14:56:39 +00:00
## Operate
2020-05-08 08:57:10 +00:00
```bash
cargo build
2020-05-08 08:58:04 +00:00
consul agent -dev # in a separate terminal
2020-05-08 08:57:10 +00:00
2020-05-08 08:58:04 +00:00
# adapt following values to your configuratio
2020-05-08 08:57:10 +00:00
export DIPLONAT_PRIVATE_IP="192.168.0.18"
export DIPLONAT_REFRESH_TIME="60"
export DIPLONAT_EXPIRATION_TIME="300"
export DIPLONAT_CONSUL_NODE_NAME="lheureduthe"
2020-05-21 15:51:30 +00:00
export RUST_LOG=debug
2020-05-08 08:57:10 +00:00
cargo run
```
2020-05-21 20:25:33 +00:00
2020-05-22 09:06:26 +00:00
## Design Guidelines
Diplonat is made of a set of Components.
Components communicate between them thanks to [tokio::sync::watch](https://docs.rs/tokio/0.2.21/tokio/sync/index.html#watch-channel) transferring copiable messages.
Each message must contain the whole state (and not a transition) as messages can be lost if a more recent message is received.
This choice has been made to limit bugs.
If you need to watch two actors and merge their content, you may use [tokio::sync::select](https://docs.rs/tokio/0.2.21/tokio/macro.select.html).
When you read a value from source 1, you must cache it to be able to merge it later when you read from source 2.
2020-05-21 20:25:33 +00:00
## About Consul Catalog
* We query the `/v1/catalog/node/<node>` endpoint
* We can watch it thanks to [Blocking Queries](https://www.consul.io/api/features/blocking.html)
eg:
```bash
curl -vvv http://127.0.0.1:8500/v1/catalog/node/lheureduthe
# returns X-Consul-Index: 15
curl -vvv http://127.0.0.1:8500/v1/catalog/node/lheureduthe?index=15
```
Each time you do the request, the whole list of services bound to the node is returned.
To test the Consul Catalog part, you can do:
```bash
consul agent -dev #in a separate terminal, if not already running
consul services register -name=example -port=1337
consul services -id=example
```