Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: ssr/Vmess/vless proxy type #790

Merged
merged 5 commits into from
Feb 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
57 changes: 51 additions & 6 deletions apps/proxy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@


class XRayTags:

APITag = "api"
SSProxyTag = "ss_proxy"
TrojanProxyTag = "trojan_proxy"
SSRProxyTag = "ssr_proxy"
VmessProxyTag = "vmess_proxy"
VlessProxyTag = "vless_proxy"


class XRayTemplates:

DEFAULT_CONFIG = {
"stats": {},
"api": {
Expand Down Expand Up @@ -73,6 +74,14 @@ class XRayTemplates:
"settings": {"clients": [], "network": "tcp"},
}

SSR_INBOUND = {
Ehco1996 marked this conversation as resolved.
Show resolved Hide resolved
"listen": "192.168.0.0",
"port": 0,
"protocol": "shadowsocksr",
"tag": XRayTags.SSRProxyTag,
"settings": {"clients": [], "network": "tcp"},
}

TROJAN_INBOUND = {
"listen": "0.0.0.0",
"port": 0,
Expand All @@ -90,6 +99,40 @@ class XRayTemplates:
},
}

VMESS_INBOUND = {
"listen": "192.168.0.0",
"port": 0,
"protocol": "vmess",
"tag": XRayTags.VmessProxyTag,
"settings": {
"clients": [],
"network": "tcp",
"fallbacks": [{"dest": ""}],
},
"streamSettings": {
"network": "tcp",
"security": "tls",
"tlsSettings": {"alpn": ["http/1.1"]},
},
}

VLESS_INBOUND = {
"listen": "192.168.0.0",
"port": 0,
"protocol": "vless",
"tag": XRayTags.VlessProxyTag,
"settings": {
"clients": [],
"network": "tcp",
"fallbacks": [{"dest": ""}],
},
"streamSettings": {
"network": "tcp",
"security": "tls",
"tlsSettings": {"alpn": ["http/1.1"]},
},
}

@classmethod
def gen_base_config(cls, xray_grpc_port, log_level):
xray_config = deepcopy(XRayTemplates.DEFAULT_CONFIG)
Expand All @@ -108,12 +151,17 @@ class Meta:


class ProxyNode(BaseNodeModel, SequenceMixin):

NODE_TYPE_SS = "ss"
NODE_TYPE_TROJAN = "trojan"
NODE_TYPE_SSR = "ssr"
NODE_TYPE_VMESS = "vmess"
NODE_TYPE_VLESS = "vless"
NODE_CHOICES = (
(NODE_TYPE_SS, NODE_TYPE_SS),
(NODE_TYPE_TROJAN, NODE_TYPE_TROJAN),
(NODE_TYPE_SSR, NODE_TYPE_SSR),
(NODE_TYPE_VMESS, NODE_TYPE_VMESS),
(NODE_TYPE_VLESS, NODE_TYPE_VLESS),
)

EHCO_LOG_LEVELS = (
Expand Down Expand Up @@ -462,7 +510,6 @@ def __str__(self) -> str:


class RelayNode(BaseNodeModel):

CMCC = "移动"
CUCC = "联通"
CTCC = "电信"
Expand Down Expand Up @@ -557,7 +604,6 @@ def api_endpoint(self):


class RelayRule(BaseModel):

rule_name = models.CharField(
"规则名", max_length=64, blank=True, null=False, default=""
)
Expand Down Expand Up @@ -613,7 +659,6 @@ def remark(self):


class UserTrafficLog(BaseLogModel):

user = models.ForeignKey(
User, on_delete=models.DO_NOTHING, verbose_name="用户", null=True
)
Expand Down