mirror of
https://git.pleroma.social/pleroma/relay.git
synced 2024-11-09 18:08:00 +00:00
add software name for inboxes
This commit is contained in:
parent
d4955828d4
commit
9369b598fa
|
@ -9,7 +9,7 @@ from datetime import datetime, timedelta
|
|||
|
||||
from .config import RelayConfig
|
||||
from .database import RelayDatabase
|
||||
from .misc import DotDict, check_open_port, set_app
|
||||
from .misc import DotDict, check_open_port, fetch_nodeinfo, set_app
|
||||
from .views import routes
|
||||
|
||||
|
||||
|
@ -25,15 +25,16 @@ class Application(web.Application):
|
|||
if not self['config'].load():
|
||||
self['config'].save()
|
||||
|
||||
self['database'] = RelayDatabase(self['config'])
|
||||
self['database'].load()
|
||||
|
||||
self['cache'] = DotDict({key: Cache(maxsize=self['config'][key]) for key in self['config'].cachekeys})
|
||||
self['semaphore'] = asyncio.Semaphore(self['config'].push_limit)
|
||||
|
||||
self.set_signal_handler()
|
||||
set_app(self)
|
||||
|
||||
self['database'] = RelayDatabase(self['config'])
|
||||
self['database'].load()
|
||||
|
||||
self.set_signal_handler()
|
||||
|
||||
|
||||
@property
|
||||
def cache(self):
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import asyncio
|
||||
import json
|
||||
import logging
|
||||
import traceback
|
||||
|
@ -5,6 +6,8 @@ import traceback
|
|||
from Crypto.PublicKey import RSA
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from .misc import fetch_nodeinfo
|
||||
|
||||
|
||||
class RelayDatabase(dict):
|
||||
def __init__(self, config):
|
||||
|
@ -75,9 +78,18 @@ class RelayDatabase(dict):
|
|||
else:
|
||||
self['relay-list'] = data.get('relay-list', {})
|
||||
|
||||
for domain in self['relay-list'].keys():
|
||||
for domain, instance in self['relay-list'].items():
|
||||
if self.config.is_banned(domain) or (self.config.whitelist_enabled and not self.config.is_whitelisted(domain)):
|
||||
self.del_inbox(domain)
|
||||
continue
|
||||
|
||||
if not instance.get('software'):
|
||||
nodeinfo = asyncio.run(fetch_nodeinfo(domain))
|
||||
|
||||
if not nodeinfo:
|
||||
continue
|
||||
|
||||
instance['software'] = nodeinfo.swname
|
||||
|
||||
new_db = False
|
||||
|
||||
|
|
Loading…
Reference in a new issue