Yate Community Forum
General Category => Yate users hangout place => Topic started by: jehanzaib_kiani on July 22, 2014, 05:19:16 PM
-
hi folks,
i am new in yate, just installed. i want to achieve round robin but need to check first the incoming registered user IP and then route it to appropiate IP.
like my users would register on yate, the incoming call IP will be checked from db and then i will be able to set the server for routing.
i know the static round robin routing can be achieved like ^00.*$=fork $(index,$idx00,| sip/sip:\0@provider1.com,| sip/sip:\0@provider2.com) | sip/sip:\0@provider3.com
anyone who has done this before? please guide.
-
Hi,
You can install a handler in the register module/javascript routing script/external module global script with a higher priority and make a query that verifies the ip address. You can reject the call here. If call is not rejected, you let it was and it will be handled by regexroute where you set up round robin.
-
hi thanks for the reply. sorry i m newbee did not understand where i need to write a script. i will use php if i have to write a script.
so my scanrio will be like if the incoming user is not registered then check its ip if it is in my db then let it dial. if it is registered user then let it dial. everything else will be rejected.
right now i am using regexroute.conf where my unauthenticated user is rejected and registered user is able to dialout. the only bit left is where i have to check the IP
can you please guide me which file i have to write a query for valid ip?
thanks
-
Hi,
Look in share/scripts/route.php from yate's sources.
Modify below to check the "address"
if ($ev->getValue("called") == "321") {
$ev->retval = "tone/dial";
$ev->handled = true;
}
Something like this:
if (!in_array($ev->getValue("address"),array("ip1","ip2"...)) {
$ev->error = "noroute";
$ev->handled = true;
}
-
Hi thanks for the reply,
yes i found /usr/local/share/yate/scripts/route.php
and modified like like. where $trunk_ip is having my all the allowed ips . but the piece of code is not called thats what the logs are showing.
if (!in_array($ev->getValue("address"),$trunk_ip)) {
$ev->error = "noroute";
$ev->handled = true;
}
here are the logs. it should not send calls to my mysipserver.com as this is not a registered user neither the ip is in the trunk_info array. can you suggest anything please. thanks
20140811233228.371866 <INFO> Could not classify call from 'test', wasted 2 usec
20140811233228.371938 <cdrbuild:INFO> Got message 'call.route' for untracked id 'sip/623'
20140811233228.372097 <INFO> Routing call to '12022899898' in context 'default' via 'fork | sip/sip:12022899898@mysipserver.com' in 92 usec
20140811233228.422545 <callfork:CALL> Call 'sip/623' calling on regular 'fork/303/1' target 'sip/sip:12022899898@mysipserver.com'
20140811233234.119916 <callfork:NOTE> Call 'sip/623' lost slave 'fork/303/1' reason 'forbidden' remaining 0 regulars, 0 auxiliars, 0 persistent
-
Did you edit extmodule.conf to set script to start? Check the start of the route.php script for instructions on how to start it.
-
hi thank you for your reply thanks
can you please have a look what else i have to change in this file ? the route.php path is /usr/local/share/yate/scripts/route.php
thanks
here is my [root@gw ~]# vim /usr/local/etc/yate/extmodule.conf
[general]
; General settings for the external module
; scripts_dir: string: The absolute or relative path used by default to load
; scripts if no full path is specified
; Note that a trailing path separator should be added
; Uncomment the following line when running in the sources directory
scripts_dir=share/yate/scripts/
; priority: int: Priority of the call.execute handler
;priority=100
; timeout: int: How many milliseconds to wait for a module to answer
;timeout=10000
; timebomb: bool: Kill the module instance if it timed out
;timebomb=false
; waitflush: int: Milliseconds to wait at script shutdown after waiting messages
; and message relays are flushed, valid range 1-100 ms
;waitflush=5
; trackparam: bool: Add the external module to the handler tracking parameter
; The default of false lets each external script do so
trackparam=true
[scripts]
; Add one entry in this section for each global external module that is to be
; loaded on Yate startup
; Each line has to be on the form:
scriptname=share/yate/scripts/route.php
; The script name should hold either the absolute path and name or the path
; and name relative to the scripts_dir in section [general]
; The parameter is optional and if present is passed to the script as the first
; (and single) parameter
[execute]
; Add one entry in this section for each external program that is to be
; executed on Yate startup
; Each line has to be on the form:
; progname=parameter
; The program name should hold the absolute path to the program
; The parameter is optional and if present is passed to the program as the first
; (and single) parameter
-
If you are running yate from sources or you installed it, and you didn't modify the scripts directory by hand then this is how extmodule.conf should look.
[scripts]
route.php=
-
hi
i have installed it from the source but my /usr/local/etc/yate/extmodule.conf file is not having only 1 line. its a big file like i already sent you the contents of the file.
so the scripts directory path is
[scripts]
scriptname=share/yate/scripts/route.php
-
This what you need to have in [scripts] section in that file:
[scripts]
route.php=
This is not correct:
scriptname=share/yate/scripts/route.php
If you want to set a path to the script it would look like this:
share/yate/scripts/route.php=
You won't need to set a path to the script there. Just "route.php=" should be enough.
The length on the file doesn't matter. The majority of those line are comments.
-
please see the attached sniffer. when i dial 99 i can see the script route.php is called but i cant see any effect. i have also put
Yate::Output("gw.conf247.com routing \n");
so it should show this line but i cant see in the logs, any idea?
-
You routed from regexroute or someplace else to this script. That is wrong. You have to route to a channel script. Ex: voicemail.php
route.php is a global script. Don't send calls to it from other modules. If the script was started it will catch the calls on it's own. So i guess you didn't set it in extmodule.conf. I don't see handlers from extmodule in call.route message so script was not started.
-
ok let me sum up what i did. see the below extmodule.conf i have already set the script what else i need to do ?
in /usr/local/etc/yate/regexroute.conf
[default]
^99$=/usr/local/share/yate/scripts/route.php
in /usr/local/etc/yate/extmodule.conf
[general]
scripts_dir=share/yate/scripts/
trackparam=true
[scripts]
route.php=
share/yate/scripts/route.php=
-
by the way my regexroute.conf have these lines. i have removed the direct call of route.php from the regexroute.conf file
[$once]
sip_srv=198.23.194.134
[default]
^001.*$=fork $(index,$idx01,| sip/sip:\0@myprovider1.com,| sip/sip:\0@myprovider2.com);osip_Yatebillid=${billid};rtp_forward=true;maxcall=30000
[user.auth]
my extmodule.conf have below lines. but i still cant see the route.php to run. is there any other settings i have to change? any priority or anything else. i have not touched anything else yet.
[general]
scripts_dir=share/yate/scripts/
trackparam=true
[scripts]
route.php=
share/yate/scripts/route.php=
-
Post a log with -vvvvv of yate starting. This way we can see if there were any issues when yate tries to start the script.
-
All good, figured it out from the logs that the path was not correct so if you have default path then you need to comment the below line. so just use route.php=
[scripts]
route.php=
;share/yate/scripts/route.php=
This has resolved the issue, now i can see route.php is being called. i will explore it more in a few days.
All looks good so far. much appreciated for your help.
Cheers!
-
Hi team,
The routing worked for a few times then it stop working.
please see the attached log file, looks like the route.php is loaded successfully but its not called when i have dialed the number. the call was dialed successfully but it did not call the route.php
script does not have any error.
any idea what it could be ?
-
Hi,
Enable message sniffer (telnet command: msgsniff on).
Check the call.route message 'handlers' parameter. On return it should show the name of the message handler(s) processing it.
-
hi there,
yes i have enabled the sniffer i cant see anything in the call.route Return. but i can see the priority of route.php is 80.
please see the attached sniffer for reference.
yate.conf247.com (is my yate server)
xx.xx.xx.xx (is my eyeabeam softphone ip)
100extension (is my eyebeam extension)
mysipserer.com (is my sipserver where i route the call - in regexroute,,conf)
let me know if you can find anything. thanks
-
sorry here is the file attached
-
Hi,
Your script is receiving the message and don't handle it.
See handlers='register:50,regexroute:100,cdrbuild:50,register:50,route.php:80,fileinfo:90,subscription:100,iax:100,regexroute:100'
The message is handled by regexroute.
Check the script to see why it doesn't handle the message.
-
i figured it out, the route.php was not returning anything but the error i should see is Not Permitted but i saw the sip response as 404 Not Found
$ev->error = "Not Permitted";
$ev->handled = true;
If i $ev->Acknowledge(); the call then it follows the regexroute.conf route and routed to my provider sip server with other parameters like what i set in the regexroute.conf , also set the osip_Yatebillid like i am doing in the regexroute.conf, is there anyways i route the call directly from here i mean from route.php.
i have not found any guide from yate wiki on this.
much appreciated for your help. thanks
-
Yes, you can.
Set the call target in call.route event retval.
E.g.:
$ev->retval = "sip/sip:1@1.2.3.4";
$ev->handled = true;
$ev->Acknowledge();
-
sure thanks.
but how will i set the osip_Yatebillid header if i want to ? like i am setting in regexroute.conf osip_Yatebillid=${billid};
thanks
-
To set message parameters use the SetParam method.
To obtain message params use the GetValue method.
$ev->SetParam("osip_Yatebillid",$ev->GetValue("billid"));
-
thanks. actually i have to replace regexroute.conf line
^1.*$=fork $(index,$idx01,| sip/sip:\0@mysip1.com,| sip/sip:\0@mysip2.com);osip_Yatebillid=${billid};rtp_forward=true;maxcall=30000
To route.php can you please check if the below is fine. no idea how to route to mysip2.com if the mysip1.com will be down.
$ev->SetParam("osip_Yatebillid",$ev->GetValue("billid"));
$ev->SetParam("rtp_forward",true);
$ev->SetParam("maxcall",30000);
$ev->retval = "sip/sip:1@mysip1.com";
$ev->handled = true;
-
I'm not a good php programmer but it seems fine to me.
If you want to call on both targets (and rotate them) using fork I suppose you can:
Global variable:
$firstProvider = true;
In handler:
$ev->SetParam("callto.2","|");
if ($firstProvider) {
$ev->SetParam("callto.1","sip/sip:1@mysip1.com");
$ev->SetParam("callto.3","sip/sip:1@mysip2.com");
}
else {
$ev->SetParam("callto.1","sip/sip:1@mysip2.com");
$ev->SetParam("callto.3","sip/sip:1@mysip1.com");
}
$firstProvider = !$firstProvider;
$ev->retval = "fork";