-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mikrotik RouterOS Parser #244
Mikrotik RouterOS Parser #244
Conversation
@@ -0,0 +1,6 @@ | |||
features = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always like to have an example of a banner being parsed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Ken! The comments at the top of the config files, is that considered a banner here, not just comments? There is a system note
command, but it just outputs like a normal str config line.
# mar/22/2023 17:44:57 by RouterOS 6.48.5
# software id =
#
#
#
/interface wireless security-profiles set [ find default=yes ] supplicant-identity=MikroTik
/ip address add address=172.31.255.30/30 interface=ether1 network=172.31.255.28
/ip dhcp-client add disabled=no interface=ether1
/system identity set name=R2
/system note set note="SOME CRAZY NOTE!"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, perhaps simpleton of me to presume there is a banner :)
I do think it would be great to have a few options for "note", like how does it handle multi-line (is that supported), special characters, can you have a double quote in there, etc.. Think of ways to break it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@itdependsnetworks I added to the parsing
tests to capture the lines that are children of the /system note set note=..
line. This is the exact input that went into the device is below. If a user inputs a string without adding \n
the config export will handle it and add it for you, same with special chars. Device will just escape them when exporting config.
This is a \"System Note\" for a Mikrotik router.\n\
It includes double quotes (\") and special characters such as:\n\
@, #, $, %, ^, &, *, (, ), _, +, [, ], {, }, |, ;, ',', ., /, <, >, and ?.\n\
\n\
Remember to escape any special characters with a backslash (\\) when necessary.\n\
\n\
This is a multiline note with several lines of text.
and when doing a terse
config export, the following output appears ->
[admin@ag1.123site.nwk.nj] /system note> export terse
# apr/01/2023 17:16:02 by RouterOS 6.48.5
# software id =
#
#
#
/system note set note="This is a \\\"System Note\\\" for a Mikrotik router.\\n\\\
\nIt includes double quotes (\\\") and special characters such as:\\n\\\
\n@, #, \$, %, ^, &, *, (, ), _, +, [, ], {, }, |, ;, ',', ., /, <, >, and \?.\\n\\\
\n\\n\\\
\nRemember to escape any special characters with a backslash (\\\\) when necessary.\\n\\\
\n\\n\\\
\nThis is a multiline note with several lines of text.\\n\\\
\nWow, what a great example of a note to ensure proper parsing by NetUtils!"
[admin@ag1.123site.nwk.nj] /system note>
hope this helps and captures what you asked for, LMK.
parents=(), | ||
), | ||
ConfigLine( | ||
config_line=' \\nIt includes double quotes (\\\\\\") and special characters such as:\\\\n\\\\\\', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my mind, this line and the below should all be a single line without a parent. As an example I would not see the other lines as children of this parent.
look at:
banner exec ^C |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, I'd expect this to be one single line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right on, the more I looked at this, it makes sense to treat this like a banner since it does allow to display upon logging into the device. Made some changes, lmk what ya'll think. Single line.
mikrotik_routeros
parser