Skip to content

Commit

Permalink
max ip bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ImanMontajabi committed Apr 2, 2023
1 parent 784d6d0 commit 71667a0
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions CloudflareDNS.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,7 @@ def export_list(self):
self.finished.emit()
self.finished.emit()
# ===================================================================================
def create(self):
with open('user_id.json', 'r') as json_file:
user_data = json.load(json_file)
email = user_data['email']
api_token = user_data['api_token']
zone_id = user_data['zone_id']
record_name = user_data["ip_dns_record"]
domain = user_data["domain"]
lenscan = int(user_data["max_ip"])
def create(self):
def scan_to_iplist():
with open(self.json_path_create, 'r') as f:
data = json.load(f)
Expand Down Expand Up @@ -154,12 +146,13 @@ def ip_list():
return myip

all_ips = ip_list()
len_all_ips = len(all_ips)
def bestip():
filename = "best_ip.txt"
topUnder100ip = []

ipn = 0
while(ipn < lenscan):
while(ipn < len_all_ips):
topUnder100ip.append(all_ips[ipn])
ipn += 1
if ipn >= max_ips:
Expand All @@ -173,6 +166,21 @@ def bestip():
lines = ip.readlines()
topUnder100ipList = [line.strip() for line in lines]


with open('user_id.json', 'r') as json_file:
user_data = json.load(json_file)
email = user_data['email']
api_token = user_data['api_token']
zone_id = user_data['zone_id']
record_name = user_data["ip_dns_record"]
domain = user_data["domain"]
try:
max_ip_user = int(user_data["max_ip"])
except:
max_ip_user = len(topUnder100ipList)



params_name = f'{record_name}.{domain}'
url = f"https://api.cloudflare.com/client/v4/zones/{zone_id}/dns_records"
headers = {
Expand All @@ -182,14 +190,22 @@ def bestip():
}
ipn = 0

while(ipn < lenscan):






while(ipn < len(topUnder100ipList)):
data = {
"type": "A",
"name": params_name,
"content": f"{topUnder100ipList[ipn]}",
"ttl": 1,
"proxied": False
}
if (ipn >= max_ip_user):
break
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
subdomain = response.json()["result"]["name"]
Expand Down

0 comments on commit 71667a0

Please sign in to comment.