apernet / OpenGFW

OpenGFW is a flexible, easy-to-use, open source implementation of GFW (Great Firewall of China) on Linux
https://gfw.dev/
Mozilla Public License 2.0
9.47k stars 711 forks source link

feat: rule set loader #88

Closed Aionw closed 5 months ago

Aionw commented 6 months ago

Add rule set loader, move original config loader routine into ruslet/loader.go

tobyxdd commented 6 months ago

Sorry but I don't see the point of this change. You are merely moving this function into a new struct with only one method. This is not abstraction - in fact it ends up with more lines and more fragmented code

Aionw commented 6 months ago

The basic idea here is to create a new component named RuleSetLoader which managed all ruleset update and can be selected by config file. Based on this component, we can add remote config to not only load config from local file. Besides, viper offers onConfigChange and customized reader, maybe it's better to use them to implement new RuleSetLoader?