routeros
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| routeros [2026/07/02 20:32] – protocol | routeros [2026/09/23 14:16] (current) – protocol | ||
|---|---|---|---|
| Line 64: | Line 64: | ||
| </ | </ | ||
| + | |||
| + | ===== Automatic PPPoE creation local secrets ===== | ||
| + | < | ||
| + | |||
| + | { | ||
| + | :put " | ||
| + | | ||
| + | # Initialize the log pointer to the very last current entry | ||
| + | :local terminalLogID [/log find] | ||
| + | :local lastID "" | ||
| + | :if ([:len $terminalLogID] > 0) do={ | ||
| + | :set lastID ($terminalLogID-> | ||
| + | } | ||
| + | |||
| + | # Continuous loop | ||
| + | :while (true) do={ | ||
| + | # Filter logs containing authentication failure and include "user " | ||
| + | :local logEntries [/log find where message~" | ||
| + | | ||
| + | :foreach entry in=$logEntries do={ | ||
| + | # Process only newer entries than our saved marker | ||
| + | :if ($entry > $lastID) do={ | ||
| + | :local logTopics [/log get $entry topics] | ||
| + | | ||
| + | # STRICT TOPIC CHECK: Ensure the log contains the ' | ||
| + | :if ($logTopics ~ " | ||
| + | :local logMsg [/log get $entry message] | ||
| + | :local logTime [/log get $entry time] | ||
| + | | ||
| + | :local startPos ([:find $logMsg "user "] + 5) | ||
| + | :local endPos [:find $logMsg " authentication failed" | ||
| + | | ||
| + | :if ($endPos > $startPos) do={ | ||
| + | :local pppoeUser [:pick $logMsg $startPos $endPos] | ||
| + | | ||
| + | # Verify if it already exists | ||
| + | :if ([:len [/ppp secret find where name=$pppoeUser]] = 0) do={ | ||
| + | /ppp secret add name=$pppoeUser password=" | ||
| + | :put " | ||
| + | } else={ | ||
| + | :put " | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | :set lastID $entry | ||
| + | } | ||
| + | } | ||
| + | # 2-second delay before checking the log buffer again | ||
| + | :delay 2s; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
routeros.1783035121.txt.gz · Last modified: by protocol
