-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ Added X-Forwarded-Proto for automatic proxy detector + Split blacklist and whitelist from geodb script file + Optimized compile binary size + Added access control to TCP proxy + Added "invalid config detect" in up time monitor for isse #7 + Fixed minor bugs in advance stats panel + Reduced file size of embedded materials
- Loading branch information
Showing
27 changed files
with
391 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package geodb | ||
|
||
import "strings" | ||
|
||
/* | ||
Blacklist.go | ||
This script store the blacklist related functions | ||
*/ | ||
|
||
//Geo Blacklist | ||
|
||
func (s *Store) AddCountryCodeToBlackList(countryCode string) { | ||
countryCode = strings.ToLower(countryCode) | ||
s.sysdb.Write("blacklist-cn", countryCode, true) | ||
} | ||
|
||
func (s *Store) RemoveCountryCodeFromBlackList(countryCode string) { | ||
countryCode = strings.ToLower(countryCode) | ||
s.sysdb.Delete("blacklist-cn", countryCode) | ||
} | ||
|
||
func (s *Store) IsCountryCodeBlacklisted(countryCode string) bool { | ||
countryCode = strings.ToLower(countryCode) | ||
var isBlacklisted bool = false | ||
s.sysdb.Read("blacklist-cn", countryCode, &isBlacklisted) | ||
return isBlacklisted | ||
} | ||
|
||
func (s *Store) GetAllBlacklistedCountryCode() []string { | ||
bannedCountryCodes := []string{} | ||
entries, err := s.sysdb.ListTable("blacklist-cn") | ||
if err != nil { | ||
return bannedCountryCodes | ||
} | ||
for _, keypairs := range entries { | ||
ip := string(keypairs[0]) | ||
bannedCountryCodes = append(bannedCountryCodes, ip) | ||
} | ||
|
||
return bannedCountryCodes | ||
} | ||
|
||
//IP Blacklsits | ||
|
||
func (s *Store) AddIPToBlackList(ipAddr string) { | ||
s.sysdb.Write("blacklist-ip", ipAddr, true) | ||
} | ||
|
||
func (s *Store) RemoveIPFromBlackList(ipAddr string) { | ||
s.sysdb.Delete("blacklist-ip", ipAddr) | ||
} | ||
|
||
func (s *Store) GetAllBlacklistedIp() []string { | ||
bannedIps := []string{} | ||
entries, err := s.sysdb.ListTable("blacklist-ip") | ||
if err != nil { | ||
return bannedIps | ||
} | ||
|
||
for _, keypairs := range entries { | ||
ip := string(keypairs[0]) | ||
bannedIps = append(bannedIps, ip) | ||
} | ||
|
||
return bannedIps | ||
} | ||
|
||
func (s *Store) IsIPBlacklisted(ipAddr string) bool { | ||
var isBlacklisted bool = false | ||
s.sysdb.Read("blacklist-ip", ipAddr, &isBlacklisted) | ||
if isBlacklisted { | ||
return true | ||
} | ||
|
||
//Check for IP wildcard and CIRD rules | ||
AllBlacklistedIps := s.GetAllBlacklistedIp() | ||
for _, blacklistRule := range AllBlacklistedIps { | ||
wildcardMatch := MatchIpWildcard(ipAddr, blacklistRule) | ||
if wildcardMatch { | ||
return true | ||
} | ||
|
||
cidrMatch := MatchIpCIDR(ipAddr, blacklistRule) | ||
if cidrMatch { | ||
return true | ||
} | ||
} | ||
|
||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
5e75997
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgotten to mention, this also added an experimental fix to issue #18