AuthMeReloaded icon indicating copy to clipboard operation
AuthMeReloaded copied to clipboard

AllowedRestrictedUser Wildcard

Open Faicu opened this issue 9 years ago • 4 comments

Hello! I want to use AllowedRestrictedUser to restrict my username, Faicu to my IP. But, I have dynamic IP and it is modifying daily with a NEW part of it. Example: 23.33.55.10 today. 23.33.55.11, tomorrow and I want, if possible to use wildcard at last series of numbers, like: 23.33.55.* or 23.33.55.% something like this.

Environment description

BungeeCord - Spigot

AuthMe build number:

5.2 1542

Faicu avatar May 27 '17 14:05 Faicu

The added RegEx support is a great addition, but AFAIS no documentation changes were done which clearly state you have to use Java-specific RegEx syntax.

rautamiekka avatar Jul 03 '17 10:07 rautamiekka

The best way would be if we supported * as wildcard. Would not require any regex prefix and is probably what the user would expect. I'm not sure how it could be best implemented, though :/

ljacqu avatar Jul 03 '17 11:07 ljacqu

^ I think that should internally be done as a RegEx regardless since it provides a massive range of possibilities. In which case you could do this (designed for Perl but should work with Java when Java's additional requirements are met):

  • Escape characters as needed, except the * if we'll use it as the wildcard.
  • If it's an IPv4 address, replace * with [0-9]{1,3} (I know, this allows IPv4 0.0.0.0-999.999.999.999, but that's not really any of our concern). If it's a string (username, etc.), with .*. EDIT 2017-07-25: I found a working complete IPv4 address RegEx which allows only the IPs it's supposed to, but it's a lot of text cuz of options, so I made a gist: https://gist.github.com/rautamiekka/e6e088f085a553778992dfd9e1ffb2da
  • Assuming you want the string you're supposed to compare against to match completely: prepend ^ and append $ to the RegEx string. However, if Java has its own quirks with this that make this step redundant, I'm not aware of such thing.
  • Run the RegEx string through RegEx matcher like usual.
  • Do your stuff.

rautamiekka avatar Jul 03 '17 14:07 rautamiekka

I've tested the new regex feature successfully on an online server, so in the interest of keeping our tracking clean (milestones and whatnot) I open a follow-up issue and close this.

ljacqu avatar Jul 08 '17 19:07 ljacqu