Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IP filtering #102

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

IP filtering #102

wants to merge 13 commits into from

Conversation

lekhan05
Copy link
Collaborator

Minimal changes required for some ip filtering, for further review and inputs only

@s-gv s-gv changed the title Initial Ip filtering changes IP filtering Jun 13, 2021
views/views.go Outdated Show resolved Hide resolved
views/views.go Outdated Show resolved Hide resolved
}

if checkIfIpIsBlocked(parsedIp.String()) {
w.WriteHeader(http.StatusUnauthorized)
Copy link
Owner

Choose a reason for hiding this comment

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

write to response like this: http.Error(w, http.StatusText(404), 404) I dunno what the appropriate http code is, so find that out! Bad request (400) is generic, so maybe we can use that unless you find a better one!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure, ive added the appropriate ones

@s-gv
Copy link
Owner

s-gv commented Jun 13, 2021

Can you create a table for banned IPs (like in the wiki) and read banned IPs from that? This will also get you to setup postgres.

@lekhan05
Copy link
Collaborator Author

Can you create a table for banned IPs (like in the wiki) and read banned IPs from that? This will also get you to setup postgres.

sure , on to it.

@lekhan05
Copy link
Collaborator Author

Is this how we want to do this? I'll read up on what the gist index is. I think we might want to build some data structure (like Trie) by reading the entire table on application start instead of querying the banned_ips table on every query. We can refresh the data structure if the banned_ips table is modified (which I expect will be pretty rare).

yeah that was the intention , sure if we choose to go with the trie approach lets do it.

@lekhan05
Copy link
Collaborator Author

I think we'll want to keep the SQL queries in the "model" package and expose some API to the rest of the codebase. That way, if we make changes to the DB, we only have to re-write SQL in one package instead of all over the application!

sure was thinking to create some sort of data access module , will move it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants