作者: xo_ox 時間: 2024-11-1 14:33 標題: help - Mikrotik Script for capture tiktok ip
本帖最後由 xo_ox 於 2024-11-1 06:40 編輯
This script work on only one keyword;
- :local sname "tiktok" ;
- :local lname "us-only" ;
- #/log info ("Starting "$sname" script");
- :foreach i in=[/ip dns cache all find where (name~"$sname")] do={
- :local tmpAddress [/ip dns cache get $i name];
-
- :if ( [/ip firewall address-list find where address=$tmpAddress] = "") do={
- :local cacheName [/ip dns cache get $i name] ;
- #/log info ("added entry: $cacheName $tmpAddress");
- /ip firewall address-list add address=$tmpAddress list=$lname timeout=00:01:00 ;
- }
- }
- /log info ("Ending "$sname" script");
- :local lname "tiktok_ips"; # Address list name
- :local domains {"tiktokcdn", "tiktokv", "tiktok", "byteoversea", "musical-ly", "tiktokapi", "tik-tok", "ttwapi", "ixigua", "amemv", "snssdk", "pstatp", "byteimg", "zjbyte"};
- :local timeout "1d"; # Address list entry timeout
- /log info ("Starting TikTok DNS capture script");
- :foreach sname in=$domains do={
- /log info ("Checking domain pattern "$sname"");
-
- # Search DNS cache for entries matching the domain pattern
- :foreach i in=[/ip dns cache find where name~"$sname"] do={
- :local resolvedIP [/ip dns cache get $i address];
-
- # Check if IP address was resolved and is not already in the address list
- :if (($resolvedIP != "") && ([/ip firewall address-list find where address=$resolvedIP] = nil)) do={
- :local cacheName [/ip dns cache get $i name];
- /log info ("Adding TikTok IP: $resolvedIP for domain $cacheName to address list $lname");
-
- # Add the IP to the address list with a timeout
- /ip firewall address-list add address=$resolvedIP list=$lname timeout=$timeout;
- } else={
- :log info ("No new IP for "$sname" or already in list");
- }
- }
- }
- :log info ("TikTok DNS capture script completed");
作者: xo_ox 時間: 2024-11-1 14:40
i need to post to -->程式編寫 ma?
