Commit bf095068 authored by Hugo Hörnquist's avatar Hugo Hörnquist
Browse files

Merge branch 'master' into WIPdb

parents ed9a4f00 c33ce0cc
#!/usr/bin/env python2
import nis
username = "hugo"
uname, password, uid, gid, full_name, home, shell ="passwd.byname").get(username).split(":")
# get uid from cas.username
# check that agains the DB
print uid, uname
......@@ -2,6 +2,7 @@
import socket
import socketserver
import argparse
import ssl
import ip_query_pb2
......@@ -21,6 +22,8 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser(description='LysNS IP update server.')
parser.add_argument('host', type=str, help='The listening address of the server.')
parser.add_argument('port', type=int, help='The listening port of the server.')
parser.add_argument('cert', type=str, help='The SSL certificate of the server.')
parser.add_argument('key', type=str, help='The private key for the SSL certificate.')
parser.add_argument('--ipv6', action='store_true', help='The given listening address is IPv6.')
args = parser.parse_args()
......@@ -31,4 +34,9 @@ if __name__ == '__main__':
server = ForkingServer((, args.port), RequestHandler, family)
server.socket = ssl.wrap_socket(server.socket,
server_side = True,
certfile = args.cert,
keyfile = args.key)
#!/usr/bin/env python3
import socket
import argparse
import os
import socket
import ssl
import ip_query_pb2
def request_address(address, port):
def request_address(address, port, cert):
This function obtains the external ip address of the current machine.
msg = ip_query_pb2.Query()
connection = socket.create_connection((address, port,))
connection = ssl.wrap_socket(socket.create_connection((address, port,)),
cert_reqs=ssl.CERT_REQUIRED, ca_certs=cert)
buf = connection.recv(MAX_MSG_LEN)
......@@ -18,13 +24,27 @@ def request_address(address, port):
return answer.address
def nsupdate(domain_server, domain, ip):
res = os.system('''nsupdate -k key.key -p 2223 <<EOF
server {}
update delete {}
update add {} 600 A {}
send'''.format(domain_server, domain, domain, ip))
if res != 0:
print('Got an error when updating the domain!')
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='LysNS IP update client.')
parser.add_argument('server', type=str, help='Server address.')
parser.add_argument('port', type=int, help='Server port.')
parser.add_argument('--ipv6', action='store_true', help='Perform an IPv4 update.')
parser.add_argument('cert', type=str, help='Public certificate for the server.')
parser.add_argument('domain_server', type=str, help='The address of the DNS server you wish to update.')
parser.add_argument('domain', type=str, help='The domain record you wish to update.')
parser.add_argument('--ipv6', action='store_true', help='Perform an IPv6 update.')
args = parser.parse_args()
address = request_address(args.server, args.port)
address = request_address(args.server, args.port, args.cert)
print('Got {} from the server.'.format(address))
nsupdate(args.domain_server, args.domain, address)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment