Il giorno lun 18 lug 2022 alle ore 09:06 Frediano Ziglio <freddy77@xxxxxxxxx> ha scritto: > > Il giorno lun 18 lug 2022 alle ore 08:56 bob cantor > <bobc@xxxxxxxxxxxxx> ha scritto: > > > > Is it possible to connect to xspice via a unix-socket rather than a tcp-port? (I would like to connect to xspice running in a LXC comtainer. The container and host are on the same machine, but there is no network connection between them). > > > > Hi, > currently only TCP is supported but the change should not be that difficult. > Hi, something like this should do (not tested): diff --git a/src/listen.c b/src/listen.c index d00358d..292b20a 100644 --- a/src/listen.c +++ b/src/listen.c @@ -39,12 +39,15 @@ #include <arpa/inet.h> #include <errno.h> +#include <spice.h> + #include "listen.h" #include "x11spice.h" #define SPICE_URI_PREFIX "spice://" +#define SPICE_UNIX_URI_PREFIX "spice+unix://" -int listen_parse(const char *listen_spec, char **addr, int *port_start, int *port_end) +int listen_parse(const char *listen_spec, char **addr, int *port_start, int *port_end, int *flags) { int leading = 0; int trailing = 0; @@ -54,6 +57,15 @@ int listen_parse(const char *listen_spec, char **addr, int *port_start, int *por *port_start = *port_end = -1; *addr = NULL; + *flags = 0; + + if (strncmp(listen_spec, SPICE_UNIX_URI_PREFIX, strlen(SPICE_UNIX_URI_PREFIX)) == 0) { + listen_spec += strlen(SPICE_UNIX_URI_PREFIX); + + *flags = SPICE_ADDR_FLAG_UNIX_ONLY; + *addr = strdup(listen_spec); + return 0; + } /* Allow form of spice:// */ if (strlen(listen_spec) > strlen(SPICE_URI_PREFIX)) diff --git a/src/listen.h b/src/listen.h index 78f8792..86d5594 100644 --- a/src/listen.h +++ b/src/listen.h @@ -25,7 +25,7 @@ /*---------------------------------------------------------------------------- ** Prototypes **--------------------------------------------------------------------------*/ -int listen_parse(const char *listen_spec, char **addr, int *port_start, int *port_end); +int listen_parse(const char *listen_spec, char **addr, int *port_start, int *port_end, int *flags); int listen_find_open_port(const char *addr, int start, int end, int *port); #endif diff --git a/src/spice.c b/src/spice.c index 0c6c610..fe5be17 100644 --- a/src/spice.c +++ b/src/spice.c @@ -582,9 +582,10 @@ static int try_listen(spice_t *s, options_t *options) char *addr = NULL; int start; int rc; + int flags; - rc = listen_parse(options->listen, &addr, &start, &port); + rc = listen_parse(options->listen, &addr, &start, &port, &flags); if (rc) return rc; @@ -599,7 +600,7 @@ static int try_listen(spice_t *s, options_t *options) } if (addr) { - spice_server_set_addr(s->server, addr, 0); + spice_server_set_addr(s->server, addr, flags); free(addr); } Frediano