Make htsp_server and webui IPv6 ready
This commit is contained in:
parent
b08a3c40d7
commit
0a4f32bfba
3 changed files with 34 additions and 15 deletions
|
@ -115,7 +115,7 @@ typedef struct htsp_connection {
|
|||
LIST_ENTRY(htsp_connection) htsp_link;
|
||||
|
||||
int htsp_fd;
|
||||
struct sockaddr_in *htsp_peer;
|
||||
struct sockaddr_storage *htsp_peer;
|
||||
|
||||
uint32_t htsp_version;
|
||||
|
||||
|
@ -464,19 +464,22 @@ htsp_build_channel(channel_t *ch, const char *method, htsp_connection_t *htsp)
|
|||
htsmsg_add_str(out, "channelName", ch->ch_name);
|
||||
if(ch->ch_icon != NULL) {
|
||||
uint32_t id;
|
||||
struct sockaddr_in addr;
|
||||
struct sockaddr_storage addr;
|
||||
socklen_t addrlen;
|
||||
if ((id = imagecache_get_id(ch->ch_icon))) {
|
||||
size_t p = 0;
|
||||
char url[256];
|
||||
char buf[50];
|
||||
if (htsp->htsp_version < 8) {
|
||||
addrlen = sizeof(addr);
|
||||
getsockname(htsp->htsp_fd, (struct sockaddr*)&addr, &addrlen);
|
||||
tcp_get_ip_str((struct sockaddr*)&addr, buf, 50);
|
||||
strcpy(url, "http://");
|
||||
p = strlen(url);
|
||||
inet_ntop(AF_INET, &addr.sin_addr, url+p, sizeof(url)-p);
|
||||
p = strlen(url);
|
||||
p += snprintf(url+p, sizeof(url)-p, ":%hd%s",
|
||||
p += snprintf(url+p, sizeof(url)-p, "%s%s%s:%hd%s",
|
||||
(addr.ss_family == AF_INET6)?"[":"",
|
||||
buf,
|
||||
(addr.ss_family == AF_INET6)?"]":"",
|
||||
tvheadend_webui_port,
|
||||
tvheadend_webroot ?: "");
|
||||
}
|
||||
|
@ -1871,14 +1874,14 @@ htsp_write_scheduler(void *aux)
|
|||
*
|
||||
*/
|
||||
static void
|
||||
htsp_serve(int fd, void *opaque, struct sockaddr_in *source,
|
||||
struct sockaddr_in *self)
|
||||
htsp_serve(int fd, void *opaque, struct sockaddr_storage *source,
|
||||
struct sockaddr_storage *self)
|
||||
{
|
||||
htsp_connection_t htsp;
|
||||
char buf[30];
|
||||
char buf[50];
|
||||
htsp_subscription_t *s;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s", inet_ntoa(source->sin_addr));
|
||||
tcp_get_ip_str((struct sockaddr*)source, buf, 50);
|
||||
|
||||
memset(&htsp, 0, sizeof(htsp_connection_t));
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "http.h"
|
||||
#include "webui/webui.h"
|
||||
#include "access.h"
|
||||
#include "tcp.h"
|
||||
|
||||
static pthread_mutex_t comet_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_cond_t comet_cond = PTHREAD_COND_INITIALIZER;
|
||||
|
@ -153,16 +154,24 @@ comet_access_update(http_connection_t *hc, comet_mailbox_t *cmb)
|
|||
static void
|
||||
comet_serverIpPort(http_connection_t *hc, comet_mailbox_t *cmb)
|
||||
{
|
||||
char buf[INET_ADDRSTRLEN + 1];
|
||||
char buf[50];
|
||||
uint32_t port;
|
||||
|
||||
inet_ntop(AF_INET, &hc->hc_self->sin_addr, buf, sizeof(buf));
|
||||
tcp_get_ip_str((struct sockaddr*)hc->hc_self, buf, 50);
|
||||
|
||||
if(hc->hc_self->ss_family == AF_INET)
|
||||
port = ((struct sockaddr_in*)hc->hc_self)->sin_port;
|
||||
else if(hc->hc_self->ss_family == AF_INET6)
|
||||
port = ((struct sockaddr_in6*)hc->hc_self)->sin6_port;
|
||||
else
|
||||
port = 0;
|
||||
|
||||
htsmsg_t *m = htsmsg_create_map();
|
||||
|
||||
htsmsg_add_str(m, "notificationClass", "setServerIpPort");
|
||||
|
||||
htsmsg_add_str(m, "ip", buf);
|
||||
htsmsg_add_u32(m, "port", ntohs(hc->hc_self->sin_port));
|
||||
htsmsg_add_u32(m, "port", ntohs(port));
|
||||
|
||||
if(cmb->cmb_messages == NULL)
|
||||
cmb->cmb_messages = htsmsg_create_list();
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "dvb/dvb.h"
|
||||
#include "dvb/dvb_support.h"
|
||||
#include "imagecache.h"
|
||||
#include "tcp.h"
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -563,6 +564,7 @@ http_stream_service(http_connection_t *hc, service_t *service)
|
|||
const char *str;
|
||||
size_t qsize;
|
||||
const char *name;
|
||||
char addrbuf[50];
|
||||
|
||||
mc = muxer_container_txt2type(http_arg_get(&hc->hc_req_args, "mux"));
|
||||
if(mc == MC_UNKNOWN) {
|
||||
|
@ -589,8 +591,9 @@ http_stream_service(http_connection_t *hc, service_t *service)
|
|||
flags = 0;
|
||||
}
|
||||
|
||||
tcp_get_ip_str((struct sockaddr*)hc->hc_peer, addrbuf, 50);
|
||||
s = subscription_create_from_service(service, "HTTP", st, flags,
|
||||
inet_ntoa(hc->hc_peer->sin_addr),
|
||||
addrbuf,
|
||||
hc->hc_username,
|
||||
http_arg_get(&hc->hc_args, "User-Agent"));
|
||||
if(s) {
|
||||
|
@ -624,10 +627,12 @@ http_stream_tdmi(http_connection_t *hc, th_dvb_mux_instance_t *tdmi)
|
|||
th_subscription_t *s;
|
||||
streaming_queue_t sq;
|
||||
const char *name;
|
||||
char addrbuf[50];
|
||||
streaming_queue_init(&sq, SMT_PACKET);
|
||||
|
||||
tcp_get_ip_str((struct sockaddr*)hc->hc_peer, addrbuf, 50);
|
||||
s = dvb_subscription_create_from_tdmi(tdmi, "HTTP", &sq.sq_st,
|
||||
inet_ntoa(hc->hc_peer->sin_addr),
|
||||
addrbuf,
|
||||
hc->hc_username,
|
||||
http_arg_get(&hc->hc_args, "User-Agent"));
|
||||
name = strdupa(tdmi->tdmi_identifier);
|
||||
|
@ -661,6 +666,7 @@ http_stream_channel(http_connection_t *hc, channel_t *ch)
|
|||
char *str;
|
||||
size_t qsize;
|
||||
const char *name;
|
||||
char addrbuf[50];
|
||||
|
||||
mc = muxer_container_txt2type(http_arg_get(&hc->hc_req_args, "mux"));
|
||||
if(mc == MC_UNKNOWN) {
|
||||
|
@ -687,8 +693,9 @@ http_stream_channel(http_connection_t *hc, channel_t *ch)
|
|||
flags = 0;
|
||||
}
|
||||
|
||||
tcp_get_ip_str((struct sockaddr*)hc->hc_peer, addrbuf, 50);
|
||||
s = subscription_create_from_channel(ch, priority, "HTTP", st, flags,
|
||||
inet_ntoa(hc->hc_peer->sin_addr),
|
||||
addrbuf,
|
||||
hc->hc_username,
|
||||
http_arg_get(&hc->hc_args, "User-Agent"));
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue