mirror of
https://github.com/shmilylty/OneForAll.git
synced 2026-08-26 04:47:48 +08:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -23,35 +23,38 @@ class CloudFlareAPI(Query):
|
|||||||
query from source
|
query from source
|
||||||
"""
|
"""
|
||||||
account_id_resp = self.get(self.addr + 'accounts')
|
account_id_resp = self.get(self.addr + 'accounts')
|
||||||
if account_id_resp.status_code != 200:
|
if account_id_resp:
|
||||||
|
if account_id_resp.status_code != 200:
|
||||||
|
return
|
||||||
|
else:
|
||||||
return
|
return
|
||||||
account_id = account_id_resp.json()['result'][0]['id']
|
account_id = account_id_resp.json()['result'][0]['id']
|
||||||
# query domain zone, if it not exist, create
|
# query domain zone, if it not exist, create
|
||||||
zones_resp = self.get(self.addr + 'zones',
|
zones_resp = self.get(self.addr + 'zones',
|
||||||
params={'name': self.domain}, check=False)
|
params={'name': self.domain}, check=False)
|
||||||
|
if zones_resp:
|
||||||
if zones_resp.status_code == 200:
|
if zones_resp.status_code == 200:
|
||||||
if zones_resp.json()['success'] and not zones_resp.json()['result']:
|
if zones_resp.json()['success'] and not zones_resp.json()['result']:
|
||||||
zone_id = self.create_zone(account_id)
|
zone_id = self.create_zone(account_id)
|
||||||
if zone_id:
|
if zone_id:
|
||||||
self.list_dns(zone_id)
|
self.list_dns(zone_id)
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
elif zones_resp.json()['success']:
|
||||||
|
zone_id = zones_resp.json()['result'][0]['id']
|
||||||
|
delete_zone_resp = self.delete(self.addr + f'zones/{zone_id}', check=False)
|
||||||
|
zone_id = self.create_zone(account_id)
|
||||||
|
if zone_id:
|
||||||
|
self.list_dns(zone_id)
|
||||||
return
|
return
|
||||||
else:
|
elif zones_resp.status_code == 403:
|
||||||
return
|
logger.log('DEBUG',
|
||||||
elif zones_resp.json()['success']:
|
f'{self.domain} is banned or not a registered domain, so cannot be added to Cloudflare.')
|
||||||
zone_id = zones_resp.json()['result'][0]['id']
|
|
||||||
delete_zone_resp = self.delete(self.addr + f'zones/{zone_id}', check=False)
|
|
||||||
zone_id = self.create_zone(account_id)
|
|
||||||
if zone_id:
|
|
||||||
self.list_dns(zone_id)
|
|
||||||
return
|
return
|
||||||
elif zones_resp.status_code == 403:
|
else:
|
||||||
logger.log('DEBUG',
|
logger.log('DEBUG',
|
||||||
f'{self.domain} is banned or not a registered domain, so cannot be added to Cloudflare.')
|
f'{zones_resp.status_code} {zones_resp.text}')
|
||||||
return
|
|
||||||
else:
|
|
||||||
logger.log('DEBUG',
|
|
||||||
f'{zones_resp.status_code} {zones_resp.text}')
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def create_zone(self, account_id):
|
def create_zone(self, account_id):
|
||||||
|
|||||||
Reference in New Issue
Block a user