Skip to content

Support AF_UNIX sockets for mpd #1531

@dondelelcaro

Description

@dondelelcaro

It would be great if mopidy supported AF_UNIX style sockets for mpd instead of listening on localhost. [This is especially useful for configurations where mopidy is running as a user, and may have a conflict on localhost:6600.]

Something like the following would probably work (but there's probably a better, more general method.)

diff --git a/mopidy/internal/network.py b/mopidy/internal/network.py
index cefdf8e..ae5a87b 100644
--- a/mopidy/internal/network.py
+++ b/mopidy/internal/network.py
@@ -79,9 +79,14 @@ class Server(object):
         self.register_server_socket(self.server_socket.fileno())

     def create_server_socket(self, host, port):
-        sock = create_socket()
-        sock.setblocking(False)
-        sock.bind((host, port))
+        if (re.match(r'/',host):
+            sock = socket.socket(socket.AF_UNIX)
+            sock.setblocking(False)
+            sock.bind(host)
+        else:
+            sock = create_socket()
+            sock.setblocking(False)
+            sock.bind((host, port))
         sock.listen(1)
         return sock

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions