Merge pull request #933 from nhannam/raop-configurable-ports

[raop] Allow configuration of raop control and timing ports
This commit is contained in:
ejurgensen 2020-04-12 19:49:49 +02:00 committed by GitHub
commit 90eb333f03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 4 deletions

View File

@ -276,6 +276,15 @@ audio {
# path = "/path/to/fifo" # path = "/path/to/fifo"
#} #}
# AirPlay/Airport Express settings
# common to all devices
#airplay_shared {
# UDP ports used when airplay devices make connections back to forked-daapd
# (choosing specific ports may be helpful when running forked-daapd behind a firewall)
# control_port = 0
# timing_port = 0
#}
# AirPlay/Airport Express device settings # AirPlay/Airport Express device settings
# (make sure you get the capitalization of the device name right) # (make sure you get the capitalization of the device name right)
#airplay "My AirPlay device" { #airplay "My AirPlay device" {

View File

@ -137,6 +137,14 @@ static cfg_opt_t sec_alsa[] =
CFG_END() CFG_END()
}; };
/* AirPlay/ApEx shared section structure */
static cfg_opt_t sec_airplay_shared[] =
{
CFG_INT("control_port", 0, CFGF_NONE),
CFG_INT("timing_port", 0, CFGF_NONE),
CFG_END()
};
/* AirPlay/ApEx device section structure */ /* AirPlay/ApEx device section structure */
static cfg_opt_t sec_airplay[] = static cfg_opt_t sec_airplay[] =
{ {
@ -215,6 +223,7 @@ static cfg_opt_t toplvl_cfg[] =
CFG_SEC("library", sec_library, CFGF_NONE), CFG_SEC("library", sec_library, CFGF_NONE),
CFG_SEC("audio", sec_audio, CFGF_NONE), CFG_SEC("audio", sec_audio, CFGF_NONE),
CFG_SEC("alsa", sec_alsa, CFGF_MULTI | CFGF_TITLE), CFG_SEC("alsa", sec_alsa, CFGF_MULTI | CFGF_TITLE),
CFG_SEC("airplay_shared", sec_airplay_shared, CFGF_NONE),
CFG_SEC("airplay", sec_airplay, CFGF_MULTI | CFGF_TITLE), CFG_SEC("airplay", sec_airplay, CFGF_MULTI | CFGF_TITLE),
CFG_SEC("chromecast", sec_chromecast, CFGF_MULTI | CFGF_TITLE), CFG_SEC("chromecast", sec_chromecast, CFGF_MULTI | CFGF_TITLE),
CFG_SEC("fifo", sec_fifo, CFGF_NONE), CFG_SEC("fifo", sec_fifo, CFGF_NONE),

View File

@ -3064,6 +3064,7 @@ raop_v2_timing_start_one(struct raop_service *svc, int family)
int on; int on;
int len; int len;
int ret; int ret;
int timing_port;
#ifdef SOCK_CLOEXEC #ifdef SOCK_CLOEXEC
svc->fd = socket(family, SOCK_DGRAM | SOCK_CLOEXEC, 0); svc->fd = socket(family, SOCK_DGRAM | SOCK_CLOEXEC, 0);
@ -3092,17 +3093,18 @@ raop_v2_timing_start_one(struct raop_service *svc, int family)
memset(&sa, 0, sizeof(union sockaddr_all)); memset(&sa, 0, sizeof(union sockaddr_all));
sa.ss.ss_family = family; sa.ss.ss_family = family;
timing_port = cfg_getint(cfg_getsec(cfg, "airplay_shared"), "timing_port");
switch (family) switch (family)
{ {
case AF_INET: case AF_INET:
sa.sin.sin_addr.s_addr = INADDR_ANY; sa.sin.sin_addr.s_addr = INADDR_ANY;
sa.sin.sin_port = 0; sa.sin.sin_port = htons(timing_port);
len = sizeof(sa.sin); len = sizeof(sa.sin);
break; break;
case AF_INET6: case AF_INET6:
sa.sin6.sin6_addr = in6addr_any; sa.sin6.sin6_addr = in6addr_any;
sa.sin6.sin6_port = 0; sa.sin6.sin6_port = htons(timing_port);
len = sizeof(sa.sin6); len = sizeof(sa.sin6);
break; break;
} }
@ -3316,6 +3318,7 @@ raop_v2_control_start_one(struct raop_service *svc, int family)
int on; int on;
int len; int len;
int ret; int ret;
int control_port;
#ifdef SOCK_CLOEXEC #ifdef SOCK_CLOEXEC
svc->fd = socket(family, SOCK_DGRAM | SOCK_CLOEXEC, 0); svc->fd = socket(family, SOCK_DGRAM | SOCK_CLOEXEC, 0);
@ -3344,17 +3347,18 @@ raop_v2_control_start_one(struct raop_service *svc, int family)
memset(&sa, 0, sizeof(union sockaddr_all)); memset(&sa, 0, sizeof(union sockaddr_all));
sa.ss.ss_family = family; sa.ss.ss_family = family;
control_port = cfg_getint(cfg_getsec(cfg, "airplay_shared"), "control_port");
switch (family) switch (family)
{ {
case AF_INET: case AF_INET:
sa.sin.sin_addr.s_addr = INADDR_ANY; sa.sin.sin_addr.s_addr = INADDR_ANY;
sa.sin.sin_port = 0; sa.sin.sin_port = htons(control_port);
len = sizeof(sa.sin); len = sizeof(sa.sin);
break; break;
case AF_INET6: case AF_INET6:
sa.sin6.sin6_addr = in6addr_any; sa.sin6.sin6_addr = in6addr_any;
sa.sin6.sin6_port = 0; sa.sin6.sin6_port = htons(control_port);
len = sizeof(sa.sin6); len = sizeof(sa.sin6);
break; break;
} }