Fix: sequential execution, consistent _ul naming
This commit is contained in:
@@ -128,31 +128,40 @@ def update_mangle_and_queue():
|
|||||||
q_up_ori = f"pcq_ul_{full}m"
|
q_up_ori = f"pcq_ul_{full}m"
|
||||||
|
|
||||||
# 3. SET QUEUE INTERNASIONAL (Yg Lama) PAKE PCQ SETENGAH
|
# 3. SET QUEUE INTERNASIONAL (Yg Lama) PAKE PCQ SETENGAH
|
||||||
|
# Deteksi nama asli Queue Upload Int di MikroTik Anda (dari dump 178-queue-tree)
|
||||||
|
# Sebagian besar bernama star_X_ul, bukan _up
|
||||||
|
q_up_ori_name = f"{name}_ul"
|
||||||
|
|
||||||
commands.append(f"/queue/tree/set [find name=\"{name}_dl\"] queue={pcq_dl_half} packet-mark={dl_int}")
|
commands.append(f"/queue/tree/set [find name=\"{name}_dl\"] queue={pcq_dl_half} packet-mark={dl_int}")
|
||||||
commands.append(f"/queue/tree/set [find name=\"{name}_ul\"] packet-mark={up_int} queue={pcq_up_half}")
|
commands.append(f"/queue/tree/set [find name=\"{q_up_ori_name}\"] packet-mark={up_int} queue={pcq_up_half}")
|
||||||
# Tambahan apabila ada nama tree lama yg typo dengan "up" maka ikut diubah
|
|
||||||
|
# Tambahan backup apabila ada nama tree lama yg typo dengan "up"
|
||||||
commands.append(f"/queue/tree/set [find name=\"{name}_up\"] name=\"{name}_ul\" packet-mark={up_int} queue={pcq_up_half}")
|
commands.append(f"/queue/tree/set [find name=\"{name}_up\"] name=\"{name}_ul\" packet-mark={up_int} queue={pcq_up_half}")
|
||||||
|
|
||||||
# 4. BIKIN CHILD QUEUE LOKAL YANG BARU (Gunakan rate FULL / Queue eksisting PCQ ori)
|
# 4. BIKIN CHILD QUEUE LOKAL YANG BARU (Gunakan rate FULL / Queue eksisting PCQ ori)
|
||||||
commands.append(f"/queue/tree/add max-limit=5G name={name}_dl_local packet-mark={dl_loc} parent=1_all_dl_Dimensi_LOKAL queue={pcq_dl_full}")
|
commands.append(f"/queue/tree/add max-limit=5G name={name}_dl_local packet-mark={dl_loc} parent=1_all_dl_Dimensi_LOKAL queue={pcq_dl_full}")
|
||||||
commands.append(f"/queue/tree/add max-limit=5G name={name}_ul_local packet-mark={up_loc} parent=5_all_ul_Dimensi_LOKAL queue={q_up_ori}")
|
commands.append(f"/queue/tree/add max-limit=5G name={name}_ul_local packet-mark={up_loc} parent=5_all_ul_Dimensi_LOKAL queue={q_up_ori}")
|
||||||
|
|
||||||
# --- EKSEKUSI SEMUA COMMAND SEBAGAI MIKROTIK BATCH SCRIPT ---
|
# --- EKSEKUSI SEMUA COMMAND BARIS DEMI BARIS ---
|
||||||
script_code = "\n".join(commands)
|
print(f"Mengeksekusi {len(commands)} baris konfigurasi secara antrean (Sequential)...")
|
||||||
|
|
||||||
print(f"Mengeksekusi {len(commands)} baris konfigurasi Mangle, Type, dan Queue Tree dual-stack...")
|
success_count = 0
|
||||||
|
fail_count = 0
|
||||||
|
|
||||||
payload = {"script": script_code}
|
for cmd in commands:
|
||||||
|
try:
|
||||||
try:
|
res = session.post(f"{api_url}/execute", json={"script": cmd}, timeout=10)
|
||||||
res = session.post(f"{api_url}/execute", json=payload, timeout=30)
|
if res.status_code in (200, 201):
|
||||||
if res.status_code in (200, 201):
|
success_count += 1
|
||||||
print("Berhasil! Mangle & Queue Lokal (Full) vs Int (Half) telah disinkronisasi.")
|
else:
|
||||||
print(f"Respon MikroTik: {res.text.strip()}")
|
fail_count += 1
|
||||||
else:
|
# print(f"Warning saat eksekusi: {cmd}\nResponse: {res.text}")
|
||||||
print(f"Kegagalan saat inject konfigurasi: {res.text}")
|
except Exception as e:
|
||||||
except Exception as e:
|
fail_count += 1
|
||||||
print(f"Error eksekusi: {e}")
|
print(f"Error Timeout: {e}")
|
||||||
|
|
||||||
|
print(f"Selesai! {success_count} berhasil, {fail_count} dilewati (Mungkin objek dicari tidak ada/sudah ada).")
|
||||||
|
print("Mangle & Queue Lokal vs Int dual-stack telah disinkronisasi utuh.")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
update_mangle_and_queue()
|
update_mangle_and_queue()
|
||||||
|
|||||||
Reference in New Issue
Block a user