Updates v2.6.1

+ Added reverse proxy TLS skip verification
+ Added basic auth
+ Edit proxy settings
+ Whitelist
+ TCP Proxy (experimental)
+ Info (Utilities page)
This commit is contained in:
Toby Chui
2023-05-31 22:22:47 +08:00
parent 5952a1b55f
commit 20fd8e9a49
42 changed files with 87636 additions and 1165 deletions

View File

@@ -145,7 +145,9 @@ func (c *Collector) RecordRequest(ri RequestInfo) {
//Filter out CF forwarded requests
if strings.Contains(ri.IpAddr, ",") {
ips := strings.Split(strings.TrimSpace(ri.IpAddr), ",")
if len(ips) >= 1 {
if len(ips) >= 1 && IsValidIPAddress(strings.TrimPrefix(ips[0], "[")) {
//Example when forwarded from CF: 158.250.160.114,109.21.249.211
//Or IPv6 [15c4:cbb4:cc98:4291:ffc1:3a46:06a1:51a7],109.21.249.211
ri.IpAddr = ips[0]
}
}

View File

@@ -2,6 +2,7 @@ package statistic
import (
"fmt"
"net"
"time"
)
@@ -26,3 +27,19 @@ func IsBeforeToday(dateString string) bool {
today := time.Now().UTC().Truncate(24 * time.Hour)
return date.Before(today) || dateString == time.Now().Format(layout)
}
// Check if the IP string is a valid ip address
func IsValidIPAddress(ip string) bool {
// Check if the string is a valid IPv4 address
if parsedIP := net.ParseIP(ip); parsedIP != nil && parsedIP.To4() != nil {
return true
}
// Check if the string is a valid IPv6 address
if parsedIP := net.ParseIP(ip); parsedIP != nil && parsedIP.To16() != nil {
return true
}
// If the string is neither a valid IPv4 nor IPv6 address, return false
return false
}