Skip to content

Commit c314377

Browse files
committed
feat(xray): add Unix socket detection for inbound listeners
1 parent 3e10bd1 commit c314377

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

app/core/xray.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ def _create_base_settings(self, inbound: dict) -> dict:
146146
}
147147
return settings
148148

149+
@staticmethod
150+
def _is_unix_socket(inbound: dict) -> bool:
151+
"""Return True if the inbound listens on a Unix domain socket instead of a TCP/UDP port."""
152+
listen = inbound.get("listen", "")
153+
return isinstance(listen, str) and (listen.startswith("/") or listen.startswith("@"))
154+
149155
def _handle_port_settings(self, inbound: dict, settings: dict):
150156
"""Handle port settings for an inbound."""
151157
port_found = True
@@ -154,6 +160,10 @@ def _handle_port_settings(self, inbound: dict, settings: dict):
154160
except KeyError:
155161
port_found = False
156162

163+
# Unix socket listeners don't require a port
164+
if not port_found and self._is_unix_socket(inbound):
165+
return
166+
157167
if self._fallbacks_inbound and "<=>" not in inbound["tag"]:
158168
if inbound.get("settings", {}).get("fallbacks", []):
159169
if not port_found:

0 commit comments

Comments
 (0)