feat: заготовка для динамических dataclass Outbound
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import secrets
|
||||
import uuid
|
||||
from abc import ABC, abstractmethod
|
||||
from collections import defaultdict
|
||||
from dataclasses import dataclass, make_dataclass
|
||||
from typing import TYPE_CHECKING, TypeVar
|
||||
from urllib.parse import parse_qs, quote, unquote, urlencode, urlparse
|
||||
|
||||
from .outbound_fields import OUTBOUND_FIELDS
|
||||
|
||||
|
||||
class Outbound(ABC):
|
||||
pass
|
||||
|
||||
|
||||
_ShadowsocksFields = make_dataclass(
|
||||
"_ShadowsocksFields", fields=OUTBOUND_FIELDS["shadowsocks"]
|
||||
)
|
||||
|
||||
|
||||
class ShadowsocksOutbound(_ShadowsocksFields, Outbound):
|
||||
pass
|
||||
|
||||
|
||||
_VlessFields = make_dataclass(
|
||||
"_VlessFieldss", fields=OUTBOUND_FIELDS["vless"]
|
||||
)
|
||||
|
||||
|
||||
class VlessOutbound(_VlessFields, Outbound):
|
||||
pass
|
||||
@@ -0,0 +1,29 @@
|
||||
from dataclasses import field
|
||||
|
||||
|
||||
_BASE_FIELDS = [
|
||||
("host", str),
|
||||
("port", str),
|
||||
("target", str),
|
||||
]
|
||||
|
||||
|
||||
OUTBOUND_FIELDS = {
|
||||
"shadowsocks": _BASE_FIELDS + [
|
||||
("method", str),
|
||||
("server_password", str),
|
||||
("client_password", str),
|
||||
],
|
||||
"vless": _BASE_FIELDS + [
|
||||
("id", str),
|
||||
("security", str),
|
||||
("encryption", str),
|
||||
("public_key", str),
|
||||
("network_type", str),
|
||||
("sni", str),
|
||||
("short_id", str),
|
||||
("flow", str, field(default="xtls-rprx-vision")),
|
||||
("header_type", str, field(default="none")),
|
||||
("finger_print", str, field(default="chrome"))
|
||||
],
|
||||
}
|
||||
Reference in New Issue
Block a user