Accfile
The Accfile module is used if Yate Server is registering itself to a remote server.
It also allows to create lines(gateways) for different protocols like SIP, H323, Jabber or IAX.
For Yate to register to outside gateways to terminate calls, you have to use accfile.conf. Accfile is for Yate to register to others.
Contents |
Main actions
Module Accfile emits a login/logout for the accounts configured in accfile.conf. An account is valid if it has parameter enabled set to true or if parameter enabled is missing but the parameter username is set.
The main actions for this module are:
- login accounts
- logout accounts
- reload accounts
Actions are done for the accounts configured.
This actions are made in two ways:
- by using rmanager
- by using external module, write your own script to give an engine.command with what action you need for the configured accounts.
Commands
From telnet the format for the actions on the accounts are:
accounts [reload|{login|logout|...} [account]]
General parameters
- protocol: The protocol to register on (sip, iax, h323, jabber ...)
- username: Account username
- password: Account password
- interval: Registration interval (in seconds) to request from server (ignored for jabber)
- enabled:
- Sections with enabled=no are always ignored.
- If the enabled parameter is missing, sections without username are ignored.
- If enabled=yes the accounts are logged in even without an username.
Specific parameters
SIP
- description: Caller name to set on outgoing calls on this account if none specified when routing
- registrar: Registrar address. A port can be specified here (e.g. 1.2.3.4:7999)
- authname: Authentication name to use instead of username when authenticating
- domain: Authentication domain if any
- outbound: Optional outbound proxy server if different from registrar.
- A port can be specified here (e.g. 1.2.3.4:7999)
- ip_transport: Optional SIP transport to use (udp, tcp, tls).
- Defaults to udp
- ip_transport_remoteip: IP address to connect to register the account.
- Defaults to outbound or registrar address
- ip_transport_remoteport: IP port to connect to register the account
- ip_transport_localip: UDP: This parameter is used in conjuction ip_transport_localport
- to identify the transport to use
- TCP/TLS: Optional local ip to use when connecting
- ip_transport_localport: Local port.
- UDP only: This parameter is used to identify the transport to use
- localaddress: Local address to set in sent messages
- Set it to 'yes' to detect NAT and re-register with public ip when NAT is detected
- Set it to 'no' or ipaddress (e.g. 1.2.3.4 or 1.2.3.4:5060) to disable NAT detection
- keepalive: Optional interval for NAT keep alive.
- Defaults to 0 if NAT detection is disabled
- NOTE
- Default port is 5060 for udp/tcp and 5061 for tls
Jabber
- domain: Authentication domain
- port: Server port. Defaults to 5222
- server: Optional jabber server ip address to connect to.
- If set the jabber stream will try first to connect to this address
- localip: Optional local ip address to use when connecting.
- Connect will fail if the address is invalid
- resource: Optional resource to request from server
- priority: Optional resource priority to set in initial presence
- options: Comma separated list of stream flags
- - allowplainauth: Allow plain password authentication
- - tlsrequired: Stream encryption is required
- - noautorestart: Don't restart the stream when disconnected (NOT RECOMMENDED)
- nocompression: Boolean. Set it to 'yes' to disable stream compression
IAX
- server: Registrar address or domain. A port can be specified here (e.g. 1.2.3.4:7999)
- port: Registrar port if not specified in 'server' parameter
- If not set the port defaults to 4569
H323
- server: Registrar IP address
- addr: Local address for H323 listener (leave it empty to listen on all interfaces)
- port: Local port for H323 listener
Configuration file
accfile.conf
[test_sip] enabled=no protocol=sip ;username=me description=Test SIP account ;interval=600 ;authname=metoo ;password=1234 ;domain=somewhere.org ;registrar=10.0.0.1:5060 ;outbound=10.0.0.1:5061 ;localaddress=192.168.0.1:5062 ; [test_h323] enabled=no protocol=h323 ;username=me description=Test H.323 account ;interval=600 ;password=1234 ; [test_iax] enabled=no protocol=iax ;username=me description=Test IAX2 account ;interval=600 ;password=1234 ;server=10.0.0.2 ; [test_jabber] enabled=no protocol=jabber ;username=me ;domain=example.com ;password=1234 ;options=allowplainauth
Configuration examples
Example how to define a line
Suppose we have a SIP line and we want to route all calls through the gateway (line).
In accfile.conf:
[line_1] enabled=yes protocol=sip username=line-1 password=pwd1 domain=10.0.0.1 registrar=10.0.0.1
How to route calls from regexroute through the line
In regexroute.conf set:
;This rule will match every call and will routed through the gateway ;\0 will catch whatever is on left side of =. In this case, all phone numbers. ^.*$=line/\0;line=line-1
How to route calls using fork
You can use fork with distributed parameters (Yate> 3.3.3 ) to route to multiple lines registered in accfile.conf.
In accfile.conf
[line_1] enabled=yes protocol=sip username=line-1 password=pwd1 domain=10.0.0.1 registrar=10.0.0.1 [line_2] enabled=yes protocol=sip username=line-2 password=pwd2 domain=10.0.0.1 registrar=10.0.0.1
This will try to send the call to both gateways at the same time:
In regexroute.conf
^.*$=fork;callto.1=line/\0;callto.1.line=line-1;callto.2=line/\0;callto.2.line=line-2
How to route calls using external module
This next example shows you how to route calls from an external module. We are going to use the lines defined above in accfile.conf.
To route to a gateway from a PHP script, take a look at route.php from share/scripts directory in Yate sources and replace:
if ($ev->getValue("called") == "321") { $ev->retval = "tone/dial"; $ev->handled = true; }
with:
if ($ev->getValue("called")=="100") { $ev->retval = "line/".$ev->getValue("called"); $ev->params["line"] = "line-1"; $ev->handed = true; }
If you wish to use fork from the PHP script:
$ev->retval = "fork"; $ev->params["callto.1"] = "line/".$ev->getValue("called"); $ev->params["callto.1.line"] = "line-1"; $ev->params["callto.2"] = "line/".$ev->getValue("called"); $ev->params["callto.2.line"] = "line-2"; $ev->handed = true;
Above is the equivalent of the following line from regexroute.conf:
^.*$=fork;callto.1=line/\0;callto.1.line=line-1;callto.2=line/\0;callto.2.line=line-2
See also