kopia lustrzana https://github.com/snarfed/bridgy-fed
atproto_hub /admin/atproto: highlight bluesky team servers
rodzic
732f2d2a60
commit
56b9509663
|
@ -1,5 +1,6 @@
|
||||||
"""Single-instance hub for ATProto subscription (firehose) server and client."""
|
"""Single-instance hub for ATProto subscription (firehose) server and client."""
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
|
from ipaddress import ip_address, ip_network
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
@ -21,9 +22,12 @@ import atproto_firehose
|
||||||
from common import global_cache, global_cache_timeout_policy, USER_AGENT
|
from common import global_cache, global_cache_timeout_policy, USER_AGENT
|
||||||
import models
|
import models
|
||||||
|
|
||||||
# CIDRs: 209.249.133.120/29, 108.179.139.0/24
|
# as of 2024-07-10
|
||||||
# https://discord.com/channels/1097580399187738645/1115973909624397855/1260356452162469969
|
# https://discord.com/channels/1097580399187738645/1115973909624397855/1260356452162469969
|
||||||
BSKY_RELAY_CIDRS = (')
|
BSKY_TEAM_CIDRS = (
|
||||||
|
ip_network('209.249.133.120/29'),
|
||||||
|
ip_network('108.179.139.0/24'),
|
||||||
|
)
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -72,6 +76,10 @@ def atproto_commit():
|
||||||
@lru_cache
|
@lru_cache
|
||||||
def gethostbyaddr(addr):
|
def gethostbyaddr(addr):
|
||||||
"""Wrapper for :func:``socket.gethostbyaddr` that caches the result."""
|
"""Wrapper for :func:``socket.gethostbyaddr` that caches the result."""
|
||||||
|
for subnet in BSKY_TEAM_CIDRS:
|
||||||
|
if ip_address(addr) in subnet:
|
||||||
|
return 'bsky'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return socket.gethostbyaddr(addr)[0]
|
return socket.gethostbyaddr(addr)[0]
|
||||||
except socket.herror:
|
except socket.herror:
|
||||||
|
|
|
@ -12,7 +12,9 @@
|
||||||
<li>{{ nsid }}
|
<li>{{ nsid }}
|
||||||
<ul>
|
<ul>
|
||||||
{% for s in subs %}
|
{% for s in subs %}
|
||||||
<li>{{ s.ip }} {{ gethostbyaddr(s.ip) }} {{s.user_agent }} {{ s.args }} {{ s.start }}
|
{% set host = gethostbyaddr(s.ip) %}
|
||||||
|
<li {% if host == 'bsky' %}style="background-color: lightgreen"{% endif %}>
|
||||||
|
{{ s.ip }} {{ host }} {{s.user_agent }} {{ s.args }} {{ s.start }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<ul>
|
<ul>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
Ładowanie…
Reference in New Issue