mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-27 15:45:56 -05:00
evrtsp: Handle IPv6 scoped addresses
This commit is contained in:
parent
01cde2c50c
commit
deae610965
@ -1237,18 +1237,33 @@ struct evrtsp_connection *
|
||||
evrtsp_connection_new(const char *address, unsigned short port)
|
||||
{
|
||||
struct evrtsp_connection *evcon = NULL;
|
||||
char *intf;
|
||||
char *addr;
|
||||
unsigned char scratch[16];
|
||||
int family;
|
||||
|
||||
if (inet_pton(AF_INET6, address, scratch) == 1)
|
||||
|
||||
if ((addr = strdup(address)) == NULL) {
|
||||
event_warn("%s: strdup failed", __func__);
|
||||
goto error;
|
||||
}
|
||||
|
||||
intf = strchr(addr, '%');
|
||||
if (intf)
|
||||
*intf = '\0';
|
||||
|
||||
if (inet_pton(AF_INET6, addr, scratch) == 1)
|
||||
family = AF_INET6;
|
||||
else if (inet_pton(AF_INET, address, scratch) == 1)
|
||||
else if (inet_pton(AF_INET, addr, scratch) == 1)
|
||||
family = AF_INET;
|
||||
else {
|
||||
free(addr);
|
||||
event_warn("%s: address is neither IPv6 nor IPv4", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (intf)
|
||||
*intf = '%';
|
||||
|
||||
event_debug(("Attempting connection to %s:%d\n", address, port));
|
||||
|
||||
if ((evcon = calloc(1, sizeof(struct evrtsp_connection))) == NULL) {
|
||||
@ -1264,11 +1279,7 @@ evrtsp_connection_new(const char *address, unsigned short port)
|
||||
evcon->cseq = 1;
|
||||
|
||||
evcon->family = family;
|
||||
|
||||
if ((evcon->address = strdup(address)) == NULL) {
|
||||
event_warn("%s: strdup failed", __func__);
|
||||
goto error;
|
||||
}
|
||||
evcon->address = addr;
|
||||
|
||||
if ((evcon->input_buffer = evbuffer_new()) == NULL) {
|
||||
event_warn("%s: evbuffer_new failed", __func__);
|
||||
|
Loading…
Reference in New Issue
Block a user