MCPcopy Create free account
hub / github.com/BryanMwangi/pine / IPs

Method IPs

pine.go:565–580  ·  view source on GitHub ↗

IPs returns all IP addresses from proxy headers.

()

Source from the content-addressed store, hash-verified

563
564// IPs returns all IP addresses from proxy headers.
565func (c *Ctx) IPs() []string {
566 if ips := c.Request.Header.Get("X-Real-Ip"); ips != "" {
567 return strings.Split(ips, ",")
568 }
569 if ips := c.Request.Header.Get("CF-Connecting-IP"); ips != "" {
570 return strings.Split(ips, ",")
571 }
572 if ips := c.Request.Header.Get("X-Forwarded-For"); ips != "" {
573 return strings.Split(ips, ",")
574 }
575 ip, _, err := net.SplitHostPort(c.Request.RemoteAddr)
576 if err != nil {
577 return []string{c.Request.RemoteAddr}
578 }
579 return []string{ip}
580}
581
582// RemoteAddr returns the raw remote address of the client.
583func (c *Ctx) RemoteAddr() string {

Callers

nothing calls this directly

Calls 1

GetMethod · 0.45

Tested by

no test coverage detected