-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] Added container and volume remove to the Docker start script.
[ADD] Added basic Network Address Translation (NAT) feature. [ADD] Added __gen_via in SIP.client. [ADD] Added __gen_contact in SIP.client. [ADD] Added some IPv6 handling. [CHANGE] Changed Docker start script to PowerShell. [FIX] Fixed not receiving replies due to network routing. [FIX] Fixed registration tests failing due to max contacts. [FIX] Fixed uri's not denoting sips when using TLS [FIX] Fixed Via headers from other hosts being incorrectly changed. [FIX] Fixed timeout errors being raised incorrectly. [FIX] Fixed deregister_connection for TCP and TLS sockets. [FIX] Fixed all registration tests.
- Loading branch information
1 parent
322757b
commit f4b6d27
Showing
10 changed files
with
170 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
docker stop $(docker ps -a -q) | ||
docker rm --force --volumes $(docker ps -a -q) | ||
docker rmi pyvoip/tests | ||
docker build . -t pyvoip/tests | ||
docker run --add-host host.docker.internal:host-gateway -d -p 5060:5060/udp -p 5061-5062:5061-5062/tcp pyvoip/tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from typing import Optional | ||
import ipaddress | ||
import socket | ||
|
||
|
||
class NATError(Exception): | ||
pass | ||
|
||
|
||
class NAT: | ||
def __init__( | ||
self, | ||
bind_ip: str, | ||
network: str, | ||
hostname: Optional[str] = None, | ||
remote_hostname: Optional[str] = None, | ||
): | ||
self.bind_ip = ipaddress.ip_address(bind_ip) | ||
self.network = ipaddress.ip_network(network) | ||
self.hostname = bind_ip if hostname is None else hostname | ||
self.remote_hostname = remote_hostname | ||
|
||
def get_host(self, host: str): | ||
"""Return the hostname another client needs to connect to us.""" | ||
try: | ||
ip = ipaddress.ip_address(host) | ||
except ValueError: | ||
try: | ||
ip = socket.gethostbyname(host) | ||
except socket.gaierror: | ||
raise NATError(f"Unable to resolve hostname {host}") | ||
|
||
if ip in self.network: | ||
return self.hostname | ||
else: | ||
if self.remote_hostname is not None: | ||
return self.remote_hostname | ||
raise NATError( | ||
"No remote hostname specified, " | ||
+ "cannot provide a return path for remote hosts." | ||
) |
Oops, something went wrong.