.SH OPTIONS
All arguments are optional.
.TP
+\fB\-b\fR \fIaddress\fR, \fB\-\-bindaddr\fR \fIaddress\fR
+Specify an interface IP address on which incoming HTTP and HTSP connections
+will be accepted. By default, connections are accepted on all interfaces.
+.TP
\fB\-f
Fork and become a background process (deamon). Default no.
.TP
* Fire up HTSP server
*/
void
-htsp_init(void)
+htsp_init(const char *bindaddr)
{
extern int tvheadend_htsp_port_extra;
- htsp_server = tcp_server_create(tvheadend_htsp_port, htsp_serve, NULL);
+ htsp_server = tcp_server_create(bindaddr, tvheadend_htsp_port, htsp_serve, NULL);
if(tvheadend_htsp_port_extra)
- htsp_server_2 = tcp_server_create(tvheadend_htsp_port_extra, htsp_serve, NULL);
+ htsp_server_2 = tcp_server_create(bindaddr, tvheadend_htsp_port_extra, htsp_serve, NULL);
}
/* **************************************************************************
#include "epg.h"
#include "dvr/dvr.h"
-void htsp_init(void);
+void htsp_init(const char *bindaddr);
void htsp_channel_update_current(channel_t *ch);
* Fire up HTTP server
*/
void
-http_server_init(void)
+http_server_init(const char *bindaddr)
{
- http_server = tcp_server_create(tvheadend_webui_port, http_serve, NULL);
+ http_server = tcp_server_create(bindaddr, tvheadend_webui_port, http_serve, NULL);
}
-void http_server_init(void);
+void http_server_init(const char *bindaddr);
int http_access_verify(http_connection_t *hc, int mask);
*opt_dvb_raw = NULL,
#endif
*opt_rawts = NULL,
+ *opt_bindaddr = NULL,
*opt_subscribe = NULL;
cmdline_opt_t cmdline_opts[] = {
{ 0, NULL, "Generic Options", OPT_BOOL, NULL },
{ 'v', "version", "Show version infomation", OPT_BOOL, &opt_version },
{ 0, NULL, "Service Configuration", OPT_BOOL, NULL },
+ { 'b', "bindaddr", "Specify bind address", OPT_STR, &opt_bindaddr},
{ 'c', "config", "Alternate config path", OPT_STR, &opt_config },
{ 'f', "fork", "Fork and run as daemon", OPT_BOOL, &opt_fork },
{ 'u', "user", "Run as user", OPT_STR, &opt_user },
#endif
tcp_server_init(opt_ipv6);
- http_server_init();
+ http_server_init(opt_bindaddr);
webui_init();
serviceprobe_init();
dvr_init();
- htsp_init();
+ htsp_init(opt_bindaddr);
if(opt_rawts != NULL)
rawts_init(opt_rawts);
*
*/
void *
-tcp_server_create(int port, tcp_server_callback_t *start, void *opaque)
+tcp_server_create(const char *bindaddr, int port, tcp_server_callback_t *start, void *opaque)
{
int fd, x;
struct epoll_event e;
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_flags = AI_PASSIVE;
+ if (bindaddr != NULL)
+ hints.ai_flags |= AI_NUMERICHOST;
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
- x = getaddrinfo(NULL, portBuf, &hints, &res);
+ x = getaddrinfo(bindaddr, portBuf, &hints, &res);
free(portBuf);
- if(x != 0)
+ if(x != 0) {
+ fprintf(stderr, "getaddrinfo: %s: %s", bindaddr != NULL ? bindaddr : "*",
+ x == EAI_SYSTEM ? strerror(errno) : gai_strerror(x));
return NULL;
+ }
ressave = res;
while(res)
if(x != 0)
{
+ fprintf(stderr, "bind: %s: %s", bindaddr != NULL ? bindaddr : "*", strerror(errno));
close(fd);
return NULL;
}
struct sockaddr_storage *peer,
struct sockaddr_storage *self);
-void *tcp_server_create(int port, tcp_server_callback_t *start, void *opaque);
+void *tcp_server_create(const char *bindaddr, int port, tcp_server_callback_t *start, void *opaque);
int tcp_read(int fd, void *buf, size_t len);