Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typos #293

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ The following table shows all the change types we use. All like change types sho
| Fixed something that was broken | FIX |
| Removed code, file, etc. | REMOVE |

Each line of your commit message should not excede 79 characters. PEP8 limits code to 79 characters long because `Limiting the required editor window width makes it possible to have several files open side by side, and works well when using code review tools that present the two versions in adjacent columns`. This will ensure readability when running `git log`.
Each line of your commit message should not exceed 79 characters. PEP8 limits code to 79 characters long because `Limiting the required editor window width makes it possible to have several files open side by side, and works well when using code review tools that present the two versions in adjacent columns`. This will ensure readability when running `git log`.

For multilined descriptions, the following line should start inline with the first letter after the change type.

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This basic code will simple make a phone that will automatically answer then han
from pyVoIP.credentials import CredentialsManager
from pyVoIP.VoIP.call import VoIPCall
from pyVoIP.VoIP.error import InvalidStateError
from pyVoIP.VoIP.phone import VoIPPhone, VoIPPhoneParamter
from pyVoIP.VoIP.phone import VoIPPhone, VoIPPhoneParameter

class Call(VoIPCall):

Expand All @@ -35,7 +35,7 @@ class Call(VoIPCall):
if __name__ == "__main__":
cm = CredentialsManager()
cm.add(<SIP server username>, <SIP server password>)
params = VoIPPhoneParamter(<SIP server IP>, <SIP server port>, <SIP server user>, cm, bind_ip=<Your computers local IP>, call_class=Call)
params = VoIPPhoneParameter(<SIP server IP>, <SIP server port>, <SIP server user>, cm, bind_ip=<Your computers local IP>, call_class=Call)
phone = VoIPPhone(params)
phone.start()
input('Press enter to disable the phone')
Expand Down
8 changes: 4 additions & 4 deletions docs/Credentials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Credentials

Since SIP requests can traverse multiple servers and can receive multiple challenges, the Credentials Manager was made to store multiple passwords and pyVoIP will use the appropriate password upon request.

Per `RFC 3261 Section 22.1 <https://www.rfc-editor.org/rfc/rfc3261.html#section-22.1>`_, SIP uses authentication similar to HTTP authentication (:RFC:`2617`), with the main difference being ``The realm string alone defines the protection domain.``. However, some services always use the same domain. For example, if you need to authenticate with two seperate Asterisk servers, the realm will almost certainly be ``asterisk`` for both, despite being otherwise unrelated servers. For that reason, the Credentials Manager also supports server filtering.
Per `RFC 3261 Section 22.1 <https://www.rfc-editor.org/rfc/rfc3261.html#section-22.1>`_, SIP uses authentication similar to HTTP authentication (:RFC:`2617`), with the main difference being ``The realm string alone defines the protection domain.``. However, some services always use the same domain. For example, if you need to authenticate with two separate Asterisk servers, the realm will almost certainly be ``asterisk`` for both, despite being otherwise unrelated servers. For that reason, the Credentials Manager also supports server filtering.

.. _CredentialsManager:

Expand All @@ -19,10 +19,10 @@ CredentialsManager
The *password* argument is the password that will be used in the Authentication header digest calculation.

The *server* argument is used to determine the correct credentials when challenged for authentication. If *server* is left as ``None``, the credentials may be selected with any server.

The *realm* argument is used to determine the correct credentials when challenged for authentication. If *realm* is left as ``None``, the credentials may be selected with any realm.

The *user* argument is used to determine the correct credentials when challenged for authentication. If *user* is left as ``None``, the credentials may be selected with any user. The *user* argument is the user in the SIP URI, **not** the username used in authentication.

**get**\ (server: str, realm: str, user: str) -> Dict[str, str]
Looks for credentials that match the server, realm, and user in that order. If no matchng credentials are found, this will return anonymous credentials as a server MAY accept them per `RFC 3261 Section 22.1 <https://www.rfc-editor.org/rfc/rfc3261.html#section-22.1>`_.
38 changes: 19 additions & 19 deletions docs/Examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ Setup

PyVoIP uses a :ref:`VoIPPhone` class to receive and initiate phone calls. The settings for our phone are passed via the :ref:`VoIPPhoneParameter` dataclass. When a call is received, a new instance of a :ref:`VoIPCall` is initialized. You can overwrite this class in initialization of VoIPPhone.

In this example, we are importing :ref:`CredentialsManager`, :ref:`VoIPPhone`, :ref:`VoIPPhoneParameter`, :ref:`VoIPCall`, and :ref:`InvalidStateError<InvalidStateError>`. :ref:`CredentialsManager` stores and retreives passwords for authentication with registrars. :ref:`VoIPPhone` is the main class for our `softphone <https://en.wikipedia.org/wiki/Softphone>`_. :ref:`VoIPPhoneParameter` is the settings for our :ref:`VoIPPhone`. :ref:`VoIPCall` will be used to create our custom answering class. An :ref:`InvalidStateError<InvalidStateError>` is thrown when you try to perform an impossible command. For example, denying the call when the phone is already answered, answering when it's already answered, etc.
In this example, we are importing :ref:`CredentialsManager`, :ref:`VoIPPhone`, :ref:`VoIPPhoneParameter`, :ref:`VoIPCall`, and :ref:`InvalidStateError<InvalidStateError>`. :ref:`CredentialsManager` stores and retrieves passwords for authentication with registrars. :ref:`VoIPPhone` is the main class for our `softphone <https://en.wikipedia.org/wiki/Softphone>`_. :ref:`VoIPPhoneParameter` is the settings for our :ref:`VoIPPhone`. :ref:`VoIPCall` will be used to create our custom answering class. An :ref:`InvalidStateError<InvalidStateError>` is thrown when you try to perform an impossible command. For example, denying the call when the phone is already answered, answering when it's already answered, etc.

The following will create a phone that answers and automatically hangs up:

.. code-block:: python

from pyVoIP.credentials import CredentialsManager
from pyVoIP.VoIP.call import VoIPCall
from pyVoIP.VoIP.error import InvalidStateError
from pyVoIP.VoIP.phone import VoIPPhone, VoIPPhoneParamter
from pyVoIP.VoIP.phone import VoIPPhone, VoIPPhoneParameter

class Call(VoIPCall):

Expand All @@ -31,12 +31,12 @@ The following will create a phone that answers and automatically hangs up:
if __name__ == "__main__":
cm = CredentialsManager()
cm.add(<SIP server username>, <SIP server password>)
params = VoIPPhoneParamter(<SIP server IP>, <SIP server port>, <SIP server user>, cm, bind_ip=<Your computers local IP>, call_class=Call)
params = VoIPPhoneParameter(<SIP server IP>, <SIP server port>, <SIP server user>, cm, bind_ip=<Your computers local IP>, call_class=Call)
phone = VoIPPhone(params)
phone.start()
input('Press enter to disable the phone')
phone.stop()

Announcement Board
******************

Expand All @@ -47,24 +47,24 @@ Let's say you want to make a phone that when you call it, it plays an announceme
from pyVoIP.credentials import CredentialsManager
from pyVoIP.VoIP.call import VoIPCall
from pyVoIP.VoIP.error import InvalidStateError
from pyVoIP.VoIP.phone import VoIPPhone, VoIPPhoneParamter
from pyVoIP.VoIP.phone import VoIPPhone, VoIPPhoneParameter
import time
import wave

class Call(VoIPCall):

def ringing(self, invite_request):
try:
f = wave.open('announcment.wav', 'rb')
f = wave.open('announcement.wav', 'rb')
frames = f.getnframes()
data = f.readframes(frames)
f.close()

call.answer()
call.write_audio(data) # This writes the audio data to the transmit buffer, this must be bytes.

stop = time.time() + (frames / 8000) # frames/8000 is the length of the audio in seconds. 8000 is the hertz of PCMU.

while time.time() <= stop and call.state == CallState.ANSWERED:
time.sleep(0.1)
call.hangup()
Expand All @@ -76,7 +76,7 @@ Let's say you want to make a phone that when you call it, it plays an announceme
if __name__ == "__main__":
cm = CredentialsManager()
cm.add(<SIP server username>, <SIP server password>)
params = VoIPPhoneParamter(<SIP server IP>, <SIP server port>, <SIP server user>, cm, bind_ip=<Your computer's local IP>, call_class=Call)
params = VoIPPhoneParameter(<SIP server IP>, <SIP server port>, <SIP server user>, cm, bind_ip=<Your computer's local IP>, call_class=Call)
phone = VoIPPhone(params)
phone.start()
input('Press enter to disable the phone')
Expand All @@ -87,7 +87,7 @@ Something important to note is our wait function. We are currently using:
.. code-block:: python

stop = time.time() + (frames / 8000) # The number of frames/8000 is the length of the audio in seconds.

while time.time() <= stop and call.state == CallState.ANSWERED:
time.sleep(0.1)

Expand All @@ -105,10 +105,10 @@ We can use the following code to create `IVR Menus <https://en.wikipedia.org/wik
from pyVoIP.credentials import CredentialsManager
from pyVoIP.VoIP.call import VoIPCall
from pyVoIP.VoIP.error import InvalidStateError
from pyVoIP.VoIP.phone import VoIPPhone, VoIPPhoneParamter
from pyVoIP.VoIP.phone import VoIPPhone, VoIPPhoneParameter
import time
import wave

class Call(VoIPCall):

def ringing(self, invite_request):
Expand All @@ -117,10 +117,10 @@ We can use the following code to create `IVR Menus <https://en.wikipedia.org/wik
frames = f.getnframes()
data = f.readframes(frames)
f.close()

call.answer()
call.write_audio(data)

while call.state == CallState.ANSWERED:
dtmf = call.get_dtmf()
if dtmf == "1":
Expand All @@ -138,7 +138,7 @@ We can use the following code to create `IVR Menus <https://en.wikipedia.org/wik
if __name__ == '__main__':
cm = CredentialsManager()
cm.add(<SIP server username>, <SIP server password>)
params = VoIPPhoneParamter(<SIP server IP>, <SIP server port>, <SIP server user>, cm, bind_ip=<Your computer's local IP>, call_class=Call)
params = VoIPPhoneParameter(<SIP server IP>, <SIP server port>, <SIP server user>, cm, bind_ip=<Your computer's local IP>, call_class=Call)
phone = VoIPPhone(params)
phone.start()
input('Press enter to disable the phone')
Expand All @@ -156,7 +156,7 @@ We can use the following code to handle various states for calls:
from pyVoIP.credentials import CredentialsManager
from pyVoIP.VoIP.call import VoIPCall
from pyVoIP.VoIP.error import InvalidStateError
from pyVoIP.VoIP.phone import VoIPPhone, VoIPPhoneParamter
from pyVoIP.VoIP.phone import VoIPPhone, VoIPPhoneParameter
import time
import wave

Expand All @@ -181,7 +181,7 @@ We can use the following code to handle various states for calls:
if __name__ == '__main__':
cm = CredentialsManager()
cm.add(<SIP server username>, <SIP server password>)
params = VoIPPhoneParamter(<SIP server IP>, <SIP server port>, <SIP server user>, cm, bind_ip=<Your computer's local IP>, call_class=Call)
params = VoIPPhoneParameter(<SIP server IP>, <SIP server port>, <SIP server user>, cm, bind_ip=<Your computer's local IP>, call_class=Call)
phone = VoIPPhone(params)
phone.start()
phone.call(<Phone Number>)
Expand Down
20 changes: 10 additions & 10 deletions docs/Networking.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pyVoIP.networking.nat.\ **AddressType**
Used for determining remote or local tags in SIP messages.

AddressType.\ **REMOTE**

AddressType.\ **LOCAL**

.. _TransportMode:
Expand All @@ -30,21 +30,21 @@ pyVoIP.networking.transport.\ **TransportMode**

TransportMode.\ **value**
This is the string value of the TransportMode. For example, ``UDP`` or ``TLS``.

TransportMode.\ **socket_type**
This is the `SocketKind <https://docs.python.org/3/library/socket.html?highlight=socket#constants>`_ associated with the TransportMode.

TransportMode.\ **tls_mode**
This is either `PROTOCOL_TLS <https://docs.python.org/3/library/ssl.html?highlight=ssl#ssl.PROTOCOL_TLS>`_ when using TLS or None otherwise.

Here is a list of current supported transport modes:

TransportMode.\ **UDP**
"UDP", `SOCK_DGRAM <https://docs.python.org/3/library/socket.html#socket.SOCK_DGRAM>`_, None

TransportMode.\ **TCP**
"TCP", `SOCK_STREAM <https://docs.python.org/3/library/socket.html#socket.SOCK_STREAM>`_, None

TransportMode.\ **TLS**
"TLS", `SOCK_STREAM <https://docs.python.org/3/library/socket.html#socket.SOCK_STREAM>`_, `PROTOCOL_TLS <https://docs.python.org/3/library/ssl.html?highlight=ssl#ssl.PROTOCOL_TLS>`_

Expand All @@ -69,7 +69,7 @@ The NAT class is used automatically understand and translate IPs and hostnames f

**get_host**\ (host: str) -> str
This method return the hostname another :term:`client` needs to connect to us.

**check_host**\ (host: str) -> :ref:`AddressType<AddressType>`
This method determine if a host is a remote computer or not.

Expand Down Expand Up @@ -102,14 +102,14 @@ The VoIPSocket class is the phone's main SIP socket. It receives and processes a
VoIPConnection
==============

The VoIPConnecion class is a wrapper for Python's sockets. Since UDP, TCP, and TLS sockets all have different quarks in Python, this class consolidates everything into one interface. For UDP, VoIPConnection will pull messages from :ref:`VoIPSocket`'s database.
The VoIPConnection class is a wrapper for Python's sockets. Since UDP, TCP, and TLS sockets all have different quarks in Python, this class consolidates everything into one interface. For UDP, VoIPConnection will pull messages from :ref:`VoIPSocket`'s database.

*class* pyVoIP.networking.sock.\ **VoIPConnection**\ (voip_sock: :ref:`VoIPSocket`, conn: Optional[:ref:`SOCKETS<SOCKETS>`, message: :ref:`SIPMessage`)
The *voiop_socket* argument is a :ref:`VoIPSocket` instance reference.
The *voip_socket* argument is a :ref:`VoIPSocket` instance reference.

The *conn* argument is the underlying Python socket.

The *message* argument is the :ref:`SIPMessage` used to initate the dialog.
The *message* argument is the :ref:`SIPMessage` used to initiate the dialog.

**send**\ (data: Union[bytes, str]) -> None
Sends *data* to the :term:`client`. If *data* is a string, it will be UTF8 encoded first.
Expand Down
Loading