Skip to content

Commit 6cb0d03

Browse files
fix(xray): improve port validation for Unix socket listeners
1 parent db132e3 commit 6cb0d03

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

app/core/xray.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,21 +160,20 @@ def _handle_port_settings(self, inbound: dict, settings: dict):
160160
except KeyError:
161161
port_found = False
162162

163-
# Unix socket listeners don't require a port
164-
if not port_found and self._is_unix_socket(inbound):
165-
return
163+
is_unix_socket = self._is_unix_socket(inbound)
166164

167165
if self._fallbacks_inbound and "<=>" not in inbound["tag"]:
168166
if inbound.get("settings", {}).get("fallbacks", []):
169-
if not port_found:
167+
if not port_found and not is_unix_socket:
170168
raise ValueError(f"{settings['tag']} inbound doesn't have port")
171-
else:
172-
return
169+
return
173170
fallbacks = self._find_fallback_inbound(inbound)
174171
if fallbacks:
175172
settings["is_fallback"] = True
176173
settings["fallbacks"] = fallbacks
177-
elif not port_found:
174+
return
175+
176+
if not port_found and not is_unix_socket:
178177
raise ValueError(f"{settings['tag']} inbound doesn't have port")
179178

180179
def _handle_tls_settings(self, tls_settings: dict, settings: dict, inbound_tag: str):

0 commit comments

Comments
 (0)