Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a new matcher to multiplex connections initiated by Winbox, a graphical tool for MikroTik hardware and software routers management. Many of these routers all over the Internet have port 8291 open and listening for incoming connections on their WANs. Some of them allegedly formed part of a global bot net a few years ago, and a few Winbox vulnerabilities were most probably the reason for it.
This matcher allows to multiplex Winbox connections with anything else (e.g. TLS on port 443), so that such routers could be reachable without exposing their distinctive port. The matcher is also capable of filtering users (with plaintext or regular expressions) and modes (standard and/or RoMON), so that no unwanted connection requests could reach the router(s) behind Caddy.
Given RouterOS is a commercial software and Winbox uses an undocumented proprietary protocol to connect to it, proxying Winbox through Caddy could be an additional layer of security to mitigate vulnerabilities that may already exist or be introduced in the future.
Sample syntax
Disclaimer
I've tested this matcher against Winbox v3.30, v3.41 and v4.0 in both standard and RoMON modes. A legacy mode which is available in the tools menu of Winbox didn't make any difference in terms of matching the first packet received from the client, i.e. it is also inherently supported. The previous versions of Winbox used to have a secure mode checkbox, and this matcher will most probably only work when it is checked. The newer versions have it implicitly enabled by default.