Accfile
(→Main actions) |
(→SIP) |
||
(71 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | The Accfile module is used | + | The Accfile module is used to register Yate to outside gateways to terminate calls. The accounts that are defined in accfile can use different protocols like SIP, H323, Jabber or IAX. |
− | + | This module defines a connection with authentication between Yate and a server(gateway). Yate Server will be a client for that server(gateway). The connection information will be configured in a file: accfile.conf. A basic connection is defined by: protocol, username, password and the server ip. | |
− | + | Accfile just makes the connection to a specific gateway. When you want to route calls to the accounts defined in accfile, you have to use a [[routing]] module, like [[Regular expressions|regexroute]] or make the routing from an external script using the [[External Module|external module]] or [[javascript]]. | |
[[File: yate_register_to_gateway.png]] | [[File: yate_register_to_gateway.png]] | ||
− | === | + | === Define account=== |
− | + | ==== General parameters==== | |
− | The | + | The setting of the following parameters usually define a valid account. |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
* protocol: The protocol to register on (sip, iax, h323, jabber ...) | * protocol: The protocol to register on (sip, iax, h323, jabber ...) | ||
Line 36: | Line 18: | ||
* password: Account password | * password: Account password | ||
* interval: Registration interval (in seconds) to request from server (ignored for jabber) | * interval: Registration interval (in seconds) to request from server (ignored for jabber) | ||
+ | * server: Registrar IP address | ||
* enabled: | * enabled: | ||
: Sections with enabled=no are always ignored. | : Sections with enabled=no are always ignored. | ||
Line 41: | Line 24: | ||
: If enabled=yes the accounts are logged in even without an username. | : If enabled=yes the accounts are logged in even without an username. | ||
− | + | An account is valid if it has parameter '''enabled''' set to true or if parameter enabled is missing but the parameter username is set. | |
− | ====SIP==== | + | As an example of configuring a line(gateway) in accfile.conf: |
+ | |||
+ | [my_line] | ||
+ | enabled=yes | ||
+ | protocol=sip | ||
+ | username=routecalls | ||
+ | password=mysecret | ||
+ | server=192.168.168.156 | ||
+ | |||
+ | The protocol set here is 'sip' but it can also be (iax, h323, jabber). | ||
+ | |||
+ | After this parameters follows the protocol specific parameters described below. | ||
+ | |||
+ | ==== Specific parameters==== | ||
+ | In some cases, depending on the gateway you wish to connect to, you might need to set some protocol specific information. | ||
+ | =====SIP===== | ||
* description: Caller name to set on outgoing calls on this account if none specified when routing | * description: Caller name to set on outgoing calls on this account if none specified when routing | ||
Line 53: | Line 51: | ||
* ip_transport: Optional SIP transport to use (udp, tcp, tls). | * ip_transport: Optional SIP transport to use (udp, tcp, tls). | ||
: Defaults to udp | : Defaults to udp | ||
− | * | + | * '''ip_transport_localip''': |
− | : | + | : UDP: This parameter is used in conjuction ip_transport_localport to identify the listener to use |
− | + | ||
− | + | ||
− | + | ||
: TCP/TLS: Optional local ip to use when connecting | : TCP/TLS: Optional local ip to use when connecting | ||
− | * ip_transport_localport: | + | * '''ip_transport_localport''': |
− | : UDP only: This parameter is used to identify the | + | : UDP only: This parameter is used to identify the listener to use |
+ | : TCP/TLS: Optional local port to use when connecting | ||
* localaddress: Local address to set in sent messages | * 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 'yes' to detect NAT and re-register with public ip when NAT is detected | ||
Line 66: | Line 62: | ||
* keepalive: Optional interval for NAT keep alive. | * keepalive: Optional interval for NAT keep alive. | ||
: Defaults to 0 if NAT detection is disabled | : Defaults to 0 if NAT detection is disabled | ||
+ | * sips: Boolean. Use SIPS URI for register/contact. Transport defaults to TLS if enabled | ||
; NOTE: Default port is 5060 for udp/tcp and 5061 for tls | ; NOTE: Default port is 5060 for udp/tcp and 5061 for tls | ||
− | ==== Jabber==== | + | ===== Jabber===== |
* domain: Authentication domain | * domain: Authentication domain | ||
Line 84: | Line 81: | ||
* nocompression: Boolean. Set it to 'yes' to disable stream compression | * nocompression: Boolean. Set it to 'yes' to disable stream compression | ||
− | ==== IAX ==== | + | ===== IAX ===== |
* server: Registrar address or domain. A port can be specified here (e.g. 1.2.3.4:7999) | * 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 | * port: Registrar port if not specified in 'server' parameter | ||
: If not set the port defaults to 4569 | : If not set the port defaults to 4569 | ||
+ | * connection_id: The name of the iax listener to use for registration and outgoing calls | ||
+ | * ip_transport_localip: This parameter is used in conjuction ip_transport_localport to identify the listener to use for registration and outgoing calls | ||
+ | * ip_transport_localport: Local port. This parameter is used to identify the listener to use for registration and outgoing calls | ||
+ | * trunking: Enable trunking for outgoing calls sent on this line | ||
+ | * trunk_timestamps: Configure how trunked audio data is sent, enable it for trunked data with timestamps and disable it to send trunked data without timestamps | ||
+ | * trunk_sendinterval: Interval, in milliseconds, to send trunked trunked audio data | ||
+ | * trunk_maxlen: Maximum value for trunked data frames | ||
+ | * trunk_nominits_sync_use_ts: Configure how to re-build timestamps when processing incoming trunked audio without miniframe timestamps | ||
+ | * trunk_nominits_ts_diff_restart: The difference (in milliseconds) between current timestamp and first timestamp of incoming trunked audio data without miniframe timestamps at which to restart timestamps build data | ||
+ | * trunk_efficient_use: Use the trunk efficiently: don't send trunking data when there is only 1 call using it | ||
− | ==== H323 ==== | + | ===== H323 ===== |
* server: Registrar IP address | * server: Registrar IP address | ||
Line 96: | Line 103: | ||
* port: Local port for H323 listener | * port: Local port for H323 listener | ||
− | === | + | ===Manage accounts using rmanager=== |
− | accfile | + | You can use rmanager module to command accfile to reload, login or logout a specific account or all accounts if parameter '''[account]''' is not specified: |
− | [ | + | accounts [reload|{login|logout|...} [account]] |
− | + | ||
− | + | To see what accounts are logged in that moment: | |
− | + | status accfile | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
===Configuration examples=== | ===Configuration examples=== | ||
Line 142: | Line 116: | ||
====Example how to define a line==== | ====Example how to define a line==== | ||
− | Suppose we have a SIP line and we want to route all calls through the gateway (line). | + | Suppose we have a SIP line and we want to route all calls through the gateway(line). |
In accfile.conf: | In accfile.conf: | ||
Line 158: | Line 132: | ||
In regexroute.conf set: | In regexroute.conf set: | ||
− | + | ^.*$=line/\0;line=line_1 | |
− | + | ||
− | + | ||
− | ====How to route calls | + | * this rule will match every call and will route the call through the gateway |
+ | * the '''line''' parameter is fixed. | ||
+ | * \0 will catch whatever is on left side of =. In this case, the phone number. | ||
+ | * line=line_1 will tell Yate on which gateway/account to route the call. | ||
+ | |||
+ | ====How to route calls to multiple accounts==== | ||
You can use fork with distributed parameters (Yate> 3.3.3 ) to route to multiple lines registered in accfile.conf. | You can use fork with distributed parameters (Yate> 3.3.3 ) to route to multiple lines registered in accfile.conf. | ||
Line 187: | Line 164: | ||
In regexroute.conf | In regexroute.conf | ||
− | ^.*$=fork;callto.1=line/\0;callto.1.line= | + | ^.*$=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==== | ====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. | + | This next example shows you how to route calls from an [[External_Module|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: | To route to a gateway from a PHP script, take a look at route.php from share/scripts directory in Yate sources and replace: | ||
Line 202: | Line 179: | ||
if ($ev->getValue("called")=="100") { | if ($ev->getValue("called")=="100") { | ||
$ev->retval = "line/".$ev->getValue("called"); | $ev->retval = "line/".$ev->getValue("called"); | ||
− | $ev->params["line"] = " | + | $ev->params["line"] = "line_1"; |
− | $ev-> | + | $ev->handled = true; |
} | } | ||
Line 210: | Line 187: | ||
$ev->retval = "fork"; | $ev->retval = "fork"; | ||
$ev->params["callto.1"] = "line/".$ev->getValue("called"); | $ev->params["callto.1"] = "line/".$ev->getValue("called"); | ||
− | $ev->params["callto.1.line"] = " | + | $ev->params["callto.1.line"] = "line_1"; |
$ev->params["callto.2"] = "line/".$ev->getValue("called"); | $ev->params["callto.2"] = "line/".$ev->getValue("called"); | ||
− | $ev->params["callto.2.line"] = " | + | $ev->params["callto.2.line"] = "line_2"; |
− | $ev-> | + | $ev->handled = true; |
Above is the equivalent of the following line from regexroute.conf: | Above is the equivalent of the following line from regexroute.conf: | ||
− | ^.*$=fork;callto.1=line/\0;callto.1.line= | + | ^.*$=fork;callto.1=line/\0;callto.1.line=line_1;callto.2=line/\0;callto.2.line=line_2 |
− | + | ||
Line 226: | Line 202: | ||
* [[Regfile]] | * [[Regfile]] | ||
* [[Register]] | * [[Register]] | ||
+ | |||
+ | [[Category:Routing]] [[Category:Server]] [[Category:Gateway]] |
Latest revision as of 12:07, 6 July 2018
The Accfile module is used to register Yate to outside gateways to terminate calls. The accounts that are defined in accfile can use different protocols like SIP, H323, Jabber or IAX.
This module defines a connection with authentication between Yate and a server(gateway). Yate Server will be a client for that server(gateway). The connection information will be configured in a file: accfile.conf. A basic connection is defined by: protocol, username, password and the server ip.
Accfile just makes the connection to a specific gateway. When you want to route calls to the accounts defined in accfile, you have to use a routing module, like regexroute or make the routing from an external script using the external module or javascript.
Contents |
[edit] Define account
[edit] General parameters
The setting of the following parameters usually define a valid account.
- 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)
- server: Registrar IP address
- 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.
An account is valid if it has parameter enabled set to true or if parameter enabled is missing but the parameter username is set.
As an example of configuring a line(gateway) in accfile.conf:
[my_line] enabled=yes protocol=sip username=routecalls password=mysecret server=192.168.168.156
The protocol set here is 'sip' but it can also be (iax, h323, jabber).
After this parameters follows the protocol specific parameters described below.
[edit] Specific parameters
In some cases, depending on the gateway you wish to connect to, you might need to set some protocol specific information.
[edit] 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_localip:
- UDP: This parameter is used in conjuction ip_transport_localport to identify the listener to use
- TCP/TLS: Optional local ip to use when connecting
- ip_transport_localport:
- UDP only: This parameter is used to identify the listener to use
- TCP/TLS: Optional local port to use when connecting
- 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
- sips: Boolean. Use SIPS URI for register/contact. Transport defaults to TLS if enabled
- NOTE
- Default port is 5060 for udp/tcp and 5061 for tls
[edit] 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
[edit] 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
- connection_id: The name of the iax listener to use for registration and outgoing calls
- ip_transport_localip: This parameter is used in conjuction ip_transport_localport to identify the listener to use for registration and outgoing calls
- ip_transport_localport: Local port. This parameter is used to identify the listener to use for registration and outgoing calls
- trunking: Enable trunking for outgoing calls sent on this line
- trunk_timestamps: Configure how trunked audio data is sent, enable it for trunked data with timestamps and disable it to send trunked data without timestamps
- trunk_sendinterval: Interval, in milliseconds, to send trunked trunked audio data
- trunk_maxlen: Maximum value for trunked data frames
- trunk_nominits_sync_use_ts: Configure how to re-build timestamps when processing incoming trunked audio without miniframe timestamps
- trunk_nominits_ts_diff_restart: The difference (in milliseconds) between current timestamp and first timestamp of incoming trunked audio data without miniframe timestamps at which to restart timestamps build data
- trunk_efficient_use: Use the trunk efficiently: don't send trunking data when there is only 1 call using it
[edit] 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
[edit] Manage accounts using rmanager
You can use rmanager module to command accfile to reload, login or logout a specific account or all accounts if parameter [account] is not specified:
accounts [reload|{login|logout|...} [account]]
To see what accounts are logged in that moment:
status accfile
[edit] Configuration examples
[edit] 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
[edit] How to route calls from regexroute through the line
In regexroute.conf set:
^.*$=line/\0;line=line_1
- this rule will match every call and will route the call through the gateway
- the line parameter is fixed.
- \0 will catch whatever is on left side of =. In this case, the phone number.
- line=line_1 will tell Yate on which gateway/account to route the call.
[edit] How to route calls to multiple accounts
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
[edit] 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->handled = 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->handled = 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