From 84e5a1f91517565f9da6078527fec00f753ab379 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 6 Sep 2020 16:01:33 +0200 Subject: Indicate days to access blocks --- README.md | 33 +++++++++++------------ src/main.rs | 88 +++++++++++++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 84 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 9a7445a..d047eb9 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,30 @@ # Proxy -Proxy denying connections according to the given configuration. +Proxy denying connections depending on the time. ## Getting started -```bash -nix-shell --run "cargo-watch -x run -- --config config.dhall" -``` - -## Example configuration +Create `config.dhall`: ```dhall [ { - from = "00:00", - to = "23:59", - hosts = [ - "facebook.com", - "gstatic.com" - ] - }, - { - from = "19:00", - to = "17:00", + times = [ + { + days = "Monday-Sunday", + from = "00:00", + to = "23:59" + } + ], hosts = [ - "youtube.com" + "facebook.com" ] } ] ``` + +Then, run with: + +```bash +nix-shell --run 'cargo-watch -x "run -- --config config.dhall"' +``` diff --git a/src/main.rs b/src/main.rs index c1a79d0..ccfb81e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,13 +22,22 @@ type HttpClient = Client; struct Opt { #[structopt(short, long)] config: String, + + #[structopt(short, long, default_value = "127.0.0.1:8200")] + address: SocketAddr, } #[derive(Debug, Deserialize, StaticType, Clone)] struct Access { + times: Vec