Skip to content

Commit 2322a9f

Browse files
committed
feat: add protocol extraction from config.hostname for playlist generation
1 parent 900fbf0 commit 2322a9f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/m3u.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,10 +1229,24 @@ char *m3u_generate_playlist(const char *host_header,
12291229
const char *host = NULL;
12301230
const char *proto = "http";
12311231

1232+
/* Extract protocol from config.hostname if configured */
1233+
char config_protocol[16] = {0};
1234+
if (config.hostname && config.hostname[0] != '\0') {
1235+
/* Parse URL components from config.hostname to extract protocol */
1236+
if (http_parse_url_components(config.hostname, config_protocol, NULL, NULL,
1237+
NULL) == 0) {
1238+
/* Successfully parsed - use protocol from config.hostname if present */
1239+
if (config_protocol[0] != '\0') {
1240+
proto = config_protocol;
1241+
}
1242+
}
1243+
}
1244+
12321245
if (config.xff && x_forwarded_host && x_forwarded_host[0]) {
12331246
/* Use X-Forwarded-Host when xff is enabled */
12341247
host = x_forwarded_host;
12351248
if (x_forwarded_proto && x_forwarded_proto[0]) {
1249+
/* X-Forwarded-Proto overrides config.hostname protocol */
12361250
proto = x_forwarded_proto;
12371251
}
12381252
} else if (host_header && host_header[0]) {

0 commit comments

Comments
 (0)