From fa9e811bb9cb18ad2f450db4480dcfcfde4f601f Mon Sep 17 00:00:00 2001 From: Thomas Ries Date: Fri, 3 Feb 2006 22:12:48 +0000 Subject: [PATCH] - rewrite complete incoming request URI --- ChangeLog | 1 + src/proxy.c | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/ChangeLog b/ChangeLog index c1b1931..d35a06c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 0.5.12 ====== + 3-Feb-2006: - rewrite complete incoming request URI 31-Jan-2006: - CALLIDHOST_SIZE to 128: support longer hostnames 1-Jan-2006: - short-dial: use "302 Moved" to point to target 28-Dec-2005: - Call logging: display FROM & TO for calls. diff --git a/src/proxy.c b/src/proxy.c index 1a506be..07901d9 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -1122,6 +1122,8 @@ if (configuration.debuglevel) * STS_SUCCESS on success */ int proxy_rewrite_request_uri(osip_message_t *mymsg, int idx){ + char *scheme; + char *username; char *host; char *port; osip_uri_t *url; @@ -1134,6 +1136,30 @@ int proxy_rewrite_request_uri(osip_message_t *mymsg, int idx){ DEBUGC(DBCLASS_PROXY,"rewriting incoming Request URI"); url=osip_message_get_uri(mymsg); + /* set the true scheme */ + if (url->scheme) osip_free(url->scheme);url->scheme=NULL; + if (urlmap[idx].true_url->scheme) { + DEBUGC(DBCLASS_BABBLE,"proxy_rewrite_request_uri: scheme=%s", + urlmap[idx].true_url->scheme); + scheme = (char *)malloc(strlen(urlmap[idx].true_url->scheme)+1); + memcpy(scheme, urlmap[idx].true_url->scheme, + strlen(urlmap[idx].true_url->scheme)); + scheme[strlen(urlmap[idx].true_url->scheme)]='\0'; + osip_uri_set_scheme(url, scheme); + } + + /* set the true username */ + if (url->username) osip_free(url->username);url->username=NULL; + if (urlmap[idx].true_url->username) { + DEBUGC(DBCLASS_BABBLE,"proxy_rewrite_request_uri: username=%s", + urlmap[idx].true_url->username); + username = (char*)malloc(strlen(urlmap[idx].true_url->scheme)+1); + memcpy(username, urlmap[idx].true_url->username, + strlen(urlmap[idx].true_url->username)); + username[strlen(urlmap[idx].true_url->username)]='\0'; + osip_uri_set_username(url, username); + } + /* set the true host */ if (url->host) osip_free(url->host);url->host=NULL; if (urlmap[idx].true_url->host) {