Provide custom options of TrustedPlatform for another CDN services (#2906)
* refine TrustedPlatform and docs * refactor for switch * refactor switch to if statement
This commit is contained in:
@ -1458,8 +1458,20 @@ func TestContextClientIP(t *testing.T) {
|
||||
c.engine.TrustedPlatform = PlatformGoogleAppEngine
|
||||
assert.Equal(t, "50.50.50.50", c.ClientIP())
|
||||
|
||||
// Test the legacy flag
|
||||
// Use custom TrustedPlatform header
|
||||
c.engine.TrustedPlatform = "X-CDN-IP"
|
||||
c.Request.Header.Set("X-CDN-IP", "80.80.80.80")
|
||||
assert.Equal(t, "80.80.80.80", c.ClientIP())
|
||||
// wrong header
|
||||
c.engine.TrustedPlatform = "X-Wrong-Header"
|
||||
assert.Equal(t, "40.40.40.40", c.ClientIP())
|
||||
|
||||
c.Request.Header.Del("X-CDN-IP")
|
||||
// TrustedPlatform is empty
|
||||
c.engine.TrustedPlatform = ""
|
||||
assert.Equal(t, "40.40.40.40", c.ClientIP())
|
||||
|
||||
// Test the legacy flag
|
||||
c.engine.AppEngine = true
|
||||
assert.Equal(t, "50.50.50.50", c.ClientIP())
|
||||
c.engine.AppEngine = false
|
||||
|
Reference in New Issue
Block a user