]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-2896 --resolve
authorMarc Olivier Chouinard <mochouinard@moctel.com>
Sun, 18 Dec 2011 06:48:35 +0000 (01:48 -0500)
committerMarc Olivier Chouinard <mochouinard@moctel.com>
Sun, 18 Dec 2011 06:48:35 +0000 (01:48 -0500)
conf/autoload_configs/xml_curl.conf.xml
src/mod/xml_int/mod_xml_curl/mod_xml_curl.c

index 21e0af6b6804ff903c0df737a155b106134c0372..30951d83c83f28cb870e1ecafe99bf88b97e6ce8 100644 (file)
@@ -1,6 +1,8 @@
 <configuration name="xml_curl.conf" description="cURL XML Gateway">
   <bindings>
     <binding name="example">
+      <!-- Allow to bind on a particular IP for requests sent -->
+      <!--<param name="bind-local" value="$${local_ip_v4}" />-->
       <!-- The url to a gateway cgi that can generate xml similar to
           what's in this file only on-the-fly (leave it commented if you dont
           need it) -->
index 0ba450b726beeaf5af8301557aa4466706f72a60..e5fa3ff032dee71be79d686be92d59858d575004 100644 (file)
@@ -44,6 +44,7 @@ struct xml_binding {
        char *url;
        char *bindings;
        char *cred;
+       char *bind_local;
        int disable100continue;
        int use_get_style;
        uint32_t enable_cacert_check;
@@ -283,6 +284,10 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con
                        switch_curl_easy_setopt(curl_handle, CURLOPT_COOKIEFILE, binding->cookie_file);
                }
 
+               if (binding->bind_local) {
+                       curl_easy_setopt(curl_handle, CURLOPT_INTERFACE, binding->bind_local);
+               }
+
                switch_curl_easy_perform(curl_handle);
                switch_curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &httpRes);
                switch_curl_easy_cleanup(curl_handle);
@@ -348,6 +353,7 @@ static switch_status_t do_config(void)
        for (binding_tag = switch_xml_child(bindings_tag, "binding"); binding_tag; binding_tag = binding_tag->next) {
                char *bname = (char *) switch_xml_attr_soft(binding_tag, "name");
                char *url = NULL;
+               char *bind_local = NULL;
                char *bind_cred = NULL;
                char *bind_mask = NULL;
                char *method = NULL;
@@ -434,10 +440,13 @@ static switch_status_t do_config(void)
                                        need_vars_map = 1;
                                }
 
-                               if (vars_map && val)
+                               if (vars_map && val) {
                                        if (switch_core_hash_insert(vars_map, val, ENABLE_PARAM_VALUE) != SWITCH_STATUS_SUCCESS) {
                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Can't add %s to params hash!\n", val);
                                        }
+                               }
+                       } else if (!strcasecmp(var, "bind-local")) {
+                               bind_local = val;
                        }
                }
 
@@ -460,6 +469,9 @@ static switch_status_t do_config(void)
                binding->url = strdup(url);
                switch_assert(binding->url);
 
+               if (bind_local != NULL) {
+                       binding->bind_local = strdup(bind_local);
+               }
                if (method != NULL) {
                        binding->method = strdup(method);
                } else {