fix: 优化 endpoint 的 ipv6 支持

pull/12255/head
ibuler 2023-12-05 14:29:08 +08:00 committed by 老广
parent d2eacad97b
commit e812e3ff89
1 changed files with 7 additions and 1 deletions

View File

@ -131,5 +131,11 @@ class EndpointRule(JMSBaseModel):
endpoint = Endpoint.get_or_create_default(request)
if not endpoint.host and request:
# 动态添加 current request host
endpoint.host = request.get_host().split(':')[0]
host_port = request.get_host()
# IPv6
if host_port.startswith('['):
host = host_port.split(']:')[0].rstrip(']') + ']'
else:
host = host_port.split(':')[0]
endpoint.host = host
return endpoint