1
4
mirror of https://github.com/yunginnanet/HellPot synced 2024-06-20 12:58:02 +00:00

Feature - making X-Real-IP configurable (#70)

This commit is contained in:
DJ1975 2023-03-01 01:58:41 +01:00 committed by GitHub
parent 58e8ab29a9
commit 22a52aff04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 1 deletions

@ -70,6 +70,9 @@ In the event of a missing configuration file, HellPot will attempt to place it's
bind_addr = "127.0.0.1"
bind_port = "8080"
# header name containing clients real IP, for reverse proxy deployments
real_ip_header = 'X-Real-IP'
# this contains a list of blacklisted useragent strings. (case sensitive)
# clients with useragents containing any of these strings will receive "Not found" for any requests.
uagent_string_blacklist = ["Cloudflare-Traffic-Manager", "curl"]

@ -129,6 +129,7 @@ func processOpts() {
stringOpt := map[string]*string{
"http.bind_addr": &HTTPBind,
"http.bind_port": &HTTPPort,
"http.real_ip_header": &HeaderName,
"logger.directory": &logDir,
"deception.server_name": &FakeServerName,
}

@ -36,6 +36,7 @@ var defOpts = map[string]map[string]interface{}{
"unix_socket_permissions": "0666",
"bind_addr": "127.0.0.1",
"bind_port": "8080",
"real_ip_header": "X-Real-IP",
"router": map[string]interface{}{
"catchall": false,

@ -42,6 +42,10 @@ var (
HTTPBind string
// HTTPPort is defined via our toml configuration file. It is the port that HellPot listens on.
HTTPPort string
// HeaderName is defined via our toml configuration file. It is the HTTP Header containing the original IP of the client,
// in traditional reverse Proxy deplyoments.
HeaderName string
// Paths are defined via our toml configuration file. These are the paths that HellPot will present for "robots.txt"
// These are also the paths that HellPot will respond for. Other paths will throw a warning and will serve a 404.
Paths []string

@ -19,7 +19,7 @@ import (
var log *zerolog.Logger
func getRealRemote(ctx *fasthttp.RequestCtx) string {
xrealip := string(ctx.Request.Header.Peek("X-Real-IP"))
xrealip := string(ctx.Request.Header.Peek(config.HeaderName))
if len(xrealip) > 0 {
return xrealip
}