fix: 补上清单里还没对上的登录拒绝、会话回退和代理清理
This commit is contained in:
@@ -393,6 +393,7 @@ def _refresh_body() -> dict:
|
||||
new_ids: list[int] = []
|
||||
alive_ids: list[int] = []
|
||||
dead_ids: list[int] = []
|
||||
seen_at = _now()
|
||||
for item in candidates:
|
||||
if not is_china(item.country):
|
||||
continue
|
||||
@@ -407,6 +408,7 @@ def _refresh_body() -> dict:
|
||||
anonymity=item.anonymity,
|
||||
source=item.source,
|
||||
status=STATUS_NEW,
|
||||
last_seen_at=seen_at,
|
||||
)
|
||||
db.add(node)
|
||||
db.flush()
|
||||
@@ -416,6 +418,7 @@ def _refresh_body() -> dict:
|
||||
node.country = item.country or node.country
|
||||
node.anonymity = item.anonymity or node.anonymity
|
||||
node.source = item.source or node.source
|
||||
node.last_seen_at = seen_at
|
||||
if node.status == STATUS_DEAD:
|
||||
dead_ids.append(node.id)
|
||||
continue
|
||||
@@ -423,6 +426,15 @@ def _refresh_body() -> dict:
|
||||
new_ids.append(node.id)
|
||||
elif node.status == STATUS_ALIVE:
|
||||
alive_ids.append(node.id)
|
||||
stale_before = seen_at - timedelta(days=7)
|
||||
held = set(_holds.values())
|
||||
for node in list(existing.values()):
|
||||
if node.id in held or node.status != STATUS_DEAD:
|
||||
continue
|
||||
seen = _aware(node.last_seen_at)
|
||||
if seen is not None and seen < stale_before:
|
||||
db.delete(node)
|
||||
existing.pop((node.scheme, node.host, int(node.port)), None)
|
||||
for node in existing.values():
|
||||
if node.id in alive_ids or node.id in new_ids or node.id in dead_ids:
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user