winshining / nginx-http-flv-module

A media streaming server based on nginx-rtmp-module. In addtion to the features nginx-rtmp-module provides, HTTP-FLV, GOP cache, VHosts (one IP for multi domain names) and JSON style statistics are supported now.
BSD 2-Clause "Simplified" License
2.72k stars 567 forks source link

Hostname parser issue, confilict with docker-compose auto naming rules. #192

Closed lclancey closed 3 years ago

lclancey commented 3 years ago

https://github.com/winshining/nginx-http-flv-module/blob/13be96d72d5163c4819830bfe925dc919364e41e/ngx_rtmp_parse.c#L123-L134

According to the codes above, RTMP server only accept a request_line's hostname combined with alphabet,number,dot(.) and -.

In my case, I'm using docker-compose to create two dockers. One, I call it HOST docker, is a nginx-http-flv-module docker, and docker-compose auto naming it something like project_service_1 when deploy. Then, while the other docker(ffmpeg docker, I call it CODEC docker) try to push stream using docker-to-docker-inside-bridge, its output_url would be "rtmp://project_service_1:1935/myapp/mystream", which is not accept by the nginx-http-flv-module docker. My sollution is adding a line container_name: host to the docker-compose.yaml, to force naming it.

My question is, will it has any bad consequence if simply replace

          if ((ch >= '0' && ch <= '9') || ch == '.' || ch == '-') {

with

          if ((ch >= '0' && ch <= '9') || ch == '.' || ch == '-' || ch == '_') {

?

winshining commented 3 years ago

It is historically assumed in RFC 952 that characters in a domain name should drawn from the alphabet (A-Z and a-z), digits (0-9), minus sign (-), and period (.). Underscore (_) was not specially pointed out. No bad consequence has been posted yet until now. However, I advise you not to use an underscore in a domain name.