Ejemplo n.º 1
0
def _url_ip_address(url):
    # type: (str) -> ipaddress._IPAddressBase
    try:
        return ip_address(text_type(url))
    except ValueError:
        host = urlparse(url).hostname
        return ip_address(text_type(socket.gethostbyname(host)))
Ejemplo n.º 2
0
 def validate_port(recipient_url):
     # type: (str) -> None
     port = urlparse(recipient_url).port
     if port and int(port) not in allowed:
         raise SecurityError(
             'Port of recipient URL {0} not allowed ({1} only)'.format(
                 recipient_url, allowed))
Ejemplo n.º 3
0
def _url_ip_address(url):
    # type: (str) -> ipaddress._IPAddressBase
    try:
        return ip_address(text_type(url))
    except ValueError:
        host = urlparse(url).hostname
        return ip_address(text_type(socket.gethostbyname(host)))
Ejemplo n.º 4
0
 def validate_port(recipient_url):
     # type: (str) -> None
     port = urlparse(recipient_url).port
     if port and int(port) not in allowed:
         raise SecurityError(
             'Port of recipient URL {0} not allowed ({1} only)'.format(
                 recipient_url, allowed))
Ejemplo n.º 5
0
    def _ensure_mongodb_uri_compliance(url):
        parsed_url = urlparse(url)
        if not parsed_url.scheme.startswith('mongodb'):
            url = 'mongodb+{}'.format(url)

        if url == 'mongodb://':
            url += 'localhost'

        return url
Ejemplo n.º 6
0
    def _ensure_mongodb_uri_compliance(url):
        parsed_url = urlparse(url)
        if not parsed_url.scheme.startswith("mongodb"):
            url = "mongodb+{}".format(url)

        if url == "mongodb://":
            url += "localhost"

        return url
Ejemplo n.º 7
0
    def _ensure_mongodb_uri_compliance(url):
        parsed_url = urlparse(url)
        if not parsed_url.scheme.startswith('mongodb'):
            url = 'mongodb+{}'.format(url)

        if url == 'mongodb://':
            url += 'localhost'

        return url
Ejemplo n.º 8
0
def _url_ip_address(url):
    try:
        return ip_address(text_type(url))
    except ValueError:
        host = urlparse(url).hostname
        return ip_address(text_type(socket.gethostbyname(host)))