Skip to content

Commit

Permalink
doghouse: log correct remote addr
Browse files Browse the repository at this point in the history
  • Loading branch information
haya14busa committed Jul 24, 2020
1 parent 3571cb2 commit 0f71ddf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion doghouse/appengine/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (gc *githubChecker) validateCheckRequest(ctx context.Context, w http.Respon
log.Printf("[ERROR] failed to update travis CI IP addresses: %v\n", err)
}
}
logger.LogWithReq(r, fmt.Sprintf("[INFO] Remote Addr: %s\n", r.RemoteAddr))
logger.LogWithReq(r, fmt.Sprintf("[INFO] Remote Addr: %s", ciutil.IPFromReq(r)))
if ciutil.IsFromCI(r) {
// Skip token validation if it's from trusted CI providers.
return true
Expand Down
6 changes: 3 additions & 3 deletions doghouse/server/ciutil/ciutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func IsFromCI(r *http.Request) bool {
func IsFromTravisCI(r *http.Request) bool {
muTravisIPAddrs.RLock()
defer muTravisIPAddrs.RUnlock()
return travisIPAddrs[ipFromReq(r)]
return travisIPAddrs[IPFromReq(r)]
}

// https://docs.travis-ci.com/user/ip-addresses/
Expand All @@ -100,10 +100,10 @@ func UpdateTravisCIIPAddrs(cli *http.Client) error {
// IsFromAppveyor returns true if given request is from Appveyor.
// https://www.appveyor.com/docs/build-environment/#ip-addresses
func IsFromAppveyor(r *http.Request) bool {
return appveyorIPAddrs[ipFromReq(r)]
return appveyorIPAddrs[IPFromReq(r)]
}

func ipFromReq(r *http.Request) string {
func IPFromReq(r *http.Request) string {
if f := r.Header.Get("Forwarded"); f != "" {
for _, kv := range strings.Split(f, ";") {
if kvPair := strings.SplitN(kv, "=", 2); len(kvPair) == 2 &&
Expand Down

0 comments on commit 0f71ddf

Please sign in to comment.