Skip to content

Commit efaf13f

Browse files
committed
Default to external IP
1 parent bfce967 commit efaf13f

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

coderd/httpmw/apikey.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs) func(http.Handler) h
168168
if now.Sub(key.LastUsed) > time.Hour {
169169
key.LastUsed = now
170170
remoteIP := net.ParseIP(r.RemoteAddr)
171+
if remoteIP == nil {
172+
remoteIP = net.IPv4(0, 0, 0, 0)
173+
}
171174
key.IPAddress = pqtype.Inet{
172175
IPNet: net.IPNet{
173176
IP: remoteIP,

coderd/users.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,9 @@ func (api *API) createAPIKey(rw http.ResponseWriter, r *http.Request, params dat
801801
}
802802

803803
ip := net.ParseIP(r.RemoteAddr)
804+
if ip == nil {
805+
ip = net.IPv4(0, 0, 0, 0)
806+
}
804807
key, err := api.Database.InsertAPIKey(r.Context(), database.InsertAPIKeyParams{
805808
ID: keyID,
806809
UserID: params.UserID,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy