Giter Site home page Giter Site logo

mwolff44 / pk-sbc Goto Github PK

View Code? Open in Web Editor NEW
98.0 23.0 49.0 29.65 MB

P-KISS-SBC - simple and stupid SIP/RTP SBC - AGPL v3 - Based on kamailio / RTP Engine

Home Page: https://pk-sbc.io

License: GNU Affero General Public License v3.0

Shell 0.77% Dockerfile 0.09% Makefile 0.08% Gherkin 0.47% JavaScript 0.69% HTML 97.89%
agplv3 kamailio voip voip-application voip-telephony-providers softswitch sip rtp routing-engine kiss sbc security

pk-sbc's Introduction

P-Kiss-SBC project

PKS release Docker pks-sipproxy Pulls Scrutinizer Code Quality AGPLv3 License Donate to this project using Paypal


Table of content

  • About P-Kiss-SBC
  • License
  • Features
  • Prerequisites
  • Installation
  • Contact information
  • Support
  • Contributing
  • Donation
  • Stats

What is PKS : P-Kiss-SBC

The new flavor of pyfreebilling, P-KISS-SBC, is an open source simple and stupid SBC based on Kamailio and RTP Engine .

License

P-Kiss-SBC is under AGPLv3 license. You can read it in COPYING file.

AGPLv3 License

Features

There are some features supported. A few of them are:

  • IPBX/Customer add/modify/delete

    • IP termination and SIP authentication (Multitenant system support)
    • DID allocation and routing
  • Provider add/modify/delete

    • Routing based on area code
    • DID Routing
    • Routing decision based on load balancing
    • Limit max channels by each provider gateway (TBD)
  • Security

    • Blocking SIP scanner attemps
    • Blocking fraudulent connection attempts
    • SQL injection detection
    • SIP header validation
  • Design for simplicity, reliability and scalability

... and much more :)

Prerequisites

In order to run PKS, you need the following configured, secured and working Basic Operating System (Linux). P-KISS-SBC works in containers, it can be deployed on any docker or Kubernetes environment.

The project uses Kamailio, RTP Engine, Redis and a Database (by default, POSTGRESQL but also support POSTGRESQL, MARIADB, MYSQL and DBTEXT).

Contact Information

Name: Mathias WOLFF

Contact: https://blog-des-telecoms.com

Website: https://pk-sbc.io

Support

To get free support, use github issue tab.

If you need paid support, specific features or consulting services, you will find support services prices on PyFreeBilling website : https://pk-sbc.io

Contributing

Separate proposed changes and PRs into small, distinct patches by type so that they can be merged faster into upstream and released quicker:

  • Feature
  • Bugfix
  • Code style
  • Documentation

Donation

If you want to support my developments you are welcome to offer me a cup of coffee :)

Paypal donation

Stats

Project Stats

pk-sbc's People

Contributors

bitdeli-chef avatar d4rkstar avatar elektordi avatar freddy36 avatar mwolff44 avatar pyup-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pk-sbc's Issues

Missing columns...

installed everything from scratch on Debian 7.8
When I log in to dashboard everything looks fine until I decide to open one of the submenus.
I always get the same error: (with DEBUG enabled)

column company.vat_number_validated does not exist
LINE 1: ...number", "company"."vat", "company"."vat_number", "company"....

All tables exist and are properly installed.

Issue on venv

root@voip:/usr/local# virtualenv venv --no-site-packages
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 7, in
from virtualenv.main import run_with_catch
File "/usr/local/lib/python2.7/dist-packages/virtualenv/init.py", line 3, in
from .run import cli_run
File "/usr/local/lib/python2.7/dist-packages/virtualenv/run/init.py", line 12, in
from .plugin.activators import ActivationSelector
File "/usr/local/lib/python2.7/dist-packages/virtualenv/run/plugin/activators.py", line 6, in
from .base import ComponentBuilder
File "/usr/local/lib/python2.7/dist-packages/virtualenv/run/plugin/base.py", line 9, in
from importlib_metadata import entry_points
File "/usr/local/lib/python2.7/dist-packages/importlib_metadata/init.py", line 9, in
import zipp
ImportError: No module named zipp

kamailio failing acc sql inserts

currently the kamailio acc module fails to insert an accounting statement after a successful call:

ERROR: db_postgres [km_dbase.c:290]: db_postgres_submit_query(): 0x7f68ccced348 PQsendQuery Error: ERROR:  syntax error at or near ";"
LINE 1: ...lid,sip_code,sip_reason,time,time_attr,time_exten,;attempt,s...
                                                                                                             ^
Query: insert into acc (method,from_tag,to_tag,callid,sip_code,sip_reason,time,time_attr,time_exten,;attempt,src_ip,calling_num,called_number,sipCode,sipReason ) values ('INVITE','pe2Z0p17QNX9e','2Kr3jKSvpQQcj','16715364-4463-4576-aa37-5a00cd616915','200','OK','2018-04-12 15:20:04',1523546404,171581,'','','','','','')

It looks like freeswitch CDRs are used for the accounting and the acc table doesn't exists.
I assume the acc module isn't supposed to be loaded at all?

Toggle disable in LCR for carriers

It would be useful to temporarily disable a carrier from the LCR vs deleting and having to add again. Sometimes you want to test a specific carrier vs having to remove all but one, or create an lcr just for the carrier.

[solved] Is the project active?

Hello, I am evaluating to use pyfreebilling for small voip startup.

Is the project actively maintained? The links on website for forums is broken so I couldn't get the list of who is using pyfreebilling in production.

Since our first plan was to build in-house billing but your project looks promising and we can contribute development back to the community.

PS: I only see freeswitch references. Is it possible to use it with core asterisk and kamailio? I didn't read the docs in detail yet, apologies.

HI,How to install this on centos 6?

I want to install on CentOS 6, but many of the commands CentOS and Ubuntu is not consistent with the installation.md, so I want to know what better way to install Pyfreebilling to CentOS

installing on virtual machine

Hi.
Can u please provide one small tutorial for installation on to virtual machine debian .
Thank you for your great work

hardcoded SIP port

Currently you define kamailio 'address' table as the view with the following line:

    '  5060 AS port,'

It means that you hardcode 5060 as SIP port of ip authorized gateway.

It's not a good idea - there are a lot of software and hardware SIP gateways which use ports other than 5060

  • some gws just use non-standard ports - say 5070 - for both inbound and outbound
  • some gws accept inbound calls to 5060 but sends outbound from some other fixed port - e.g. 5061
  • some gws accept inbound calls to 5060 but sends outbound from some random port

as a result you should add port field to the DB and GUI or allow ip:port notation of proxy field

LCR confusion

Seems all those prefixes are easy to break... in fact never got it working...

the concat function when you lookup rates you concat (c.tech_prefix,r.prefix,'%')
basically customer prefix and rate prefix.. BUT if you dont use prefixes at all then kamailio doesnt even find a destination...

Versions for stable

Which versions of Kamailio and Freeswitch should be used for stable?
The ones in the setup documentation are too old.

Migrate to kamailio 5.8

Is your feature request related to a problem? Please describe.
Follow the Kamailio release

2.0 version

Hello Mathias,
Thank you for your awesome project. I know you planned to publish 2.0v in august. Do you have any update when it may be released? Will be glad to donate, but want to see the product in work.
Thanks.

nginx support

Hi,

could you add a nginx configuration template?

Install BUG, migrate

new install all ok a part from a few Ubuntu 18.04

docker-compose -f production.yml run --rm django python manage.py migrate

Applying pyfb_normalization.0001_initial... OK
Applying pyfb_endpoint.0001_initial... OK
Applying pyfb_endpoint.0002_auto_20181218_1700... OK
Applying pyfb_endpoint.0003_auto_20181219_1354... OK
Applying pyfb_endpoint.0004_auto_20181219_1402... OK
Applying pyfb_endpoint.0005_auto_20190130_1417...Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 82, in _execute
return self.cursor.execute(sql)
psycopg2.errors.UndefinedTable: relation "pyfb_routing_c_routinggrp" does not exist
LINE 1: ...modified FROM pyfb_endpoint_customer c INNER JOIN pyfb_routi...
^
The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "manage.py", line 30, in
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.7/site-packages/django/core/management/init.py", line 381, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.7/site-packages/django/core/management/init.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/migrate.py", line 234, in handle
fake_initial=fake_initial,
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/executor.py", line 117, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/executor.py", line 245, in apply_migration
state = migration.apply(state, schema_editor)
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/migration.py", line 124, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/operations/special.py", line 105, in database_forwards
self._run_sql(schema_editor, self.sql)
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/operations/special.py", line 130, in _run_sql
schema_editor.execute(statement, params=None)
File "/usr/local/lib/python3.7/site-packages/django/db/backends/base/schema.py", line 137, in execute
cursor.execute(sql, params)
File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 67, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python3.7/site-packages/django/db/utils.py", line 89, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 82, in _execute
return self.cursor.execute(sql)
django.db.utils.ProgrammingError: relation "pyfb_routing_c_routinggrp" does not exist
LINE 1: ...modified FROM pyfb_endpoint_customer c INNER JOIN pyfb_routi...

Thanks

Kamailio Database Is not Created.

Hello, I have installed Pyfreebilling on debian 8 with multiple IP's as mentioned in the doc and kamailio does not seem to start, after checking the logs kamailio cannot find the database "kamailiopyfb" then i checked the Database after logging in psql and i can see only pyfreebilling DB. Kamailio DB is missing, I also searched the system for the kamailio sql file but could not find it. Can you please let me know how do i create and populate the kamailio DB ?

Thanks.

Install BUG, migrate

new install all ok a part from a few jessie/trusty issues..

but python manage.py migrate crashes on a missing column...

Applying axes.0002_auto_20151217_2044... OK
Applying axes.0003_auto_20160322_0929... OK
Applying cdr.0001_initial... OK
Applying cdr.0002_auto_20161116_1546... OK
Applying cdr.0003_auto_20161129_0955... OK
Applying cdr.0004_auto_20170522_1123... OK
Applying cdr.0005_remove_cdr_customerdirectory_id... OK
Applying cdr.0006_auto_20171222_1716... OK
Applying chroniker.0001_initial... OK
Applying currencies.0002_alter_model... OK
Applying customerdirectory.0017_auto_20180207_1116... OK
Applying customerdirectory.0018_auto_20180406_1732...Traceback (most recent call last):
File "manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/init.py", line 364, in execute_from_command_line
utility.execute()
File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/init.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 204, in handle
fake_initial=fake_initial,
File "/usr/local/venv/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/db/migrations/migration.py", line 129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/db/migrations/operations/special.py", line 108, in database_forwards
self._run_sql(schema_editor, self.sql)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/db/migrations/operations/special.py", line 133, in _run_sql
schema_editor.execute(statement, params=None)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 120, in execute
cursor.execute(sql, params)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/db/utils.py", line 94, in exit
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 62, in execute
return self.cursor.execute(sql)
django.db.utils.ProgrammingError: column sg.sip_port does not exist
LINE 1: ....proxy AS VARCHAR) AS ip_addr, 32 AS mask, CAST(sg.sip_por...
^

Basic stats

Customers and Providers stats
stats by day / week / month
Nb Calls
Amount
ASR
ACD

By destinations

  • by customer
    -- provider
    -- total
  • by provider
    -- gateway
    -- total

pip install -r requirements/prod.txt

This command
python manage.py migrate

is generating errors on my machine. Can't get past this point.
Traceback (most recent call last):
File "manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/init.py", line 364, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/init.py", line 338, in execute
django.setup()
File "/usr/local/lib/python2.7/dist-packages/django/init.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 94, in create
module = import_module(entry)
File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module
import(name)
ImportError: No module named debug_toolbar

I don't see any django_setup() procedure inside /django/core/management/init.py

Why all these errors? Is there an update or bug fix?

System requirements for hardware

can we know System requirements for hardware ?

1-10 users/trunks
1-10 cps
Can a 1vcroee 2.4ghx 2gb ram dor it ? or is this more cpu hungry then ram?

Time Zone is set in local.py

Enhancement:
Timezone needs to be user configurable from the UI. As it is, it is located in /usr/local/venv/pyfreebilling/config/settings/local.py

This setting should be configurable in the UI with an option to set per customer as it affects cdr timestamps.

Billing Time is rounding up

Hi. Im using PyFreeBilling 2.1.1 and I have an issues with billed time.

In example of packet captured, you can see the time of call is 3 secs (between ACK and BYE), but in PyFreeBillling, it shows 4 secs billed.

captura de tela 2018-12-12 as 15 51 16

billed_time_pyfreebilling

Expected behavior
I think it would be possible to define how the round time is made, up or down.
I hope I made myself clear.

Thanks

DIDs without Provider or customer rate plan fail

Currently the django DID model doesn't require Provider rate plan or Customer rate plan to be set.

But if they aren't set freeswitch routing fails because it generates the following invalid SQL queries with empty ID values:

SELECT
rc.lcrgroup_id AS lcrgroup_id,                                                                                                                                                                                               
rc.callerid_filter AS callerid_filter,                                                                                                                                                                                       
rc.rctype AS rctype,                                                                                                                                                                                                         
rc.id AS ratecard_id,                                                                                                                                                                                                        
r.destination AS destination,                                                                                                                                                                                                
r.prefix AS prefix,                                                                                                                                                                                                          
r.rate AS rate,                                                                                                                                                                                                              
r.block_min_duration AS block_min_duration,                                                                                                                                                                                  
r.init_block AS init_block,                                                                                                                                                                                                  
r.minimal_time AS minimal_time,                                                                                                                                                                                              
0 AS discount                                                                                                                                                                                                                
FROM ratecard rc                                                                                                                                                                                                             
INNER JOIN customer_rates r                                                                                                                                                                                                  
	ON rc.id = r.ratecard_id AND rc.rctype = 'DIDIN'                 WHERE rc.enabled = TRUE                                                                                                                                   
	AND rc.id = ''                                                                                                                                                                                                             
	AND r.enabled = true                                                                                                                                                                                                       
	AND now() > rc.date_start                                                                                                                                                                                                  
	AND now() < rc.date_end                                                                                                                                                                                                    
	AND '4961518614771' LIKE concat(r.prefix,'%')                                                                                                                                                                              
ORDER BY LENGTH(r.prefix) desc LIMIT 1;    

Note the AND rc.id = ''
The same happens for provider rates.

I worked around this by creating corresponding dummy ratecards but I personally would prefer to fix the freeswitch script to support inbound calls without ratecard.

Interested in resellere support?

Would you be interested in extending pyfreebilling with reseller support? do you have any plans? I'm planning to implement it, do you have any advice to share?

Install Guide needs an update

For the guide located at:

https://www.pyfreebilling.com/knowledge-base/installation/

Here are some areas of concern:

Title indicates install is for Ubuntu, but is for Debian version 8. Debian 8 is End of Life
Sip server installation: Repo info outdated, and Kamailio is now on version 5.4 with repo support for Debian 10 Buster
SBC installation:Repo info also outdated, and FreeSwitch is now on version 1.10 with repo support for Debian 10 Buster. Also minor setup changes.
Web server install -> install python virtualenv: For command "virtualenv venv" the option "--no-site-packages" is no longer valid.
Web server install -> activate it : source venv/bin/activate has issues
Pyfreebilling installation -> python manage.py collectstatic (answer 'yes') throws an error "-bash: syntax error near unexpected token `(" but will execute without (answer 'yes')

I guess I will stop here. I am assuming the last error is because it is probably using python 2 when version 3 has started to become common.

import-csv.pl broken

Importing the csv data fails:

DBD::Pg::st execute failed: ERROR: syntax error at or near "004961518614771"
LINE 1: ..., '', '0', '0', '0.000000', '0.000000', '', '', ''0049615186...
^ at /usr/share/freeswitch/scripts/import-csv.pl line 154, <cdr_log> line 1.

Besides that I'm pretty sure that it's vulnerable to SQL injections via e.g. the user agent field (if it would work at all).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.