Skip to content
This repository was archived by the owner on Nov 13, 2022. It is now read-only.

Conversation

@nellshamrell
Copy link
Collaborator

Adds a command to block an ip address and a command to unblock an ip address, according to the requirements in #4.

Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>

refactors parse_config_value_set into a more central place

Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>

wip

Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>

refactor

Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>

more refactoring

Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>

wip

Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>

Revert "wip"

This reverts commit 95a47e6.

wip

Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>

wip

Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>

Revert "wip"

This reverts commit 7903072.

Revert "wip"

This reverts commit 5344822.
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>

modifies parsing a hashset into a string so that it does not create an empty string at the beginning

Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
@nellshamrell
Copy link
Collaborator Author

@pietroalbini @smarnach your feedback has been so helpful on previous pull requests, I would LOVE if you would take a look at this one when you have some time.

…_app_config command

Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
…OCKED_IPS env var

Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
… per command

Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
…s are currently blocked

Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
@nellshamrell
Copy link
Collaborator Author

Thank you for the review, @pietroalbini ! I believe I've addressed all your comments.

Copy link
Contributor

@smarnach smarnach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good to me.

I still think that we want to allow ops people to see the current value of the blocked IPs, but this is easy to change, so we can decide this when needed.

README.md Outdated

```
you: ~block_ip testing-nell-bot 123.456.68
crates-io-bot: @you IP address 123.456.789
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the bot should reply with the same address as the one in the request.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

er...yes...fixing the doc!

params: empty_config_var(),
});

let response_err = response.is_err();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can inline this variable – it's used only once.

src/utilities.rs Outdated
value_set.insert(String::from(string));
}

value_set
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this function body is equivalent to

config_value.split(',').map(String::from).collect()

src/utilities.rs Outdated
// Remove last comma
combined_string.pop();

combined_string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More concise alternative:

let non_empty: Vec<String> = config_value.into_iter().filter(|s| !s.is_empty()).collect();
non_empty.join(",")

There is not join() for arbitrary iterators of strings, so we need to collect into a vector first.

Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
@nellshamrell nellshamrell merged commit 3088b53 into rust-lang:master Apr 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants