Пример #1
0
def parse(stamp):
    parameter = Parameter()

    state = create_state_for_stamp(stamp)
    parameter.protocol = consume_protocol(state)

    if parameter.protocol == Protocol.PLAIN:
        parse_plain(state, parameter)
    elif parameter.protocol == Protocol.DNSCRYPT:
        parse_dnscrypt(state, parameter)
    elif parameter.protocol == Protocol.DOH:
        parse_doh(state, parameter)
    elif parameter.protocol == Protocol.DOT:
        parse_dot(state, parameter)

    return parameter
Пример #2
0
def prepare_dot(address, hashes, hostname, options=None, bootstrap_ips=None):
    parameter = Parameter()
    parameter.protocol = Protocol.DOT

    if options is None:
        parameter.options = []
    else:
        parameter.options = options

    parameter.address = address
    parameter.hashes = hashes
    parameter.hostname = hostname

    if bootstrap_ips is None:
        parameter.bootstrap_ips = []
    else:
        parameter.bootstrap_ips = bootstrap_ips

    return parameter
Пример #3
0
def prepare_dnscrypt(address, public_key, provider_name, options=None):
    parameter = Parameter()
    parameter.protocol = Protocol.DNSCRYPT

    if options is None:
        parameter.options = []
    else:
        parameter.options = options

    parameter.address = address
    parameter.public_key = public_key
    parameter.provider_name = provider_name
    return parameter
Пример #4
0
def prepare_doh_target(hostname, path, options=None):
    parameter = Parameter()
    parameter.protocol = Protocol.DOH_TARGET

    if options is None:
        parameter.options = []
    else:
        parameter.options = options

    parameter.hostname = hostname
    parameter.path = path
    return parameter
Пример #5
0
def parse(stamp):
    parameter = Parameter()

    state = create_state_for_stamp(stamp)
    parameter.protocol = consume_protocol(state)

    if parameter.protocol == Protocol.PLAIN:
        parse_plain(state, parameter)
    elif parameter.protocol == Protocol.DNSCRYPT:
        parse_dnscrypt(state, parameter)
    elif parameter.protocol == Protocol.DOH:
        parse_doh(state, parameter)
    elif parameter.protocol == Protocol.DOT:
        parse_dot(state, parameter)
    elif parameter.protocol == Protocol.DOQ:
        parse_doq(state, parameter)
    elif parameter.protocol == Protocol.DOH_TARGET:
        parse_doh_target(state, parameter)
    elif parameter.protocol == Protocol.DNSCRYPT_RELAY:
        parse_dnscrypt_relay(state, parameter)
    elif parameter.protocol == Protocol.DOH_RELAY:
        parse_doh_relay(state, parameter)

    return parameter
Пример #6
0
def prepare_plain(address, options=None):
    parameter = Parameter()
    parameter.protocol = Protocol.PLAIN

    if options is None:
        parameter.options = []
    else:
        parameter.options = options

    parameter.address = address
    return parameter
Пример #7
0
 def test_build_with_empty_parameters(self):
     self.assertEqual("sdns://AAAAAAAAAAAACTEyNy4wLjAuMQ",
                      dnsstamps.build(Parameter()), "Invalid stamp")
Пример #8
0
def prepare_doh_relay(address,
                      hashes,
                      hostname,
                      path,
                      options=None,
                      bootstrap_ips=None):
    parameter = Parameter()
    parameter.protocol = Protocol.DOH_RELAY

    if options is None:
        parameter.options = []
    else:
        parameter.options = options

    parameter.address = address
    parameter.hashes = hashes
    parameter.hostname = hostname
    parameter.path = path

    if bootstrap_ips is None:
        parameter.bootstrap_ips = []
    else:
        parameter.bootstrap_ips = bootstrap_ips

    return parameter
Пример #9
0
def prepare_dnscrypt_relay(address):
    parameter = Parameter()
    parameter.protocol = Protocol.DNSCRYPT_RELAY
    parameter.address = address
    return parameter