Bladeren bron

Merge pull request #2275 from kamailio/grumvalski/ds_outbound_proxy

Grumvalski/ds outbound proxy
Federico Cabiddu 5 jaren geleden
bovenliggende
commit
541d1bdfaf

+ 15 - 1
src/modules/dispatcher/dispatch.c

@@ -324,6 +324,9 @@ int ds_set_attrs(ds_dest_t *dest, str *vattrs)
 		} else if(pit->name.len == 9
 				&& strncasecmp(pit->name.s, "ping_from", 9) == 0) {
 			dest->attrs.ping_from = pit->body;
+		} else if(pit->name.len == 7 
+				  && strncasecmp(pit->name.s, "obproxy", 7) == 0) {
+			dest->attrs.obproxy = pit->body;
 		}
 	}
 	if(params_list)
@@ -3295,6 +3298,7 @@ void ds_ping_set(ds_set_t *node)
 	uac_req_t uac_r;
 	int i, j;
 	str ping_from;
+	str obproxy;
 
 	if(!node)
 		return;
@@ -3342,10 +3346,20 @@ void ds_ping_set(ds_set_t *node)
 				LM_DBG("Default ping_from: %.*s\n", ping_from.len, ping_from.s);
 			}
 
+			if(node->dlist[j].attrs.obproxy.s != NULL
+					&& node->dlist[j].attrs.obproxy.len > 0) {
+				obproxy = node->dlist[j].attrs.obproxy;
+				LM_DBG("outbound proxy: %.*s\n", obproxy.len, obproxy.s);
+			}
+			else {
+				obproxy = ds_outbound_proxy;
+				LM_DBG("Default outbound proxy: %.*s\n", ds_outbound_proxy.len, ds_outbound_proxy.s);
+			}
+
 			gettimeofday(&node->dlist[j].latency_stats.start, NULL);
 
 			if(tmb.t_request(&uac_r, &node->dlist[j].uri, &node->dlist[j].uri,
-					   &ping_from, &ds_outbound_proxy)
+					   &ping_from, &obproxy)
 					< 0) {
 				LM_ERR("unable to ping [%.*s]\n", node->dlist[j].uri.len,
 						node->dlist[j].uri.s);

+ 1 - 0
src/modules/dispatcher/dispatch.h

@@ -188,6 +188,7 @@ typedef struct _ds_attrs {
 	int rweight;
 	int congestion_control;
 	str ping_from;
+	str obproxy;
 } ds_attrs_t;
 
 typedef struct _ds_latency_stats {

+ 4 - 2
src/modules/dispatcher/dispatcher.c

@@ -1573,7 +1573,7 @@ int ds_rpc_print_set(ds_set_t *node, rpc_t *rpc, void *ctx, void *rpc_handle)
 				rpc->fault(ctx, 500, "Internal error creating dest struct");
 				return -1;
 			}
-			if(rpc->struct_add(wh, "SSdddSS",
+			if(rpc->struct_add(wh, "SSdddSSS",
 						"BODY", &(node->dlist[j].attrs.body),
 						"DUID", (node->dlist[j].attrs.duid.s)
 									? &(node->dlist[j].attrs.duid) : &data,
@@ -1583,7 +1583,9 @@ int ds_rpc_print_set(ds_set_t *node, rpc_t *rpc, void *ctx, void *rpc_handle)
 						"SOCKET", (node->dlist[j].attrs.socket.s)
 									? &(node->dlist[j].attrs.socket) : &data,
 						"SOCKNAME", (node->dlist[j].attrs.sockname.s)
-									? &(node->dlist[j].attrs.sockname) : &data)
+									? &(node->dlist[j].attrs.sockname) : &data,
+						"OBPROXY", (node->dlist[j].attrs.obproxy.s)
+									? &(node->dlist[j].attrs.obproxy) : &data)
 					< 0) {
 				rpc->fault(ctx, 500, "Internal error creating attrs struct");
 				return -1;

+ 9 - 0
src/modules/dispatcher/doc/dispatcher.xml

@@ -59,6 +59,11 @@
                 <surname>Chavanton</surname>
                 <email>[email protected]</email>
             </editor>
+            <editor>
+                <firstname>Federico</firstname>
+                <surname>Cabiddu</surname>
+                <email>[email protected]</email>
+            </editor>
 	</authorgroup>
 	<copyright>
 	    <year>2004</year>
@@ -84,6 +89,10 @@
             <year>2017, 2018</year>
             <holder>Julien chavanton, Flowroute</holder>
         </copyright>
+	<copyright>
+        <year>2020</year>
+        <holder>Federico Cabiddu, Libon</holder>
+   </copyright>
    </bookinfo>
     <toc></toc>
     

+ 5 - 0
src/modules/dispatcher/doc/dispatcher_admin.xml

@@ -1316,6 +1316,7 @@ DEST: {
 		RWEIGHT: 50
 		SOCKET: 
 		SOCKNAME: 
+		OBPROXY: 
 	}
 	LATENCY: {
 		AVG: 20.104000
@@ -2055,6 +2056,10 @@ DEST: {
 					'ping_from' - used to set the From URI in OPTIONS keepalives.
 					It overwrites the general ds_ping_from parameter.
 				</listitem>
+				<listitem>
+					'obproxy' - SIP URI of outbound proxy to be used when sending pings.
+					It overwrites the general ds_outbound_proxy parameter.
+				</listitem>
 			</itemizedlist>
 		</para>
 		</section>