Lite SIP server
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
LICENSE
README.md
README.ru.md
main.go
sip.conf
sipconf.go
siputil.go

README.md

SIPLite

Description

Siplite - SIP server with register function and PBX options (forwarding, interception and transfer of calls, short number calls, voice guidance).

Setting

Siplite is controlled by only one configuration file sip.conf, which should be in the working directory of the server, and the flags of the program start from the command line of the system (CLI).

Flag Description
-d The debug mode outputs to the current terminal all SIP messages of the server
-l logging of important server events to the system log
-s directory Installing the server's working directory (default.)
-v output version of the program, reference information
-x command sending a control command or obtaining information about the status of the server

The sip.conf file is structured text, broken up using headers in square brackets into sections, which in turn describe the parameters of one of the SIP clients served on the server. The header itself is the name of the client. Followed lines in the format key=value are it's parameters. All lines beginning with a semicolon (;) character are comments and are ignored when the configuration is loaded.

Example of sip.conf file contents:

; sip.conf
;

[general]
realm = mac.local
bindaddr = 192.168.1.2
useragent = SIPLite
mediagate = 192.168.1.2: 5070

[foo]
accountcode = FOOBAR
context = domestic
secret = abc
permit = 192.168 / 16.10 / 8
exten = 1001

[bar]
accountcode = FOOBAR
host = 192.168.1.129
context = international
secret = passwd
permit = 192.168.1.129
exten = 1002

[webphone1]
accountcode = HOME
dialplan =. +
secret = 12345
exten = 1001 (2)

[webphone2]
accountcode = HOME
dialplan =. +
secret = 4321
exten = 4999876543 # 1002 = 4991234567
callerid = 4999876543

; EOF

One of the sections of the sip.conf file named general has a unique purpose, it describes the global parameters of the SIP server.

Key Description Default value
realm server domain or its name (DNS) localhost
bindaddr IP address and port of the server to which it accepts client requests (if port is not specified, standard 5060 is used) 127.0.0.1:5060
useragent server software ID SIPLite
countrycode the default country code for automatic substitution, if not entered when typing by the client 7
sitycode the default city code for automatic substitution, if not entered when typing by the client 495
mediagate the address of the media server for playing SIP voice messages to the client (IVR)
agimaster address of the auxiliary server for determining the address of the called SIP client by phone number
agislave the address of an additional auxiliary server for determining the address of the called SIP client by phone number

The remaining sections of the sip.conf file to describe SIP clients can contain the following keys.

Key Description Default value
accountcode the client group ID combines them for calls by short numbers and pickups in the limits of this group
secret password for this SIP client (its name is indicated in the square brackets of the section header)
permit comma separated IP (CIDR) addresses from which the client's requests can arrive
host static client IP address (no registration)
exten telephone number of the client in the format L#S(N)=F for connecting with him by phone number L or short number S, or transferring the connection, if not available, to another client under the serial number N in the side of the group, or forwarding to the phone number F (if redirection is needed "on unavailable", then the symbol ~ is used instead of the symbol =)
callerid identifier of the calling channel for substitution, if necessary
dialplan a standard regular expression (PCRE) that limits the range of called telephone numbers for a given SIP client (the call will take place if the dialed phone number matches this regular expression, otherwise it does not) .+
context It is used when there is no dialplan key and is replaced by it with a value according to the value of this context key (for example, context=em is perceived as dialplan=^7495\d{2,3}$)
  • Keys in tables without default values ​​for SIP server operation are not required

Exploitation

Starting the server from its working directory is performed by the command:

$ siplite &

After the changes made in the sip.conf file, you must tell the running SIP server to overload the configuration. This will not affect the current state of the connections served by the server.

$ siplite -x 'upload sip'

To collect statistics on the use of the server and analyze it, all the calls that are passed through the server are entered in the cdr.csv file of the working directory. Its contents can be viewed by the command:

$ siplite -x 'show cdr'

A list of all available commands can be obtained by the command:

$ siplite -x 'show help'

The server stops using the CLI command:

$ pkill siplite

License

SIPLite server is distributed under license MIT

Author

Vasily Suvorov (gbazil)


bazil.pro Moscow 2018