From: Jaroslav Kysela Date: Thu, 11 Jan 2018 15:28:02 +0000 (+0100) Subject: rework the idea from the previous commit, use new 'proxy' field with the proxy addres... X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4f2e363fa0c79fb1dc69e5dedad0c340b1a679fd;p=thirdparty%2Ftvheadend.git rework the idea from the previous commit, use new 'proxy' field with the proxy address, fixes #4748 --- diff --git a/src/http.c b/src/http.c index 64c4d0144..46635a1b2 100644 --- a/src/http.c +++ b/src/http.c @@ -1357,11 +1357,15 @@ process_request(http_connection_t *hc, htsbuf_queue_t *spill) v = (config.proxy) ? http_arg_get(&hc->hc_args, "X-Forwarded-For") : NULL; if (v) { + if (hc->hc_proxy_ip == NULL) + hc->hc_proxy_ip = malloc(sizeof(*hc->hc_proxy_ip)); + *hc->hc_proxy_ip = *hc->hc_peer; if (tcp_get_ip_from_str(v, hc->hc_peer) == NULL) { http_error(hc, HTTP_STATUS_BAD_REQUEST); + free(hc->hc_proxy_ip); + hc->hc_proxy_ip = NULL; return -1; } - hc->hc_is_proxied = 1; } tcp_get_str_from_ip(hc->hc_peer, authbuf, sizeof(authbuf)); @@ -1858,7 +1862,6 @@ http_serve_requests(http_connection_t *hc) atomic_set(&hc->hc_extra_insend, 0); atomic_set(&hc->hc_extra_chunks, 0); - hc->hc_is_proxied = 0; do { hc->hc_no_output = 0; @@ -1973,6 +1976,7 @@ error: free(hc->hc_nonce); hc->hc_nonce = NULL; + free(hc->hc_proxy_ip); free(hc->hc_local_ip); } diff --git a/src/http.h b/src/http.h index 480e5b772..6f1871353 100644 --- a/src/http.h +++ b/src/http.h @@ -137,6 +137,7 @@ typedef struct http_connection { char *hc_peer_ipstr; struct sockaddr_storage *hc_self; char *hc_representative; + struct sockaddr_storage *hc_proxy_ip; struct sockaddr_storage *hc_local_ip; pthread_mutex_t *hc_paths_mutex; @@ -176,7 +177,6 @@ typedef struct http_connection { uint8_t hc_no_output; uint8_t hc_shutdown; uint8_t hc_is_local_ip; /*< a connection from the local network */ - uint8_t hc_is_proxied; /* Support for HTTP POST */ diff --git a/src/satip/rtsp.c b/src/satip/rtsp.c index 71ab9a202..631efbbeb 100644 --- a/src/satip/rtsp.c +++ b/src/satip/rtsp.c @@ -1656,7 +1656,13 @@ static void rtsp_stream_status ( void *opaque, htsmsg_t *m ) { http_connection_t *hc = opaque; - htsmsg_add_str(m, "type", (hc->hc_is_proxied)? "SAT>IP/proxy" : "SAT>IP"); + char buf[128]; + + htsmsg_add_str(m, "type", "SAT>IP"); + if (hc->hc_proxy_ip) { + tcp_get_str_from_ip(hc->hc_proxy_ip, buf, sizeof(buf)); + htsmsg_add_str(m, "proxy", buf); + } if (hc->hc_username) htsmsg_add_str(m, "user", hc->hc_username); } diff --git a/src/tcp.c b/src/tcp.c index 7fd31363d..b650fd923 100644 --- a/src/tcp.c +++ b/src/tcp.c @@ -1112,7 +1112,7 @@ tcp_server_connections ( void ) tcp_server_launch_t *tsl; lock_assert(&global_lock); htsmsg_t *l, *e, *m; - char buf[1024]; + char buf[128]; int c = 0; /* Build list */ diff --git a/src/webui/static/app/status.js b/src/webui/static/app/status.js index b08556be2..0ac4b78e9 100644 --- a/src/webui/static/app/status.js +++ b/src/webui/static/app/status.js @@ -607,6 +607,7 @@ tvheadend.status_conns = function(panel, index) { { name: 'server_port' }, { name: 'peer', sortType: stype }, { name: 'peer_port' }, + { name: 'proxy' }, { name: 'user', sortType: stype }, { name: 'started', @@ -672,6 +673,12 @@ tvheadend.status_conns = function(panel, index) { header: _("Server Port"), dataIndex: 'server_port', sortable: true + }, { + width: 50, + id: 'proxy', + header: _("Proxy Address"), + dataIndex: 'proxy', + sortable: true }]); grid = new Ext.grid.GridPanel({ diff --git a/src/webui/webui.c b/src/webui/webui.c index 97924ad73..6bac55e6f 100644 --- a/src/webui/webui.c +++ b/src/webui/webui.c @@ -291,7 +291,13 @@ static void http_stream_status ( void *opaque, htsmsg_t *m ) { http_connection_t *hc = opaque; - htsmsg_add_str(m, "type", (hc->hc_is_proxied)? "HTTP/proxy" : "HTTP"); + char buf[128]; + + htsmsg_add_str(m, "type", "HTTP"); + if (hc->hc_proxy_ip) { + tcp_get_str_from_ip(hc->hc_proxy_ip, buf, sizeof(buf)); + htsmsg_add_str(m, "proxy", buf); + } if (hc->hc_username) htsmsg_add_str(m, "user", hc->hc_username); }