diff --git a/app/portal/__init__.py b/app/portal/__init__.py index 432219b..c608e37 100644 --- a/app/portal/__init__.py +++ b/app/portal/__init__.py @@ -5,6 +5,7 @@ from sqlalchemy import desc, or_ from app.models.activity import Activity from app.models.alarms import Alarm +from app.models.bridges import Bridge from app.models.mirrors import Origin, Proxy from app.models.base import Group from app.portal.list import NewMirrorListForm @@ -48,6 +49,16 @@ def format_datetime(s: datetime) -> str: return s.strftime("%a, %d %b %Y %H:%M:%S") +def total_origins_blocked(): + count = 0 + for o in Origin.query.filter(Origin.destroyed == None).all(): + for a in o.alarms: + if a.alarm_type.startswith("ooni"): + if a.alarm_state == AlarmState.WARNING: + count += 1 + break + return count + @portal.route("/") def portal_home(): groups = Group.query.order_by(Group.group_name).all() @@ -60,9 +71,17 @@ def portal_home(): s: len(Alarm.query.filter(Alarm.alarm_state == s.upper(), Alarm.last_updated > (now - timedelta(days=1))).all()) for s in ["critical", "warning", "ok", "unknown"] } + br_last = { + d: len(Bridge.query.filter(Bridge.deprecated > (now - timedelta(days=d))).all()) + for d in [1, 3, 7] + } activity = Activity.query.filter(Activity.added > (now - timedelta(days=2))).order_by(desc(Activity.added)).all() + onionified = len([o for o in Origin.query.filter(Origin.destroyed == None).all() if o.onion() != None]) + ooni_blocked = total_origins_blocked() + total_origins = len(Origin.query.filter(Origin.destroyed == None).all()) return render_template("home.html.j2", section="home", groups=groups, last24=last24, last72=last72, - lastweek=lastweek, proxies=proxies, **alarms, activity=activity) + lastweek=lastweek, proxies=proxies, **alarms, activity=activity, total_origins=total_origins, + onionified=onionified, br_last=br_last, ooni_blocked=ooni_blocked) @portal.route("/search") diff --git a/app/portal/templates/home.html.j2 b/app/portal/templates/home.html.j2 index 99f7de8..e265c29 100644 --- a/app/portal/templates/home.html.j2 +++ b/app/portal/templates/home.html.j2 @@ -5,29 +5,83 @@

Welcome to the Bypass Censorship portal.

-
-
-

Groups

-
-
Active Groups: {{ groups | count }}
-

{% for group in groups %}{{ group.group_name }}{{ ", " if not loop.last else "" }}{% endfor %}

-
+
+
+

Groups

+
+
Active Groups: {{ groups | count }}
+

{% for group in groups %} + {{ group.group_name }} + {{ ", " if not loop.last else "" }}{% endfor %}

+
+
+
+
+
+

Proxies

+
+
Total proxies running: {{ proxies | count }}
+

Marked blocked: +

    +
  • Last 24 hours: {{ last24 }}
  • +
  • Last 72 hours: {{ last72 }}
  • +
  • Last week: {{ lastweek }}
  • +
+
+
+
+
+
+

Tor Bridges

+
+
Total bridges running: {{ bridges | count }}
+

Marked blocked: +

    +
  • Last 24 hours: {{ br_last[1] }}
  • +
  • Last 72 hours: {{ br_last[3] }}
  • +
  • Last week: {{ br_last[7] }}
  • +
+
+
+
-
-
-
-

Proxies

-
-
Total proxies running: {{ proxies | count }}
-

Marked blocked: -

    -
  • Last 24 hours: {{ last24 }}
  • -
  • Last 72 hours: {{ last72 }}
  • -
  • Last week: {{ lastweek }}
  • -
-
-
-
+ +
+
+
+

Onion Services

+
+
Onionification progress:
+

{{ onionified }}/{{ total_origins }}

+
+
{{ (onionified / total_origins * 100) | int }}% +
+
+
+
+
+ +
+
+

OONI

+
+
Origins with censorship detected:
+

{{ ooni_blocked }}/{{ total_origins }}

+
+
{{ (ooni_blocked / total_origins * 100) | int }}% +
+
+
+
+
+

Alarms

@@ -44,6 +98,7 @@
+
@@ -51,10 +106,10 @@
{% for a in activity %} - - - - + + + + {% endfor %}
{{ a.text }}{{ a.added | format_datetime }}
{{ a.text }}{{ a.added | format_datetime }}