2

I am new with LUA so take it easy to me. I have the following code that should be ran into mikrotik router. Could you possibly tell me what it does?

:local content
:local i
#For each mangle in the list
:foreach i in=[/ip firewall mangle find comment !=""] do={

#Pull comment out of queue and divide up accordingly
    :set content [/ip firewall mangle get $i comment]
:if ([:find $content "!"] != "") do={
        :local pos1 [:find $content "!"]
        :local pos4 [:len $content]
        :local pos2 ([:find [:pick $content ($pos1+1) $pos4] "!"]+($pos1+1))
        :local pos3 ([:find [:pick $content ($pos2+1) $pos4] "!"]+($pos2+1))
hjpotter92
  • 78,589
  • 36
  • 144
  • 183
mrb
  • 29
  • 2

1 Answers1

1

This is a Mikrotik script which search for rules with comments in the firewall mangle rules, and find the comments with exclamation points "!".

The variables pos1 pos2 pos3 are first, second and third location of ! in the comments.

For instance: If there is a comment like this: a!b!cde!fg

Variables would be:

pos1=1    pos2=3    pos3=7

The location starts from zero, so first location is 0 and second is 1!

Arash
  • 400
  • 4
  • 11