Skip to content

Commit

Permalink
chore: fix many issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehco1996 committed Aug 25, 2024
1 parent 4ea6791 commit a04a13f
Show file tree
Hide file tree
Showing 6 changed files with 511 additions and 498 deletions.
65 changes: 12 additions & 53 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,14 @@
version: 2
updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
ignore:
- dependency-name: black
versions:
- 21.4b0
- 21.4b1
- dependency-name: django-simpleui
versions:
- "2021.2"
- "2021.4"
- 2021.4.1
- 2021.4.3
- dependency-name: isort
versions:
- 5.7.0
- 5.8.0
- dependency-name: django-countries
versions:
- "7.0"
- "7.1"
- dependency-name: sentry-sdk
versions:
- 0.19.5
- 0.20.0
- 0.20.1
- 0.20.2
- 0.20.3
- 1.0.0
- dependency-name: markdown
versions:
- 3.3.4
- dependency-name: django-anymail
versions:
- "8.2"
- dependency-name: django
versions:
- 3.1.6
- 3.1.7
- dependency-name: python-alipay-sdk
versions:
- 2.3.0
- 3.0.0
- 3.0.1
- dependency-name: mysqlclient
versions:
- 2.0.3
- dependency-name: celery
versions:
- 5.0.5
- package-ecosystem: pip
directory: "/"
schedule:
interval: weekly
groups:
# Specify a name for the group, which will be used in pull request titles
# and branch names
dependencies:
# Define patterns to include dependencies in the group (based on
# dependency name)
patterns:
- "*" # A wildcard that matches all dependencies in the package
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ update:
fmt:
isort .
ruff format .
djlint --reformat .

fmt-templates:
djlint --reformat templates/

check:
Expand Down
15 changes: 4 additions & 11 deletions apps/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,30 +76,23 @@

# ehco隧道相关
LISTEN_RAW = "raw"
LISTEN_WS = "ws"
LISTEN_WSS = "wss"
LISTEN_MWSS = "mwss"
LISTEN_MTCP = "mtcp"
LISTEN_TYPES = (
(LISTEN_RAW, "raw"),
(LISTEN_WS, "ws"),
(LISTEN_WSS, "wss"),
(LISTEN_MWSS, "mwss"),
(LISTEN_MTCP, "mtcp"),
)

TRANSPORT_RAW = "raw"
TRANSPORT_WS = "ws"
TRANSPORT_WSS = "wss"
TRANSPORT_MWSS = "mwss"
TRANSPORT_MTCP = "mtcp"
TRANSPORT_TYPES = (
(TRANSPORT_RAW, "raw"),
(TRANSPORT_WS, "ws"),
(TRANSPORT_WSS, "wss"),
(TRANSPORT_MWSS, "mwss"),
(TRANSPORT_MTCP, "mtcp"),
)

WS_LISTENERS = {LISTEN_WSS, LISTEN_MWSS}
WS_TRANSPORTS = {TRANSPORT_WSS, TRANSPORT_MWSS}


CACHE_TTL_HOUR = 60 * 60
CACHE_TTL_DAY = CACHE_TTL_HOUR * 24
Expand Down
41 changes: 21 additions & 20 deletions apps/proxy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ def get_proxy_configs(self):

def get_ehco_server_config(self):
if self.enable_ehco_tunnel:
tcp_remotes = [f"127.0.0.1:{self.ehco_relay_port}"]
return {
"web_port": self.ehco_web_port,
"web_token": self.ehco_web_token,
Expand All @@ -352,8 +353,8 @@ def get_ehco_server_config(self):
"listen": f"{self.ehco_listen_host}:{self.ehco_listen_port}",
"listen_type": self.ehco_listen_type,
"transport_type": self.ehco_transport_type,
"tcp_remotes": [f"127.0.0.1:{self.ehco_relay_port}"],
"udp_remotes": [],
"tcp_remotes": tcp_remotes,
"remotes": tcp_remotes,
}
],
}
Expand Down Expand Up @@ -689,34 +690,34 @@ def get_config(self):
# NOTE 这里要求代理节点的隧道监听类型一致
nodes: List[ProxyNode] = rule.proxy_nodes.all()
tcp_remotes = []
udp_remotes = []
for proxy_node in nodes:
if not proxy_node.enable:
continue
if (
proxy_node.enable_ehco_tunnel
and rule.transport_type != c.TRANSPORT_RAW
):
tcp_remote = f"{proxy_node.server}:{proxy_node.ehco_listen_port}"
else:

if not proxy_node.enable_ehco_tunnel:
tcp_remote = f"{proxy_node.server}:{proxy_node.get_user_port()}"
if rule.transport_type in c.WS_TRANSPORTS:
tcp_remote = f"wss://{tcp_remote}"
if self.enable_udp and proxy_node.enable_udp:
udp_remotes.append(
f"{proxy_node.server}:{proxy_node.get_user_port()}"
)
else:
tcp_remote = f"{proxy_node.server}:{proxy_node.ehco_listen_port}"
if rule.transport_type == c.TRANSPORT_WS:
tcp_remote = f"ws://{tcp_remote}"
elif rule.transport_type == c.TRANSPORT_WSS:
tcp_remote = f"wss://{tcp_remote}"
else:
raise Exception("not support transport type")
tcp_remotes.append(tcp_remote)
relay_configs.append(
{
rule_cfg = {
"label": rule.name,
"listen": f"0.0.0.0:{rule.relay_port}",
"listen_type": rule.listen_type,
"tcp_remotes": tcp_remotes,
"udp_remotes": udp_remotes,
"transport_type": rule.transport_type,
"tcp_remotes": tcp_remotes,
"remotes": tcp_remotes,
"options": {
"enable_multipath_tcp": True,
"enable_udp": rule.enable_udp and proxy_node.enable_udp,
},
}
)
relay_configs.append(rule_cfg)
cfg = {
"enable_ping": self.enable_ping,
"relay_configs": relay_configs,
Expand Down
Loading

0 comments on commit a04a13f

Please sign in to comment.