gin-gonic / gin
Showing 2 of 4 files from the diff.
Other files ignored by Codecov
README.md has changed.
context_test.go has changed.

@@ -59,10 +59,10 @@
Loading
59 59
const (
60 60
	// When running on Google App Engine. Trust X-Appengine-Remote-Addr
61 61
	// for determining the client's IP
62 -
	PlatformGoogleAppEngine = "google-app-engine"
62 +
	PlatformGoogleAppEngine = "X-Appengine-Remote-Addr"
63 63
	// When using Cloudflare's CDN. Trust CF-Connecting-IP for determining
64 64
	// the client's IP
65 -
	PlatformCloudflare = "cloudflare"
65 +
	PlatformCloudflare = "CF-Connecting-IP"
66 66
)
67 67
68 68
// Engine is the framework's instance, it contains the muxer, middleware and configuration settings.

@@ -735,20 +735,16 @@
Loading
735 735
	return bb.BindBody(body, obj)
736 736
}
737 737
738 -
// ClientIP implements a best effort algorithm to return the real client IP.
738 +
// ClientIP implements one best effort algorithm to return the real client IP.
739 739
// It called c.RemoteIP() under the hood, to check if the remote IP is a trusted proxy or not.
740 740
// If it is it will then try to parse the headers defined in Engine.RemoteIPHeaders (defaulting to [X-Forwarded-For, X-Real-Ip]).
741 741
// If the headers are not syntactically valid OR the remote IP does not correspond to a trusted proxy,
742 742
// the remote IP (coming form Request.RemoteAddr) is returned.
743 743
func (c *Context) ClientIP() string {
744 -
	// Check if we're running on a trusted platform
745 -
	switch c.engine.TrustedPlatform {
746 -
	case PlatformGoogleAppEngine:
747 -
		if addr := c.requestHeader("X-Appengine-Remote-Addr"); addr != "" {
748 -
			return addr
749 -
		}
750 -
	case PlatformCloudflare:
751 -
		if addr := c.requestHeader("CF-Connecting-IP"); addr != "" {
744 +
	// Check if we're running on a trusted platform, continue running backwards if error
745 +
	if c.engine.TrustedPlatform != "" {
746 +
		// Developers can define their own header of Trusted Platform or use predefined constants
747 +
		if addr := c.requestHeader(c.engine.TrustedPlatform); addr != "" {
752 748
			return addr
753 749
		}
754 750
	}
Files Coverage
binding 100.00%
render 92.61%
auth.go 100.00%
context.go 97.81%
debug.go 100.00%
deprecated.go 100.00%
errors.go 100.00%
fs.go 100.00%
gin.go 99.12%
logger.go 100.00%
mode.go 100.00%
path.go 100.00%
recovery.go 98.08%
response_writer.go 93.48%
routergroup.go 100.00%
test_helpers.go 100.00%
tree.go 100.00%
utils.go 96.81%
Project Totals (41 files) 98.74%
1376666356
nomsgpack go-1.13 macos-latest
1376666356
go-1.15 macos-latest
1376666356
go-1.13 macos-latest
1376666356
nomsgpack go-1.14 macos-latest
1376666356
nomsgpack go-1.15 macos-latest
1376666356
go-1.14 macos-latest
1376666356
go-1.17 macos-latest
1376666356
nomsgpack go-1.16 macos-latest
1376666356
nomsgpack go-1.17 macos-latest
1376666356
go-1.16 macos-latest
1376666356
nomsgpack go-1.15 ubuntu-latest
1376666356
nomsgpack go-1.17 ubuntu-latest
1376666356
nomsgpack go-1.16 ubuntu-latest
1376666356
go-1.13 ubuntu-latest
1376666356
go-1.15 ubuntu-latest
1376666356
nomsgpack go-1.13 ubuntu-latest
1376666356
nomsgpack go-1.14 ubuntu-latest
1376666356
go-1.14 ubuntu-latest
1376666356
go-1.17 ubuntu-latest
1376666356
go-1.16 ubuntu-latest
1
coverage:
2
  notify:
3
    gitter:
4
      default:
5
        url: https://webhooks.gitter.im/e/d90dcdeeab2f1e357165
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading