Guest User

Untitled

a guest
Aug 28th, 2020
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1.  
  2. // call this function on a timer
  3. func optimizeBanTable(){
  4. var explored_subnets []string // ["192.0.0.0/17","192.0.0.128/17"]
  5. //1 Fetch all bans
  6. var bans []string
  7. //2 take one ban and check if it's redundant in the total list of bans
  8. // itterate over bans for main action
  9. // itterate over bans to see if it's redundant
  10. // build subnet chunks and itterate over them
  11. // eg for 192.168.1.1
  12. // 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
  13. // or for ipv6 , 2605:8d80:504:4fb1:1c6b:ea11:a067:e812 , a less chunked system
  14. // 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
  15. // within each itterated chunk check the ban list for items falling within this
  16. // if an item is found add it to the count
  17. // A subnet counts as a number based on the mask bit
  18. // A single IP counts by 1
  19. // 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
  20. // 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
  21.  
  22. }
  23.  
  24. func getBansFromProxySites(){
  25. // 1 get list of cites from a settings json page
  26.  
  27. // 2 search page for ipv4 and ipv6 subnets and addresses
  28.  
  29. // 3 add finds to database if not already existing
  30. }
  31.  
  32. func createRecurentActionTicker(){
  33. ban_ticker := time.NewTicker(1 * time.Hour)
  34. go func() {
  35. for {
  36. <-ban_ticker.C
  37. getBansFromProxySites()
  38. optimizeBanTable()
  39. }
  40. }()
  41.  
  42. }
Add Comment
Please, Sign In to add comment