1
0
mirror of https://gitlab.xiph.org/xiph/ezstream.git synced 2024-12-04 14:46:31 -05:00

Fix "HTTPS" protocol support. Add optional support for ICY and RoarAudio

This commit is contained in:
Moritz Grimm 2020-01-22 22:55:59 +01:00
parent ce0d1ffaab
commit 44f7e19ca7
6 changed files with 72 additions and 4 deletions

View File

@ -186,10 +186,19 @@ Transport protocol used to stream to the server:
.Pp .Pp
.Bl -tag -width HTTPS -compact .Bl -tag -width HTTPS -compact
.It Ar HTTP .It Ar HTTP
Unencrypted HTTP (the default). Plain-text HTTP
.It Ar HTTPS .It Ar HTTPS
HTTP over TLS. HTTP over TLS.
This option implies that \&<tls\ /\&> is set to
.Qq required .
.It Ar ICY
ICY streaming protocol
.It Ar RoarAudio
RoarAudio streaming protocol
.El .El
.Pp
Default:
.Ar HTTP
.It Sy \&<hostname\ /\&> .It Sy \&<hostname\ /\&>
.Pq Mandatory. .Pq Mandatory.
The FQDN host name or IP address of the server. The FQDN host name or IP address of the server.
@ -223,12 +232,19 @@ Possible values are:
No TLS encryption will be attempted. No TLS encryption will be attempted.
.It Ar May .It Ar May
Opportunistic TLS encryption may be used, if the server supports it Opportunistic TLS encryption may be used, if the server supports it
.Pq the default .
.It Ar Required .It Ar Required
TLS encryption is required. TLS encryption is required.
This is the only setting that is providing security against both passive and This is the only setting that is providing security against both passive and
active attackers. active attackers.
.El .El
.Pp
Default:
.Ar May
.Pp
This option is ignored when \&<protocol\ /\&> is set to
.Ar HTTPS ,
which implies a value of
.Ar Required .
.It Sy \&<tls_cipher_suite\ /\&> .It Sy \&<tls_cipher_suite\ /\&>
Configure allowed cipher suites for TLS. Configure allowed cipher suites for TLS.
.Pp .Pp

View File

@ -18,7 +18,10 @@
<!-- Identifying name (default: "default") --> <!-- Identifying name (default: "default") -->
<name>Test Server</name> <name>Test Server</name>
<!-- Transport protocol: HTTP, HTTPS (default: "HTTP") --> <!--
Transport protocol:
HTTP (default), HTTPS (implies <tls>required</tls>), ICY, RoarAudio
-->
<protocol>HTTP</protocol> <protocol>HTTP</protocol>
<!-- Server address --> <!-- Server address -->
<hostname>127.0.0.1</hostname> <hostname>127.0.0.1</hostname>

View File

@ -194,6 +194,10 @@ cfg_server_set_protocol(struct cfg_server *s, struct cfg_server_list *not_used,
s->protocol = CFG_PROTO_HTTP; s->protocol = CFG_PROTO_HTTP;
else if (0 == strcasecmp("https", protocol)) else if (0 == strcasecmp("https", protocol))
s->protocol = CFG_PROTO_HTTPS; s->protocol = CFG_PROTO_HTTPS;
else if (0 == strcasecmp("icy", protocol))
s->protocol = CFG_PROTO_ICY;
else if (0 == strcasecmp("roaraudio", protocol))
s->protocol = CFG_PROTO_ROARAUDIO;
else { else {
if (NULL != errstrp) if (NULL != errstrp)
*errstrp = "unsupported"; *errstrp = "unsupported";
@ -364,6 +368,10 @@ cfg_server_get_protocol_str(struct cfg_server *s)
switch (s->protocol) { switch (s->protocol) {
case CFG_PROTO_HTTPS: case CFG_PROTO_HTTPS:
return ("https"); return ("https");
case CFG_PROTO_ICY:
return ("icy");
case CFG_PROTO_ROARAUDIO:
return ("roaraudio");
case CFG_PROTO_HTTP: case CFG_PROTO_HTTP:
default: default:
return ("http"); return ("http");
@ -397,12 +405,16 @@ cfg_server_get_password(struct cfg_server *s)
enum cfg_server_tls enum cfg_server_tls
cfg_server_get_tls(struct cfg_server *s) cfg_server_get_tls(struct cfg_server *s)
{ {
if (CFG_PROTO_HTTPS == s->protocol)
return (CFG_TLS_REQUIRED);
return (s->tls); return (s->tls);
} }
const char * const char *
cfg_server_get_tls_str(struct cfg_server *s) cfg_server_get_tls_str(struct cfg_server *s)
{ {
if (CFG_PROTO_HTTPS == s->protocol)
return ("required");
switch (s->tls) { switch (s->tls) {
case CFG_TLS_NONE: case CFG_TLS_NONE:
return ("none"); return ("none");

View File

@ -23,8 +23,10 @@
enum cfg_server_protocol { enum cfg_server_protocol {
CFG_PROTO_HTTP = 0, CFG_PROTO_HTTP = 0,
CFG_PROTO_HTTPS, CFG_PROTO_HTTPS,
CFG_PROTO_ICY,
CFG_PROTO_ROARAUDIO,
CFG_PROTO_MIN = CFG_PROTO_HTTP, CFG_PROTO_MIN = CFG_PROTO_HTTP,
CFG_PROTO_MAX = CFG_PROTO_HTTPS, CFG_PROTO_MAX = CFG_PROTO_ROARAUDIO,
}; };
enum cfg_server_tls { enum cfg_server_tls {

View File

@ -48,6 +48,7 @@ _stream_cfg_server(struct stream *s, cfg_server_t cfg_server)
{ {
switch (cfg_server_get_protocol(cfg_server)) { switch (cfg_server_get_protocol(cfg_server)) {
case CFG_PROTO_HTTP: case CFG_PROTO_HTTP:
case CFG_PROTO_HTTPS:
if (SHOUTERR_SUCCESS != if (SHOUTERR_SUCCESS !=
shout_set_protocol(s->shout, SHOUT_PROTOCOL_HTTP)) { shout_set_protocol(s->shout, SHOUT_PROTOCOL_HTTP)) {
log_error("%s: protocol: %s", log_error("%s: protocol: %s",
@ -55,6 +56,26 @@ _stream_cfg_server(struct stream *s, cfg_server_t cfg_server)
return (-1); return (-1);
} }
break; break;
#ifdef SHOUT_PROTOCOL_ICY
case CFG_PROTO_ICY:
if (SHOUTERR_SUCCESS !=
shout_set_protocol(s->shout, SHOUT_PROTOCOL_ICY)) {
log_error("%s: protocol: %s",
s->name, shout_get_error(s->shout));
return (-1);
}
break;
#endif /* SHOUT_PROTOCOL_ICY */
#ifdef SHOUT_PROTOCOL_ROARAUDIO
case CFG_PROTO_ROARAUDIO:
if (SHOUTERR_SUCCESS !=
shout_set_protocol(s->shout, SHOUT_PROTOCOL_ROARAUDIO)) {
log_error("%s: protocol: %s",
s->name, shout_get_error(s->shout));
return (-1);
}
break;
#endif /* SHOUT_PROTOCOL_ROARAUDIO */
default: default:
log_error("%s: protocol: unsupported: %s", log_error("%s: protocol: unsupported: %s",
s->name, cfg_server_get_protocol_str(cfg_server)); s->name, cfg_server_get_protocol_str(cfg_server));

View File

@ -63,10 +63,24 @@ START_TEST(test_server_protocol)
0); 0);
ck_assert_int_eq(cfg_server_get_protocol(srv), CFG_PROTO_HTTP); ck_assert_int_eq(cfg_server_get_protocol(srv), CFG_PROTO_HTTP);
ck_assert_str_eq(cfg_server_get_protocol_str(srv), "http"); ck_assert_str_eq(cfg_server_get_protocol_str(srv), "http");
ck_assert_int_eq(cfg_server_get_tls(srv), CFG_TLS_MAY);
ck_assert_str_eq(cfg_server_get_tls_str(srv), "may");
ck_assert_int_eq(cfg_server_set_protocol(srv, servers, "HtTpS", NULL), ck_assert_int_eq(cfg_server_set_protocol(srv, servers, "HtTpS", NULL),
0); 0);
ck_assert_int_eq(cfg_server_get_protocol(srv), CFG_PROTO_HTTPS); ck_assert_int_eq(cfg_server_get_protocol(srv), CFG_PROTO_HTTPS);
ck_assert_str_eq(cfg_server_get_protocol_str(srv), "https"); ck_assert_str_eq(cfg_server_get_protocol_str(srv), "https");
ck_assert_int_eq(cfg_server_get_tls(srv), CFG_TLS_REQUIRED);
ck_assert_str_eq(cfg_server_get_tls_str(srv), "required");
ck_assert_int_eq(cfg_server_set_protocol(srv, servers, "iCY", NULL),
0);
ck_assert_int_eq(cfg_server_get_protocol(srv), CFG_PROTO_ICY);
ck_assert_str_eq(cfg_server_get_protocol_str(srv), "icy");
ck_assert_int_eq(cfg_server_get_tls(srv), CFG_TLS_MAY);
ck_assert_str_eq(cfg_server_get_tls_str(srv), "may");
ck_assert_int_eq(cfg_server_set_protocol(srv, servers, "rOaRaudIo", NULL),
0);
ck_assert_int_eq(cfg_server_get_protocol(srv), CFG_PROTO_ROARAUDIO);
ck_assert_str_eq(cfg_server_get_protocol_str(srv), "roaraudio");
} }
END_TEST END_TEST