diff --git a/nyacme/hook.py b/nyacme/hook.py index a0c1c93..b200f87 100644 --- a/nyacme/hook.py +++ b/nyacme/hook.py @@ -19,19 +19,21 @@ handlers = { 'http': HTTPHandler, } +class Args: + def __init__(self, argv): + # one of 'begin', 'done', 'failed' + self.method = argv[1] + # challenge type (dns-01, http-01 or tls-alpn-01) + self.type = argv[2] + # the identifier the challenge refers to (domain name) + self.domain = argv[3] + # the challenge token + self.token = argv[4] + # the key authorization (DNS record contents, etc.) + self.auth = argv[5] def main() -> None: - parser = argparse.ArgumentParser( - prog='nyacme-hook', - description='nyacme hook (not meant to be ran manually)' - ) - parser.add_argument('method', help='one of begin, done or failed') - parser.add_argument('type', help='challenge type (dns-01, http-01 or tls-alpn-01)') - parser.add_argument('domain', help='the identifier the challenge refers to (domain name)') - parser.add_argument('token', help='the challenge token') - parser.add_argument('auth', help='the key authorization (DNS record contents, etc.)') - args = parser.parse_args() - + args = Args(sys.argv) config = read_config(None) record_name = f'_acme-challenge.{args.domain}'