Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hyperioxx/Katari
Katari - Python Session Initiated Protocol Framework
https://github.com/hyperioxx/Katari
asterisk avaya broadsoft broadworks cisco-webex phone python sip sip-library sip-server sip-stack sip-uri telecommunications telephony voip voip-communications voip-server
Last synced: about 1 month ago
JSON representation
Katari - Python Session Initiated Protocol Framework
- Host: GitHub
- URL: https://github.com/hyperioxx/Katari
- Owner: hyperioxx
- License: bsd-3-clause
- Created: 2018-01-04T22:15:58.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-25T21:33:27.000Z (almost 2 years ago)
- Last Synced: 2024-09-27T17:35:10.180Z (3 months ago)
- Topics: asterisk, avaya, broadsoft, broadworks, cisco-webex, phone, python, sip, sip-library, sip-server, sip-stack, sip-uri, telecommunications, telephony, voip, voip-communications, voip-server
- Language: Python
- Homepage:
- Size: 155 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-rtc - Katari - SIP stack application framework. (Developer Resources / Python Libraries)
README
![alt text](https://github.com/hyperioxx/Katari/blob/master/Katari.png "Katari Logo")
# Katari - SIP (Session Initiated Protocol) Application Framework
[![PyPI pyversions](https://img.shields.io/pypi/status/Katari.svg)](https://pypi.org/project/Katari/)
[![PyPI version shields.io](https://img.shields.io/pypi/v/Katari.svg)](https://pypi.python.org/pypi/Katari/)
[![PyPI license](https://img.shields.io/pypi/l/Katari.svg)](https://pypi.python.org/pypi/Katari/)
![PyPI version shields.io](https://img.shields.io/pypi/dm/Katari.svg)## Documentation
https://katari.readthedocs.io/en/latest/
## Installing
```
pip install Katari
```## Installing from Git
```
pip install git+https://github.com/hyperioxx/Katari.git
```## Getting Started
to create a katari project run the following command in your terminal
```bash
katari --build-app
```#### app.py
```python
import settings
from Katari import KatariApplication
from Katari.sip.response import ResponseFactoryapp = KatariApplication(settings=settings)
@app.invite()
def do_invite(request, client):
# add INVITE logic here
response = ResponseFactory.build(200) # 200 OK
app.send(request.create_response(response), client)@app.register()
def do_register(request, client):
# add REGISTER logic here
response = ResponseFactory.build(401) # 401 unauthorized
app.send(request.create_response(OK200()), client)@app.options()
def do_options(request, client):
# add OPTIONS logic here
response = ResponseFactory.build(200) # 200 OK
app.send(request.create_response(response), client)@app.info()
def do_info(request, client):
# add INFO logic here
response = ResponseFactory.build(200) # 200 OK
app.send(request.create_response(response), client)if __name__ == "__main__":
app.run()```
## Writing your own middleware
create a directory called middleware within your project
```
myproject -
- app.py
- settings.py
- middleware << LIKE THIS
- __init__.py
- test.py
```your middleware can modify the sip message before it reaches your main logic using the process_request method and also modify the response before it gets sent back to the client using process response method.
#### Example
test.py
```pythonfrom Katari.interfaces import MiddlewareInterface
class Test(MiddlewareInterface):
def process_request(self, message):
print(str(message))
return message
def process_response(self, message):
print(str(message))
return message```
settings.py```python
"""
## ## ### ######## ### ######## ####
## ## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ## ##
##### ## ## ## ## ## ######## ##
## ## ######### ## ######### ## ## ##
## ## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ## ####SIP (Session Initiated Protocol) Application Framework
"""
HOST = "127.0.0.1" #Specify interface to listen on
PORT = 5060 # Specify port to listen on
ALLOWED_HOSTS = ["127.0.0.1"] # Katari whitelist
USER_AGENT = "Katari Server 0.0.6" # User Agent sent in response
# Logging settings
KATARI_LOGGING = {
"LOGFILE" :"Katari.log",
"LEVEL": "INFO",
"OUTPUTMODE": "file"
}# Katari middleware
KATARI_MIDDLEWARE = [
'middleware.test', # Add import path here
]```