Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // call this function on a timer
- func optimizeBanTable(){
- var explored_subnets []string // ["192.0.0.0/17","192.0.0.128/17"]
- //1 Fetch all bans
- var bans []string
- //2 take one ban and check if it's redundant in the total list of bans
- // itterate over bans for main action
- // itterate over bans to see if it's redundant
- // build subnet chunks and itterate over them
- // eg for 192.168.1.1
- // 192.0.0.0/9 , 192.128.0.0/9 , 192.168.0.0/17 , 192.168.128.0/17 , 192.168.1.0/25 , 192.168.1.128/25 6x
- // or for ipv6 , 2605:8d80:504:4fb1:1c6b:ea11:a067:e812 , a less chunked system
- // 2605:0:0:0:0:0:0:0/16 , 2605:8d80:0:0:0:0:0:0/32 , 2605:8d80:504:0:0:0:0:0/48 , 2605:8d80:504:4fb1:0:0:0:0/64 , 2605:8d80:504:4fb1:1c6b:0:0:0/80 , 2605:8d80:504:4fb1:1c6b:ea11:0:0/96 6x
- // within each itterated chunk check the ban list for items falling within this
- // if an item is found add it to the count
- // A subnet counts as a number based on the mask bit
- // A single IP counts by 1
- // use a factorial system based on the subnet mask value to evaluate weather the number of bans is enough to lock the current chunk with a ban
- // if it's enough to warant a lock, remove the bans used for counting from the DB and the search list as they are now redundant
- }
- func getBansFromProxySites(){
- // 1 get list of cites from a settings json page
- // 2 search page for ipv4 and ipv6 subnets and addresses
- // 3 add finds to database if not already existing
- }
- func createRecurentActionTicker(){
- ban_ticker := time.NewTicker(1 * time.Hour)
- go func() {
- for {
- <-ban_ticker.C
- getBansFromProxySites()
- optimizeBanTable()
- }
- }()
- }
Add Comment
Please, Sign In to add comment