Skip to content

Commit

Permalink
removed custom cloudflare functon
Browse files Browse the repository at this point in the history
  • Loading branch information
kelindi committed Feb 4, 2025
1 parent 68a459d commit f4c1dc1
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions pkg/solver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (solverServer *solverServer) disconnectCB(connParams http.WSConnectionParam
func exemptIPKeyFunc(exemptIPs []string) func(r *corehttp.Request) (string, error) {
return func(r *corehttp.Request) (string, error) {

ip, err := getRealIPWithCloudflare(r)
ip, err := httprate.KeyByRealIP(r)

if err != nil {
log.Error().Err(err).Msgf("error getting real ip")
Expand All @@ -208,14 +208,6 @@ func exemptIPKeyFunc(exemptIPs []string) func(r *corehttp.Request) (string, erro
}
}

func getRealIPWithCloudflare(r *corehttp.Request) (string, error) {
if ip := r.Header.Get("CF-Connecting-IP"); ip != "" {
return canonicalizeIP(ip), nil
}

return httprate.KeyByRealIP(r)
}

func canonicalizeIP(ip string) string {
for _, c := range ip {
switch c {
Expand Down

0 comments on commit f4c1dc1

Please sign in to comment.