Btw, there is a global parameter to disable server signatures:
- http://www.kamailio.org/wiki/cookbooks/devel/core#server_signature
According to the code, it affect USER-Agent when generating a request and Server header for replies.
Turn it of and can get rid of the workaround with custom header name.
Cheers, Daniel
On 09/10/14 13:52, Daniel-Constantin Mierla wrote:
Hello,
On 09/10/14 13:19, Errol Samuels wrote:
HI Daniel,
Thanks for that.
In my case I would need to use something like:
user_agent_header = "X-Proxy: $ua"
The only purpose of the above line is that Kamailio doesn't add an User-Agent header by itself, but this X-Proxy (which you can change as well).
Then you still add User-Agent in $uac_req(hdrs), but you don't end up with two User-Agent headers anymore.
Hope is more clear now the purpose of X-Proxy header.
Cheers, Daniel
since we don't what to hardcode a specific value which would affect every device that is registering but rather $ua which would set the real UA of the device that is registering at that time.
Does that make sense?
regards,
Errol
On Thu, Oct 9, 2014 at 12:09 PM, Daniel-Constantin Mierla <miconda@gmail.com mailto:miconda@gmail.com> wrote:
On 08/10/14 19:25, Errol Samuels wrote:
I followed Daniel's instructions and made some progress but not 100% there yet. -------[Global section]---------- user_agent_header="" -------[Main Routing Logic]------- # handle registrations if (is_method("REGISTER")) { $avp(new_user_agent) = $ua; } route(REGISTRAR); . . # Forward REGISTER to Freeswitch route[REGFWD] { if(!is_method("REGISTER")) { return; } route(DISPATCH); $uac_req(method)="REGISTER"; $uac_req(ruri)=$du; $uac_req(furi)=$fn + "<sip:" + $au + "@" + $ar + ">"; $uac_req(turi)=$tn + "<sip:" + $au + "@" + $ar + ">"; $uac_req(hdrs)="Contact: <sip:" + $au + "@" + $ar + ";fs_path=sip:" + $sel(cfg_get.kamailio.bindip) + ":" + $sel(cfg_get.kamailio.bindport) + ">" + "\r\n"; if($sel(contact.expires) != $null) $uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $sel(contact.expires) + "\r\n"; else $uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $hdr(Expires) + "\r\n"; $uac_req(hdrs)= $uac_req(hdrs) + "User-Agent: " + $avp(new_user_agent) + "\r\n"; uac_req_send(); exit; } #!endif ------------ Now the correct User-Agent appears in the REGISTER message but in Freeswitch it shows as unknown. U 184.xx.xx.208:5060 -> 184.xx.xx.198:6060 REGISTER sip:184.x.x.198:6060 SIP/2.0. Via: SIP/2.0/UDP 184.xx.xx.208;branch=z9hG4bKa764.668d6dc7.0. To: <sip:1001@pbx.mydomain.com <mailto:sip%3A1001@pbx.mydomain.com>>. From: <sip:1001@pbx.mydomain.com <mailto:sip%3A1001@pbx.mydomain.com>>;tag=6f72f76f3402bf7cf11f6917529ca761-2ceb. CSeq: 10 REGISTER. Call-ID: 4570a277563cdffc-61869@184.xx.xx.208 <mailto:4570a277563cdffc-61869@184.xx.xx.208>. Max-Forwards: 70. Content-Length: 0. . Contact: <sip:1001@pbx.mydomain.com <mailto:sip%3A1001@pbx.mydomain.com>;fs_path=sip:184.xx.xx.208:5060>. Expires: 120. User-Agent: Yealink SIP-T46G 28.72.0.26. . ---------------- Got some extra dots in there but not sure why they are there and how they got there. Any ideas? Anything I missed?
Apparently by setting an empty user-agent header value in kamailio config file results in an empty line in headers, which means end of headers. So it kind of breaks the headers -- I will fix that in kamailio. A solution for now will be to use: user_agent_header = "X-Proxy: abc" Or, in other words, set the value of the parameter to something that doesn't include User-Agent: as header name. Cheers, Daniel
BR Errol On Wed, Oct 8, 2014 at 12:34 PM, Daniel-Constantin Mierla <miconda@gmail.com <mailto:miconda@gmail.com>> wrote: Perhaps you can get it with adding User-Agent header to $uac_req(hdrs): $uac_req(hdrs)= $uac_req(hdrs) + "User-Agent: " + $ua + "\r\n"; And sent the global parameter: user_agent_header="" But then no local generated request has user agent, which probably is ok for you. There are still ways to use event_route[tm:local-request] to set a custom user agent header, but would require something like: - add $us in $uac_req(hdrs) as X-UA header - in event_route[tm:local-request], remove User-Agent and X-UA headers and add again User-Agent taking the value from X-UA Cheers, Daniel
-- Daniel-Constantin Mierla http://twitter.com/#!/miconda <http://twitter.com/#%21/miconda> -http://www.linkedin.com/in/miconda
-- Daniel-Constantin Mierla http://twitter.com/#!/miconda -http://www.linkedin.com/in/miconda