Wildcard IP Banning with MySQL

前端 未结 5 1884
甜味超标
甜味超标 2021-02-01 11:01

I\'m trying to implement an IP banning system into my web app using MySQL, i know i can do it using .htaccess but that\'s not neat to me.

Basically my curre

5条回答
  •  猫巷女王i
    2021-02-01 11:25

    My suggestion might make some cringe, but you seem to be going for nontraditional in this project so here it goes: Parse each IP from the database into a regex that can be compared against the user's IP. Example:

    
    

    And of course you can do much more with this. You could cache the regex to save querying the database on every request or even expand your wild card options to includes IP ranges.

提交回复
热议问题