CodeFaux

Untitled

Oct 14th, 2025
547
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. :log info "Start"
  2. :foreach idx in=[/ip/firewall/address-list/find list=PRIORITY_HOSTS] do={
  3.     :local ip [/ip/firewall/address-list/get $idx address];
  4.     :local tag [/ip/firewall/address-list/get $idx comment];
  5.     :local lease [/ip/dhcp-server/lease/find where address=$ip];
  6.     :local mac [/ip/dhcp-server/lease/get $lease mac-address];
  7.  
  8.     :foreach n in=[/ipv6/neighbor/find where mac-address=$mac interface=BRIDGE_LAN] do={
  9.         :local candidate [/ipv6/neighbor/get $n address]
  10.         :log info [:serialize value=$candidate to=json]
  11.         :if ([:len $candidate] > 0 && [:pick $candidate 0 4] = "2605") do={
  12.  
  13.             :log info ("/ipv6/firewall/address-list/print where list=PRIORITY_HOSTS address=" . $candidate);
  14.             # ^^^ IF I RUN THIS COMMAND IT RETURNS A VALID MATCH
  15.  
  16.             :log info (":put [/ipv6/firewall/address-list/find list=PRIORITY_HOSTS address=" . $candidate . "]");
  17.             # ^^^ IF I RUN THIS COMMAND IT RETURNS A VALID MATCH
  18.  
  19.             :local existing [/ipv6/firewall/address-list/find list=PRIORITY_HOSTS address=$candidate];
  20.             # ^^^ NEVER POPULATED EVEN THOUGH LIST ENTRY IS 100% VERIFIED TO EXIST AND BOTH PRINT AND FIND COMMANDS 100% RETURN A MATCH MANUALLY
  21.  
  22.             :if ([:len $existing] = 0) do={
  23.                 /ipv6/firewall/address-list/add comment=$tag list=PRIORITY_HOSTS timeout=1:0:0 address=$candidate;
  24.                 # ^^^ ALWAYS THROWS ERROR BECAUSE ENTRY EXISTS
  25.             } else={
  26.                 /ipv6/firewall/address-list/set $existing timeout=4:0:0;
  27.                 # ^^^ NEVER RUN BECAUSE `existing` IS NOT POPULATED
  28.             }
  29.         }
  30.     }
  31. }
  32. :log info "End"
Advertisement
Add Comment
Please, Sign In to add comment