Feature #4734
Allow to disable HTTP and HTSP services (set TCP port to zero on the command line)
100%
Description
Hi,
I have this suggestion: Disable the HTTP service/thread with the parameter "--http_port 0".
The objetive is to disable the listing socket for the HTTP UI, and reduce the memory footprint. This improves the security when using only (for example) the SAT>IP RTSO server protocol. And also reduces the memory consumed. For sure, you can continue using the UI and configuring the TVH when you start it with a port different that 0.
I feel this will be easy to implement. Right?
Files
History
Updated by Mono Polimorph about 7 years ago
Mono Polimorph wrote:
Hi,
No one interested on this?
Hi Jaroslav,
I'll try to implement this. Please, can you say if this is feasible? If I don't create the HTTP server thread the rest will function?
I only need your recomendation. I'll do the rest of the work.
Thank you!
Updated by saen acro about 7 years ago
If you disable WEB tread in program how will you communicate to SAT>IP server?
UDP only?
Updated by Mono Polimorph about 7 years ago
saen acro wrote:
If you disable WEB tread in program how will you communicate to SAT>IP server?
UDP only?
For the SAT>IP server? Using the RTSP server!
Updated by Mono Polimorph about 7 years ago
Hi Jaroslav,
I have created this "simple" patch for support this functionality:
diff --git a/src/avahi.c b/src/avahi.c index 64be541..54a4995 100644 --- a/src/avahi.c +++ b/src/avahi.c @@ -135,8 +135,9 @@ create_services(AvahiClient *c) tvhdebug(LS_AVAHI, "Adding service '%s'", name); /* Add the service for HTSP */ - if ((ret = avahi_entry_group_add_service(group, AVAHI_IF_UNSPEC, - AVAHI_PROTO_UNSPEC, 0, name, + if (tvheadend_htsp_port) + if ((ret = avahi_entry_group_add_service(group, AVAHI_IF_UNSPEC, + AVAHI_PROTO_UNSPEC, 0, name, "_htsp._tcp", NULL, NULL,tvheadend_htsp_port, NULL)) < 0) { @@ -157,8 +158,9 @@ create_services(AvahiClient *c) } /* Add the service for HTTP */ - if ((ret = avahi_entry_group_add_service(group, AVAHI_IF_UNSPEC, - AVAHI_PROTO_UNSPEC, 0, name, + if (tvheadend_webui_port) + if ((ret = avahi_entry_group_add_service(group, AVAHI_IF_UNSPEC, + AVAHI_PROTO_UNSPEC, 0, name, "_http._tcp", NULL, NULL, tvheadend_webui_port, path, NULL)) < 0) { diff --git a/src/bonjour.c b/src/bonjour.c index 5e4eb0f..af86a70 100644 --- a/src/bonjour.c +++ b/src/bonjour.c @@ -107,11 +107,13 @@ bonjour_init(void) { "path", tvheadend_webroot ? tvheadend_webroot : "/" }, { .key = NULL } }; - - bonjour_start_service(&svc_http, "_http._tcp", tvheadend_webui_port, + + if(tvheadend_webui_port) + bonjour_start_service(&svc_http, "_http._tcp", tvheadend_webui_port, txt_rec_http); - bonjour_start_service(&svc_htsp, "_htsp._tcp", tvheadend_htsp_port, NULL); + if(tvheadend_htsp_port) + bonjour_start_service(&svc_htsp, "_htsp._tcp", tvheadend_htsp_port, NULL); } void diff --git a/src/htsp_server.c b/src/htsp_server.c index cd8a973..34c1ed8 100644 --- a/src/htsp_server.c +++ b/src/htsp_server.c @@ -3495,7 +3495,8 @@ htsp_init(const char *bindaddr) .stop = NULL, .cancel = htsp_server_cancel }; - htsp_server = tcp_server_create(LS_HTSP, "HTSP", bindaddr, tvheadend_htsp_port, &ops, NULL); + if(tvheadend_htsp_port) + htsp_server = tcp_server_create(LS_HTSP, "HTSP", bindaddr, tvheadend_htsp_port, &ops, NULL); if(tvheadend_htsp_port_extra) htsp_server_2 = tcp_server_create(LS_HTSP, "HTSP2", bindaddr, tvheadend_htsp_port_extra, &ops, NULL); } diff --git a/src/http.c b/src/http.c index 3c8d95a..738484f 100644 --- a/src/http.c +++ b/src/http.c @@ -1993,7 +1993,8 @@ http_server_init(const char *bindaddr) .cancel = http_cancel }; RB_INIT(&http_nonces); - http_server = tcp_server_create(LS_HTTP, "HTTP", bindaddr, tvheadend_webui_port, &ops, NULL); + if(tvheadend_webui_port) + http_server = tcp_server_create(LS_HTTP, "HTTP", bindaddr, tvheadend_webui_port, &ops, NULL); atomic_set(&http_server_running, 1); }
Comments:
- It supports the three TCP listening ports: webUI (HTTP), HTSP and HTSP_extra.
- It simply does the check of not zero before call to the creation function.
- It also does it for helper network services (Bonjour & Avahi).
- It saves around a 1MB of memory footprint.
- No collateral effects detected. When setting all to "0" the SAT>IP continues working as expected.
Please, commit it! It's mainly a assertion check, and a hard port restriction.
Updated by Jaroslav Kysela about 7 years ago
- Subject changed from Disable HTTP service/thread to Allow to disable HTTP and HTSP services (set TCP port to zero on the command line)
- Target version set to 4.4
Updated by Jaroslav Kysela about 7 years ago
- Status changed from New to Fixed
- % Done changed from 0 to 100
Applied in changeset commit:tvheadend|4e3359a2d018e075a7372a6a533b0bdf79dcaef4.
Updated by Mark Clarkstone about 7 years ago
Ħaving a quick read of the patch, I can see that there's no option to disable the tcp ports via the webui, and imo that's a GOOD thing .
Updated by Mono Polimorph about 7 years ago
Jaroslav Kysela wrote:
Applied in changeset commit:tvheadend|4e3359a2d018e075a7372a6a533b0bdf79dcaef4.
Thank you!
Mark Clarkstone wrote:
Ħaving a quick read of the patch, I can see that there's no option to disable the tcp ports via the webui, and imo that's a GOOD thing .
Hi Mark,
Please, think on this: if you disable the webUI listening port using the webUI... how you apply and reenable it?
This is for "hidde" (aka disable) listening ports when the configuration is done. And you can revert it remoning the commandline parameter. What you sugest has no sense.
Regards.
Updated by Mark Clarkstone about 7 years ago
Mono Polimorph wrote:
Jaroslav Kysela wrote:
Applied in changeset commit:tvheadend|4e3359a2d018e075a7372a6a533b0bdf79dcaef4.
Thank you!
Mark Clarkstone wrote:
Ħaving a quick read of the patch, I can see that there's no option to disable the tcp ports via the webui, and imo that's a GOOD thing .
Hi Mark,
Please, think on this: if you disable the webUI listening port using the webUI... how you apply and reenable it?
This is for "hidde" (aka disable) listening ports when the configuration is done. And you can revert it remoning the commandline parameter. What you sugest has no sense.Regards.
You misunderstand, what I'm saying is it's a good thing it's not possible from the webui. It wasn't a suggestion at all!
Updated by Mono Polimorph about 7 years ago
Mark Clarkstone wrote:
You misunderstand, what I'm saying is it's a good thing it's not possible from the webui. It wasn't a suggestion at all!
I re-read it... you're right!