server

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Port int = 5000
)

Functions

func ClientIP added in v0.4.1

func ClientIP(c *gin.Context) string

ClientIP implements a best effort algorithm to return the real client IP. It called c.RemoteIP() under the hood, to check if the remote IP is a trusted proxy or not. If it's it will then try to parse the headers defined in Engine.RemoteIPHeaders (defaulting to [X-Forwarded-For, X-Real-Ip]). If the headers are nots syntactically valid OR the remote IP does not correspong to a trusted proxy, the remote IP (coming form Request.RemoteAddr) is returned.

func RemoteIP added in v0.4.1

func RemoteIP(c *gin.Context) (net.IP, bool)

RemoteIP parses the IP from Request.RemoteAddr, normalizes and returns the IP (without the port). It also checks if the remoteIP is a trusted proxy or not. In order to perform this validation, it will see if the IP is contained within at least one of the CIDR blocks defined in Engine.TrustedProxies

func Start

func Start(ctx context.Context, wg *sync.WaitGroup, serverPort int)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL