Module: kamailio
Branch: master
Commit: b384a99dc62330a2638fffe07ae1b142ff41d47f
URL:
https://github.com/kamailio/kamailio/commit/b384a99dc62330a2638fffe07ae1b14…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-01-17T12:39:11+01:00
http_client: new param netinterface to set curl network interface
---
Modified: src/modules/http_client/functions.c
Modified: src/modules/http_client/http_client.c
Modified: src/modules/http_client/http_client.h
---
Diff:
https://github.com/kamailio/kamailio/commit/b384a99dc62330a2638fffe07ae1b14…
Patch:
https://github.com/kamailio/kamailio/commit/b384a99dc62330a2638fffe07ae1b14…
---
diff --git a/src/modules/http_client/functions.c b/src/modules/http_client/functions.c
index bfa42ac527..3c99d77f14 100644
--- a/src/modules/http_client/functions.c
+++ b/src/modules/http_client/functions.c
@@ -57,6 +57,7 @@ typedef struct
char *failovercon;
char *useragent;
char *hdrs;
+ char *netinterface;
unsigned int authmethod;
unsigned int http_proxy_port;
unsigned int tlsversion;
@@ -249,7 +250,9 @@ static int curL_query_url(struct sip_msg *_m, const char *_url, str
*_dst,
if(params->http_follow_redirect) {
LM_DBG("Following redirects for this request! \n");
}
-
+ if(params->netinterface != NULL) {
+ res |= curl_easy_setopt(curl, CURLOPT_INTERFACE, params->netinterface);
+ }
res |= curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_function);
res |= curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)(&stream));
@@ -576,6 +579,7 @@ int curl_con_query_url_f(struct sip_msg *_m, const str *connection,
query_params.keep_connections = conn->keep_connections;
query_params.oneline = 0;
query_params.maxdatasize = maxdatasize;
+ query_params.netinterface = default_netinterface;
query_params.http_proxy_port = conn->http_proxy_port;
if(conn->failover.s) {
failovercon = as_asciiz(&conn->failover);
@@ -654,6 +658,7 @@ int http_client_query(
query_params.http_follow_redirect = default_http_follow_redirect;
query_params.oneline = default_query_result;
query_params.maxdatasize = default_query_maxdatasize;
+ query_params.netinterface = default_netinterface;
if(default_useragent.s != NULL && default_useragent.len > 0) {
query_params.useragent = default_useragent.s;
}
diff --git a/src/modules/http_client/http_client.c
b/src/modules/http_client/http_client.c
index bdc2253b3d..6e2b216c4b 100644
--- a/src/modules/http_client/http_client.c
+++ b/src/modules/http_client/http_client.c
@@ -100,6 +100,8 @@ unsigned int default_authmethod =
CURLAUTH_BASIC
| CURLAUTH_DIGEST; /*!< authentication method - Basic, Digest or both */
+char *default_netintrface = 0; /*!< local network interface */
+
/*!< Default http query result mode
* - 0: return full result
* - 1: return first line only */
@@ -204,6 +206,7 @@ static param_export_t params[] = {
{"keep_connections", PARAM_INT, &default_keep_connections },
{"query_result", PARAM_INT, &default_query_result },
{"query_maxdatasize", PARAM_INT, &default_query_maxdatasize },
+ {"netinterface", PARAM_STRING, &default_netinterface },
{0, 0, 0}
};
diff --git a/src/modules/http_client/http_client.h
b/src/modules/http_client/http_client.h
index a3620bd233..29b451ba4d 100644
--- a/src/modules/http_client/http_client.h
+++ b/src/modules/http_client/http_client.h
@@ -69,6 +69,8 @@ extern counter_handle_t connections; /* Number of connection definitions
*/
extern counter_handle_t connok; /* Successful Connection attempts */
extern counter_handle_t connfail; /* Failed Connection attempts */
+extern char *default_netinterface;
+
/* Curl stream object */
typedef struct
{