Use enable/disable option like explained in docs
This commit is contained in:
parent
403bd89ca2
commit
c512919fac
2 changed files with 8 additions and 5 deletions
|
|
@ -6,6 +6,6 @@ from ip_listener.main import detect
|
|||
@click.command()
|
||||
@click.argument("domains", envvar="DOMAIN", nargs=-1)
|
||||
@click.argument("token", envvar="TOKEN")
|
||||
@click.option("--read-only", envvar="READ_ONLY", default=False)
|
||||
def run(domains, token):
|
||||
detect(domains, token)
|
||||
@click.option("--read-only/--write", envvar="READ_ONLY", default=False)
|
||||
def run(domains, token, read_only):
|
||||
detect(domains, token, read_only)
|
||||
|
|
|
|||
|
|
@ -51,7 +51,10 @@ def _update_domain(domain, payload, token):
|
|||
return requests.put(url, data=json.dumps(payload), headers=headers)
|
||||
|
||||
|
||||
def _update_domains(updated_domains, token):
|
||||
def _update_domains(updated_domains, token, read_only):
|
||||
if read_only:
|
||||
return
|
||||
|
||||
with ThreadPoolExecutor(max_workers=10) as executor:
|
||||
futures = {
|
||||
executor.submit(_update_domain, domain, entries, token): domain
|
||||
|
|
@ -71,7 +74,7 @@ def _update_domains(updated_domains, token):
|
|||
logger.info(f"Updated domain {domain}")
|
||||
|
||||
|
||||
def detect(domains, token):
|
||||
def detect(domains, token, read_only):
|
||||
ip = _get_ip()
|
||||
domain_data = _get_domain_data(domains, token)
|
||||
updated_domains = {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue