]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
rework the idea from the previous commit, use new 'proxy' field with the proxy addres...
authorJaroslav Kysela <perex@perex.cz>
Thu, 11 Jan 2018 15:28:02 +0000 (16:28 +0100)
committerJaroslav Kysela <perex@perex.cz>
Thu, 11 Jan 2018 15:28:11 +0000 (16:28 +0100)
src/http.c
src/http.h
src/satip/rtsp.c
src/tcp.c
src/webui/static/app/status.js
src/webui/webui.c

index 64c4d01447fefec6c7cfe4e384afed29ae322726..46635a1b24c6b2d0bd232d3ef7c499afae1823df 100644 (file)
@@ -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);
 }
 
index 480e5b772236a715ab4860d290c51f0697715bb0..6f1871353341efab7f71764fc870b69bfcc7bd3b 100644 (file)
@@ -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 */
   
index 71ab9a202db7c439b6ad4dcd10e25141d2683edd..631efbbeb3338b9e38f55d8fb2f5aef70c00eeef 100644 (file)
@@ -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);
 }
index 7fd31363de7f8e9d050080e39f3d5cca53ed38b4..b650fd9235a2cf2b02044b9444b4ba8f75da1909 100644 (file)
--- 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 */
index b08556be2f9b985a7551d4916c020671b280053a..0ac4b78e93dd91cf57669bf1c52dc09f46f67331 100644 (file)
@@ -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({
index 97924ad7383aab1f6fcb9e28eb6c6a296bab394b..6bac55e6fc4265ea56ae440a404005092ea06fc0 100644 (file)
@@ -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);
 }