Skip to content

Commit

Permalink
Merge pull request #94 from rollbar/pawel/fix_ip_address
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelsz-rb authored Jun 14, 2022
2 parents 6380fe0 + f6e498d commit 0066903
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion rollbar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func TestBuildBodyNoBaseCustom(t *testing.T) {
func TestErrorRequest(t *testing.T) {
r, _ := http.NewRequest("GET", "http://foo.com/somethere?param1=true", nil)
r.RemoteAddr = "1.1.1.1:123"

SetCaptureIp(CaptureIpFull)
object := std.requestDetails(r)

if object["url"] != "http://foo.com/somethere?param1=true" {
Expand All @@ -223,6 +223,9 @@ func TestErrorRequest(t *testing.T) {
if object["query_string"] != "param1=true" {
t.Errorf("wrong id, got %v", object["query_string"])
}
if object["user_ip"] != "1.1.1.1" {
t.Errorf("wrong user_ip, got %v", object["user_ip"])
}
}

func TestRequestForwardedIP(t *testing.T) {
Expand Down
4 changes: 3 additions & 1 deletion transforms.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ func remoteIP(req *http.Request) string {
ips := strings.Split(forwardedIPs, ", ")
return ips[0]
}
return req.RemoteAddr
remoteAddr := req.RemoteAddr
spltRemoteAddr := strings.Split(remoteAddr, ":")
return spltRemoteAddr[0]
}

// filterFlatten filters sensitive information like passwords from being sent to Rollbar, and
Expand Down

0 comments on commit 0066903

Please sign in to comment.