From 4530a484db324d0417ecca1e851161546110c7a2 Mon Sep 17 00:00:00 2001 From: TJ Porter Date: Mon, 8 Jan 2024 17:59:34 -0600 Subject: [PATCH 1/6] [FIX] Fixed incorrect imports --- pyVoIP/SIP/__init__.py | 4 ---- pyVoIP/VoIP/phone.py | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/pyVoIP/SIP/__init__.py b/pyVoIP/SIP/__init__.py index a039aa5..a1bcd7e 100644 --- a/pyVoIP/SIP/__init__.py +++ b/pyVoIP/SIP/__init__.py @@ -1,7 +1,3 @@ -from pyVoIP.SIP import error -from pyVoIP.SIP import client -from pyVoIP.SIP import message - __all__ = [ "error", "client", diff --git a/pyVoIP/VoIP/phone.py b/pyVoIP/VoIP/phone.py index fa23ddd..9526736 100644 --- a/pyVoIP/VoIP/phone.py +++ b/pyVoIP/VoIP/phone.py @@ -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 @@ -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) From 3d29ca1d6b4e4168c9db50e7be712b96dd10fd13 Mon Sep 17 00:00:00 2001 From: TJ Porter Date: Mon, 8 Jan 2024 18:08:57 -0600 Subject: [PATCH 2/6] Release pyVoIP v2.0.0a2 --- docs/conf.py | 2 +- pyVoIP/__init__.py | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 07b45d7..b1538ad 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -24,7 +24,7 @@ author = "Tayler J Porter" # The full version, including alpha/beta/rc tags -release = "2.0.0a1" +release = "2.0.0a2" master_doc = "index" diff --git a/pyVoIP/__init__.py b/pyVoIP/__init__.py index ff6720d..cc4d3e8 100644 --- a/pyVoIP/__init__.py +++ b/pyVoIP/__init__.py @@ -2,7 +2,7 @@ __all__ = ["SIP", "RTP", "VoIP"] -version_info = (2, 0, "0a1") +version_info = (2, 0, "0a2") __version__ = ".".join([str(x) for x in version_info]) diff --git a/setup.py b/setup.py index 02fd0ee..04e57d8 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name="pyVoIP", - version="2.0.0a1", + version="2.0.0a2", description="PyVoIP is a pure python VoIP/SIP/RTP library.", long_description=long_description, long_description_content_type="text/markdown", From dace4db2a2ed2bde82bb130e2675142c3776b113 Mon Sep 17 00:00:00 2001 From: TJ Porter Date: Tue, 9 Jan 2024 14:54:10 -0600 Subject: [PATCH 3/6] Release pyVoIP v2.0.0a3 [FIX] Fixed more circular imports --- docs/conf.py | 2 +- pyVoIP/VoIP/__init__.py | 7 +------ pyVoIP/__init__.py | 2 +- setup.py | 2 +- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index b1538ad..3278840 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -24,7 +24,7 @@ author = "Tayler J Porter" # The full version, including alpha/beta/rc tags -release = "2.0.0a2" +release = "2.0.0a3" master_doc = "index" diff --git a/pyVoIP/VoIP/__init__.py b/pyVoIP/VoIP/__init__.py index 8149dde..736e626 100644 --- a/pyVoIP/VoIP/__init__.py +++ b/pyVoIP/VoIP/__init__.py @@ -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"] diff --git a/pyVoIP/__init__.py b/pyVoIP/__init__.py index cc4d3e8..6ceacf2 100644 --- a/pyVoIP/__init__.py +++ b/pyVoIP/__init__.py @@ -2,7 +2,7 @@ __all__ = ["SIP", "RTP", "VoIP"] -version_info = (2, 0, "0a2") +version_info = (2, 0, "0a3") __version__ = ".".join([str(x) for x in version_info]) diff --git a/setup.py b/setup.py index 04e57d8..f8f77d3 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name="pyVoIP", - version="2.0.0a2", + version="2.0.0a3", description="PyVoIP is a pure python VoIP/SIP/RTP library.", long_description=long_description, long_description_content_type="text/markdown", From 1144f1caf32b908bb1dd918596ee1fa6888fe675 Mon Sep 17 00:00:00 2001 From: TJ Porter Date: Wed, 10 Jan 2024 20:16:38 -0600 Subject: [PATCH 4/6] [ADD] Added tests for NAT --- tests/test_nat.py | 142 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 tests/test_nat.py diff --git a/tests/test_nat.py b/tests/test_nat.py new file mode 100644 index 0000000..0aa2731 --- /dev/null +++ b/tests/test_nat.py @@ -0,0 +1,142 @@ +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") From 8ad9d5ea50a85306d12724bb41508fe4e268c9f6 Mon Sep 17 00:00:00 2001 From: TJ Porter Date: Wed, 10 Jan 2024 20:21:18 -0600 Subject: [PATCH 5/6] [FIX] Fixed formatting issue. --- tests/test_nat.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/test_nat.py b/tests/test_nat.py index 0aa2731..3b3385c 100644 --- a/tests/test_nat.py +++ b/tests/test_nat.py @@ -42,7 +42,6 @@ "10.1.0.1", "example.com", ), - # Test Remote Host with Bind 0.0.0.0 ( { @@ -74,7 +73,6 @@ "10.1.0.1", "example.com", ), - # Test Local Host ( { @@ -100,7 +98,6 @@ "10.1.1.1", "10.0.0.4", ), - # Test Local Host with Bind 0.0.0.0 ( { From 286c24c689b8afccfd9360c75b6cf7da7c0853bc Mon Sep 17 00:00:00 2001 From: TJ Porter Date: Thu, 11 Jan 2024 08:39:24 -0600 Subject: [PATCH 6/6] [CHANGE] Changed pytest workflow to use all Python versions between 3.8 - 3.12 [CHANGE] Changed flake8 and black jobs to use Python version 3.12 --- .github/workflows/black.yml | 5 +---- .github/workflows/flake8.yml | 5 +---- .github/workflows/pytest.yml | 10 +++------- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml index 975c115..c6321c5 100644 --- a/.github/workflows/black.yml +++ b/.github/workflows/black.yml @@ -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: @@ -16,7 +13,7 @@ jobs: strategy: matrix: python-version: - - "3.8" + - "3.12" steps: - uses: actions/checkout@v3.5.2 diff --git a/.github/workflows/flake8.yml b/.github/workflows/flake8.yml index c4567dc..a8557b7 100644 --- a/.github/workflows/flake8.yml +++ b/.github/workflows/flake8.yml @@ -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: @@ -16,7 +13,7 @@ jobs: strategy: matrix: python-version: - - "3.8" + - "3.12" steps: - uses: actions/checkout@v3.5.2 diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 97c2125..2c9e352 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -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: @@ -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/checkout@v3.5.2