- new feature: can masquerade User-agent header

This commit is contained in:
Thomas Ries
2007-05-24 18:38:59 +00:00
parent 977e03f97c
commit c97532fdbb
5 changed files with 50 additions and 4 deletions
+1
View File
@@ -1,5 +1,6 @@
0.6.0
=====
24-May-2007: - new feature: can masquerade User-agent header
13-May-2007: - deal with locally running UAs on same host (inboud IF side)
07-May-2007: - Client-ID in RTP proxy is derived from Client IP address.
This should fix an issue with unexpectedly timing-out RTP
+11
View File
@@ -232,6 +232,17 @@ debug_port = 0
# mask_host=10.0.1.1 -- inbound IP address of proxy
# masked_host=my.public.host -- outbound hostname proxy
######################################################################
# User Agent Masquerading
#
# Siproxd can masquerade the User Agent string of your local UAs.
# Useful for Providers that do not work with some specific UAs
# (e.g. sipcall.ch - it does not work if your outgoing SIP
# traffic contains an Asterisk UA string...)
# Default is to do no replacement.
#
#ua_string = Siproxd-UA
######################################################################
# Outbound proxy
#
+35 -4
View File
@@ -189,7 +189,6 @@ int proxy_request (sip_ticket_t *ticket) {
/* 'i' still holds the valid index into the URLMAP table */
proxy_rewrite_request_uri(request, i);
/* if this is CANCEL/BYE request, stop RTP proxying */
if (MSG_IS_BYE(request) || MSG_IS_CANCEL(request)) {
/* stop the RTP proxying stream(s) */
@@ -243,9 +242,12 @@ int proxy_request (sip_ticket_t *ticket) {
}
#endif
/* rewrite Contact header to represent the masqued address */
/* Rewrite Contact header to represent the masqued address */
sip_rewrite_contact(ticket, DIR_OUTGOING);
/* Masquerade the User-Agent if configured to do so */
proxy_rewrite_useragent(ticket);
/* if an INVITE, rewrite body */
if (MSG_IS_INVITE(request)) {
sts = proxy_rewrite_invitation_body(ticket, DIR_OUTGOING);
@@ -605,7 +607,7 @@ int proxy_response (sip_ticket_t *ticket) {
* response merely indicates that the subscription has been
* understood, and that authorization may or may not have been
* granted), which then of course is forwarded back to the phone.
* Ans it seems that the Grandstream can *not* *handle* this
* And it seems that the Grandstream can *not* *handle* this
* response, as it immediately sends another SUBSCRIBE request.
* And this games goes on and on and on...
*
@@ -636,9 +638,12 @@ int proxy_response (sip_ticket_t *ticket) {
response->from->url->host ?
response->from->url->host : "*NULL*");
/* rewrite Contact header to represent the masqued address */
/* Rewrite Contact header to represent the masqued address */
sip_rewrite_contact(ticket, DIR_OUTGOING);
/* Masquerade the User-Agent if configured to do so */
proxy_rewrite_useragent(ticket);
/*
* If an 2xx OK or 1xx response, answer to an INVITE request,
* rewrite body
@@ -1204,3 +1209,29 @@ int proxy_rewrite_request_uri(osip_message_t *mymsg, int idx){
}
return STS_SUCCESS;
}
/*
* PROXY_REWRITE_USERAGENT
*
* rewrites the User Agent String
*
* RETURNS
* STS_SUCCESS on success
*/
int proxy_rewrite_useragent(sip_ticket_t *ticket){
osip_header_t *ua_hdr=NULL;
char *useragent;
osip_message_get_user_agent(ticket->sipmsg, 0, &ua_hdr);
/* Configured? & Does User-Agent header exist? */
if ((configuration.ua_string) && (ua_hdr && ua_hdr->hvalue)) {
DEBUGC(DBCLASS_PROXY,"proxy_rewrite_useragent: [%s] -> [%s]",
ua_hdr->hvalue, configuration.ua_string);
osip_free(ua_hdr->hvalue);
ua_hdr->hvalue=osip_malloc(strlen(configuration.ua_string)+1);
strcpy(ua_hdr->hvalue, configuration.ua_string);
}
return STS_SUCCESS;
}
+1
View File
@@ -183,6 +183,7 @@ static int parse_config (FILE *configfile) {
{ "pi_shortdial_enable", TYP_INT4, &configuration.pi_shortdial },
{ "pi_shortdial_akey", TYP_STRING, &configuration.pi_shortdial_akey },
{ "pi_shortdial_entry", TYP_STRINGA,&configuration.pi_shortdial_entry },
{ "ua_string", TYP_STRING, &configuration.ua_string },
{0, 0, 0}
};
+2
View File
@@ -94,6 +94,7 @@ struct siproxd_config {
int pi_shortdial;
char *pi_shortdial_akey;
stringa_t pi_shortdial_entry;
char *ua_string;
};
/*
@@ -143,6 +144,7 @@ int proxy_request (sip_ticket_t *ticket); /*X*/
int proxy_response (sip_ticket_t *ticket); /*X*/
int proxy_rewrite_invitation_body(sip_ticket_t *ticket, int direction); /*X*/
int proxy_rewrite_request_uri(osip_message_t *mymsg, int idx); /*X*/
int proxy_rewrite_useragent(sip_ticket_t *ticket); /*X*/
/* route_preprocessing.c */
int route_preprocess(sip_ticket_t *ticket); /*X*/