ncsa / bhr-site Goto Github PK
View Code? Open in Web Editor NEWBlackhole Router Site
License: Other
Blackhole Router Site
License: Other
I received this from a do_unblock in the browser, for an IP that had been previously whitelisted. Removing the whitelist entry allowed the do_unblock action from the browser to proceed.
Environment:
Request Method: POST
Request URL: https://[hostname]/bhr/do_unblock
Django Version: 1.7.4
Python Version: 2.7.10
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'rest_framework.authtoken',
'django_forms_bootstrap',
'bhr')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback:
File "/opt/app/rtbh/venv/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/app/rtbh/venv/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
21. return view_func(request, *args, **kwargs)
File "/opt/app/rtbh/venv/lib/python2.7/site-packages/django/views/generic/base.py" in view
69. return self.dispatch(request, *args, **kwargs)
File "/opt/app/rtbh/venv/lib/python2.7/site-packages/django/views/generic/base.py" in dispatch
87. return handler(request, *args, **kwargs)
File "/opt/app/rtbh/venv/lib/python2.7/site-packages/django/views/generic/edit.py" in post
173. return self.form_valid(form)
File "/opt/app/rtbh/bhr/browser_views.py" in form_valid
66. b.unblock_now(self.request.user, why)
File "/opt/app/rtbh/bhr/models.py" in unblock_now
184. self.save()
File "/opt/app/rtbh/bhr/models.py" in save
143. raise WhitelistError(wle.why)
Exception Type: WhitelistError at /bhr/do_unblock
Exception Value: [redacted]
Just realized that the query page and API don't show unblock_who or unblock_why
The end user site doesn't have a link to /admin anywhere for managing the whitelist/users/etc.
Probably makes more sense to display duration for old blocks, and duration remaining for current blocks, perhaps with the unblock time as the tooltip.
I replaced the index on forced_unblock with
create index bhr_block_forced_unblocked_true on bhr_block ( forced_unblock) where forced_unblock=true;
Which should accomplish the same thing but save 10% of the size of the DB and speed things up a bit.
It looks like this can't be specified in models.py, but I can use
migrations.RunSQL('create index bhr_block_forced_unblocked_true on bhr_block ( forced_unblock) where forced_unblock=true')
In a migration to add the better performing index.
Need to use something like this for each link
<li role="presentation" {% if request.resolver_match.url_name == 'home' %}class="active"{% endif %}>
<a href="{% url 'home' %}">Home</a>
</li>
or write/find a helper that does that for me.
Checking this setting at import time and modifying the urlpatterns makes it impossible to use @override_settings during testing.
I feel like I optimized this query a while ago to make it fast when there were many pending blocks, but now it seems that it is slow when there are a large number of current blocks.
The custom query that block_queue runs is still fast, so PendingBlockManager probably just needs to be made to ran a similar query.
When I run:
docker-compose run --rm web python manage.py migrate
I get this error:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 83, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "/usr/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 20, in __init__
self.loader = MigrationLoader(self.connection)
File "/usr/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 52, in __init__
self.build_graph()
File "/usr/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 210, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/usr/local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 65, in applied_migrations
self.ensure_schema()
File "/usr/local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 52, in ensure_schema
if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
File "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 254, in cursor
return self._cursor()
File "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 229, in _cursor
self.ensure_connection()
File "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
self.connect()
File "/usr/local/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
self.connect()
File "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 189, in connect
self.connection = self.get_new_connection(conn_params)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/postgresql/base.py", line 176, in get_new_connection
connection = Database.connect(**conn_params)
File "/usr/local/lib/python2.7/site-packages/psycopg2/__init__.py", line 126, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Also when I clone repo and run docker-compose I get error from psql. I repair it with:
db:
image: postgres
environment:
POSTGRES_DB: bhr
POSTGRES_HOST_AUTH_METHOD: trust
A minimum prefix length of /24 does not mean the same thing for ipv6, so I need to split up the setting into a v4 and a v6 option.
I'd like to clear the history for an IP once I query it.
Right now there is the query view that is for historical data, but there needs to be a way to hit the current list view and filter by cidr/source/etc.
I added the /bhrlist/source
view but I think that should be removed and /list itself should accept source,cidr,who,reason,etc filter params.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.