mirror of
https://git.hackfreedom.org/mesh.cat/meshname.git
synced 2026-05-22 06:22:32 +00:00
check for ip in reverse proxy header
This commit is contained in:
@@ -20,8 +20,14 @@ func domainFromIP(target net.IP) string {
|
||||
|
||||
// handle HTTP requests
|
||||
func handler(w http.ResponseWriter, r *http.Request) {
|
||||
// get client's ip address
|
||||
ip, port, err := net.SplitHostPort(r.RemoteAddr)
|
||||
_, _ = port, err
|
||||
// check if we're behind a reverse proxy
|
||||
xForwardedFor := r.Header.Get("X-Forwarded-For")
|
||||
if xForwardedFor != "" {
|
||||
ip = xForwardedFor
|
||||
}
|
||||
parsedIP := net.ParseIP(ip)
|
||||
// return domain for IPv6 only
|
||||
if parsedIP.To4() == nil {
|
||||
|
||||
Reference in New Issue
Block a user