pulse-server: add support for IPv6

Add support for listening on IPv6 addresses.
The following address formats are supported:
 * tcp:[<ipv6-addr>]:<port>,
 * tcp:<ipv4-addr>:<port>,
 * tcp:<port>, and
 * unix:<path>.

The IP addresses are parsed using `inet_pton()`,
only the formats supported by that function
are accepted.

The IPv6 address must be surrounded by square brackets,
they do not mean "optional" here. Specifying only the
port is equivalent to the following two addresses:
 * [::]:<port>, and
 * 0.0.0.0:<port>.

Address parsing has been made stricter: the port
must always be specified explicitly.

Fixes #1216.
This commit is contained in:
Barnabás Pőcze 2021-05-26 04:00:08 +02:00
parent 279470bc07
commit 48f03f85a7
4 changed files with 521 additions and 191 deletions

View file

@ -28,7 +28,6 @@
#include "config.h"
#include <sys/socket.h>
#include <sys/un.h>
#include <spa/utils/defs.h>
#include <spa/utils/ringbuffer.h>
@ -195,11 +194,7 @@ struct server {
struct spa_list link;
struct impl *impl;
#define SERVER_TYPE_INVALID 0
#define SERVER_TYPE_UNIX 1
#define SERVER_TYPE_INET 2
uint32_t type;
struct sockaddr_un addr;
struct sockaddr_storage addr;
struct spa_source *source;
struct spa_list clients;
@ -230,7 +225,7 @@ struct impl {
struct stats stat;
};
struct server *create_server(struct impl *impl, const char *address);
int create_and_start_servers(struct impl *impl, const char *addresses, struct pw_array *servers);
void server_free(struct server *server);
#endif