Commit graph

23 commits

Author SHA1 Message Date
Christian Hesse
958bfa7ce8 collect-wireless-mac: automatically add missing access-list entry 2020-01-17 10:36:03 +01:00
Christian Hesse
aa885e17e2 collect-wireless-mac: use dynamic & bound mac address only 2020-01-06 09:47:32 +01:00
Christian Hesse
afb9839073 update copyright for 2020 2020-01-01 17:00:39 +01:00
Christian Hesse
a8a0523d33 collect-wireless-mac: add the dns name 2019-11-25 17:07:45 +01:00
Christian Hesse
15a6fb325e collect-wireless-mac: lease without address should be impossible...
... we need the check for empty hostname, though.
2019-11-25 16:43:19 +01:00
Christian Hesse
b70d4f7666 collect-wireless-mac: move code into condition 2019-11-25 16:39:23 +01:00
Christian Hesse
b35c0b8a6f always write warnings and errors to log 2019-04-03 21:30:43 +02:00
Christian Hesse
e72b3dd4f1 collect-wireless-mac: use $ScriptLock 2019-02-21 20:16:03 +01:00
Christian Hesse
1ca1b48bcd collect-wireless-mac: simplify array access 2019-01-15 10:38:47 +01:00
Christian Hesse
870f00bb36 global: variable names are CamelCase
___  _         ___     __
           / _ )(_)__ _   / _/__ _/ /_
          / _  / / _ `/  / _/ _ `/ __/
         /____/_/\_, /  /_/ \_,_/\__/
 _       __     /___/       _             __
| |     / /___ __________  (_)___  ____ _/ /
| | /| / / __ `/ ___/ __ \/ / __ \/ __ `/ /
| |/ |/ / /_/ / /  / / / / / / / / /_/ /_/
|__/|__/\__,_/_/  /_/ /_/_/_/ /_/\__, (_)
                                /____/

RouterOS has some odd behavior when it comes to variable names. Let's
have a look at the interfaces:

[admin@MikroTik] > / interface print where name=en1
Flags: D - dynamic, X - disabled, R - running, S - slave
 #     NAME                                TYPE       ACTUAL-MTU L2MTU
 0  RS en1                                 ether            1500  1598

That looks ok. Now we use a script:

{ :local interface "en1";
  / interface print where name=$interface; }

And the result...

[admin@MikroTik] > { :local interface "en1";
{...   / interface print where name=$interface; }
Flags: D - dynamic, X - disabled, R - running, S - slave
 #     NAME                                TYPE       ACTUAL-MTU L2MTU
 0  RS en1                                 ether            1500  1598

... still looks ok.
We make a little modification to the script:

{ :local name "en1";
  / interface print where name=$name; }

And the result:

[admin@MikroTik] > { :local name "en1";
{...   / interface print where name=$name; }
Flags: D - dynamic, X - disabled, R - running, S - slave
 #     NAME                                TYPE       ACTUAL-MTU L2MTU
 0  RS en1                                 ether            1500  1598
 1   S en2                                 ether            1500  1598
 2   S en3                                 ether            1500  1598
 3   S en4                                 ether            1500  1598
 4   S en5                                 ether            1500  1598
 5  R  br-local                            bridge           1500  1598

Ups! The filter has no effect!
That happens whenever the variable name ($name) matches the property
name (name=).

And another modification:

{ :local type "en1";
  / interface print where name=$type; }

And the result:

[admin@MikroTik] > { :local type "en1";
{...   / interface print where name=$type; }
Flags: D - dynamic, X - disabled, R - running, S - slave
 #     NAME                                TYPE       ACTUAL-MTU L2MTU

Ups! Nothing?
Even if the variable name ($type) matches whatever property name (type=)
things go wrong.

The answer from MikroTik support (in Ticket#2019010222000454):

> This is how scripting works in RouterOS and we will not fix it.

To get around this we use variable names in CamelCase. Let's hope
Mikrotik never ever introduces property names in CamelCase...

*fingers crossed*
2019-01-04 12:35:34 +01:00
Christian Hesse
472cd3d905 update copyright for 2019 2019-01-02 09:38:34 +01:00
Christian Hesse
3cdd0fb94b global-functions: properly define global functions 2018-12-28 22:56:29 +01:00
Christian Hesse
ee5eefefc3 global-functions: add $GetMacVendor 2018-12-27 00:48:56 +01:00
Christian Hesse
f4673928ef global-functions: make $CertificateAvailable work on CommonName
This should prevent endless certificate switching for Let's Encrypt
cross-signed intermediate certificates.
2018-12-20 22:21:00 +01:00
Christian Hesse
b8830ee6a5 collect-wireless-mac: send the mac's vendor part only 2018-12-14 12:48:01 +01:00
Christian Hesse
eda89ba643 collect-wireless-mac: get and record the vendor 2018-12-14 12:35:06 +01:00
Christian Hesse
6e4d715937 global-functions: add identity tag in $SendNotification
... and send subject in telegram message.
2018-11-28 21:19:39 +01:00
Christian Hesse
1bbbe3a5a7 global: remove unused variables 2018-10-10 21:49:46 +02:00
Christian Hesse
f262ff99a8 collect-wireless-mac: use function for notification 2018-10-09 15:57:53 +02:00
Christian Hesse
be673737d3 start scripts with a magic token / shebang 2018-09-27 00:18:43 +02:00
Christian Hesse
07e54dd88b add empty comment at first line...
... for better formatting in export.
2018-08-24 16:58:30 +02:00
Christian Hesse
c66bb89be2 update template system 2018-07-10 14:01:41 +02:00
Christian Hesse
fe5386fbec introduce templates for scripts depending on capsman or local wireless 2018-07-09 16:44:44 +02:00
Renamed from collect-wireless-mac (Browse further)