Beispiel #1
0
def test_remote_ip_error():
    p = mock.patch('dnsimple_dyndns.external_ip.requests')
    with p as m:
        m.get.return_value = mock.Mock(content='127.0.0.1', ok=False)
        from dnsimple_dyndns.external_ip import get_external_ip
        with pytest.raises(RuntimeError):
            get_external_ip()
Beispiel #2
0
def main():
    parser = argparse.ArgumentParser(description='Dynamic DNS implementation, '
                                     'that relies on DNSimple.com.',
                                     version=__version__)
    parser.add_argument('-t',
                        '--ttl',
                        type=int,
                        default=60,
                        help='DNS record TTL, defaults to 60')
    parser.add_argument('-i',
                        '--ip',
                        help='IP address, defaults to current '
                        'external address from http://icanhazip.com/')
    parser.add_argument('domain',
                        metavar='DOMAIN',
                        help='domain controlled by DNSimple.com')
    parser.add_argument('domain_token',
                        metavar='DOMAIN-TOKEN',
                        help='DNSimple.com domain API key.')
    parser.add_argument('record_name',
                        metavar='RECORD-NAME',
                        help='name of the record to be updated.')

    args = parser.parse_args()
    dns = DNSimple(args.domain, args.domain_token)
    record = dns.update_record(args.record_name, args.ip or get_external_ip(),
                               args.ttl)
    print record['content']
    return 0
Beispiel #3
0
def test_remote_ip():
    p = mock.patch('dnsimple_dyndns.external_ip.requests')
    with p as m:
        m.get.return_value = mock.Mock(content='127.0.0.1', ok=True)
        from dnsimple_dyndns.external_ip import get_external_ip
        ip = get_external_ip()
        assert ip == '127.0.0.1'
        m.get.assert_called_once_with('http://icanhazip.com/')
Beispiel #4
0
def main():
    parser = argparse.ArgumentParser(description='Dynamic DNS implementation, '
                                     'that relies on DNSimple.com.',
                                     version=__version__)
    parser.add_argument('-t', '--ttl', type=int, default=60,
                        help='DNS record TTL, defaults to 60')
    parser.add_argument('-i', '--ip', help='IP address, defaults to current '
                        'external address from http://icanhazip.com/')
    parser.add_argument('domain', metavar='DOMAIN',
                        help='domain controlled by DNSimple.com')
    parser.add_argument('domain_token', metavar='DOMAIN-TOKEN',
                        help='DNSimple.com domain API key.')
    parser.add_argument('record_name', metavar='RECORD-NAME',
                        help='name of the record to be updated.')

    args = parser.parse_args()
    dns = DNSimple(args.domain, args.domain_token)
    record = dns.update_record(args.record_name, args.ip or get_external_ip(),
                               args.ttl)
    print record['content']
    return 0