Skip to content

Commit

Permalink
Merge branch 'development' into docs/Issue-204
Browse files Browse the repository at this point in the history
  • Loading branch information
tayler6000 committed Jan 11, 2024
2 parents 6cf1734 + 5f03d54 commit 6785320
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 30 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflow will install Python dependencies, run tests and lint
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Check Black

on:
Expand All @@ -16,7 +13,7 @@ jobs:
strategy:
matrix:
python-version:
- "3.8"
- "3.12"

steps:
- uses: actions/[email protected]
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflow will install Python dependencies, run tests and lint
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Check flake8

on:
Expand All @@ -16,7 +13,7 @@ jobs:
strategy:
matrix:
python-version:
- "3.8"
- "3.12"

steps:
- uses: actions/[email protected]
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# This workflow will install Python dependencies, run tests and lint
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Check pytest
name: Run pytest

on:
push:
Expand All @@ -11,12 +8,11 @@ on:
pull_request:

jobs:
check-pytest:
run-pytest:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.8"
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
author = "Tayler J Porter"

# The full version, including alpha/beta/rc tags
release = "2.0.0a1"
release = "2.0.0a3"

master_doc = "index"

Expand Down
4 changes: 0 additions & 4 deletions pyVoIP/SIP/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
from pyVoIP.SIP import error
from pyVoIP.SIP import client
from pyVoIP.SIP import message

__all__ = [
"error",
"client",
Expand Down
7 changes: 1 addition & 6 deletions pyVoIP/VoIP/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
from pyVoIP.VoIP import call, phone, status

CallState = call.CallState
VoIPCall = call.VoIPCall
PhoneStatus = status.PhoneStatus
VoIPPhone = phone.VoIPPhone
__all__ = ["call", "phone", "status"]
4 changes: 2 additions & 2 deletions pyVoIP/VoIP/phone.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pyVoIP import RTP
from pyVoIP.credentials import CredentialsManager
from pyVoIP.SIP.client import SIPClient
from pyVoIP.SIP.message import SIPMessage, SIPStatus
from pyVoIP.SIP.message import SIPMessage, SIPMessageType, SIPStatus
from pyVoIP.sock.sock import VoIPConnection
from pyVoIP.sock.transport import TransportMode
from pyVoIP.types import KEY_PASSWORD
Expand Down Expand Up @@ -105,7 +105,7 @@ def callback(
self, conn: VoIPConnection, request: SIPMessage
) -> Optional[str]:
# debug("Callback: "+request.summary())
if request.type == pyVoIP.SIPMessageType.REQUEST:
if request.type == SIPMessageType.REQUEST:
# debug("This is a message")
if request.method == "INVITE":
self._callback_MSG_Invite(conn, request)
Expand Down
2 changes: 1 addition & 1 deletion pyVoIP/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__all__ = ["SIP", "RTP", "VoIP"]

version_info = (2, 0, "0a1")
version_info = (2, 0, "0a3")

__version__ = ".".join([str(x) for x in version_info])

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name="pyVoIP",
version="2.0.0a1",
version="2.0.0a3",
description="PyVoIP is a pure python VoIP/SIP/RTP library.",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
139 changes: 139 additions & 0 deletions tests/test_nat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
from pyVoIP.networking.nat import NAT, NATError
import pytest


@pytest.mark.parametrize(
"nat_settings,test_against,expected",
[
# Test Remote Host
(
{
"bind_ip": "10.0.0.4",
"network": "10.0.0.0/24",
"remote_hostname": "example.com",
},
"8.8.8.8",
"example.com",
),
(
{
"bind_ip": "10.0.0.4",
"network": "10.0.0.0/24",
"remote_hostname": "example.com",
},
"example.org",
"example.com",
),
(
{
"bind_ip": "10.0.0.4",
"network": "10.0.0.0/24",
"remote_hostname": "example.com",
},
"10.0.1.1",
"example.com",
),
(
{
"bind_ip": "10.0.0.4",
"network": "10.0.0.0/16",
"remote_hostname": "example.com",
},
"10.1.0.1",
"example.com",
),
# Test Remote Host with Bind 0.0.0.0
(
{
"bind_ip": "0.0.0.0",
"network": "10.0.0.0/24",
"hostname": "10.0.0.4",
"remote_hostname": "example.com",
},
"8.8.8.8",
"example.com",
),
(
{
"bind_ip": "0.0.0.0",
"network": "10.0.0.0/24",
"hostname": "10.0.0.4",
"remote_hostname": "example.com",
},
"10.0.1.1",
"example.com",
),
(
{
"bind_ip": "0.0.0.0",
"network": "10.0.0.0/16",
"hostname": "10.0.0.4",
"remote_hostname": "example.com",
},
"10.1.0.1",
"example.com",
),
# Test Local Host
(
{
"bind_ip": "10.0.0.4",
"network": "10.0.0.0/24",
},
"10.0.0.10",
"10.0.0.4",
),
(
{
"bind_ip": "10.0.0.4",
"network": "10.0.0.0/16",
},
"10.0.1.1",
"10.0.0.4",
),
(
{
"bind_ip": "10.0.0.4",
"network": "10.0.0.0/8",
},
"10.1.1.1",
"10.0.0.4",
),
# Test Local Host with Bind 0.0.0.0
(
{
"bind_ip": "0.0.0.0",
"network": "10.0.0.0/24",
"hostname": "10.0.0.4",
},
"10.0.0.10",
"10.0.0.4",
),
(
{
"bind_ip": "0.0.0.0",
"network": "10.0.0.0/16",
"hostname": "10.0.0.4",
},
"10.0.1.1",
"10.0.0.4",
),
(
{
"bind_ip": "0.0.0.0",
"network": "10.0.0.0/8",
"hostname": "10.0.0.4",
},
"10.1.1.10",
"10.0.0.4",
),
],
)
def test_nat(nat_settings, test_against, expected):
nat = NAT(**nat_settings)
assert nat.get_host(test_against) == expected


def test_nat_error():
nat = NAT("192.168.0.5", "192.168.0.0/24")
with pytest.raises(NATError):
nat.get_host("google.com")

0 comments on commit 6785320

Please sign in to comment.