only allow admin access via unix socket

This commit is contained in:
ston1th 2023-03-15 12:54:21 +01:00
commit 13780f1c74
5 changed files with 73 additions and 16 deletions

View file

@ -40,6 +40,8 @@ type Context struct {
Data *ContextData
Log logr.Logger
ip string
}
// Method returns the request method
@ -69,7 +71,15 @@ func (c *Context) Form(name string) string {
}
func (c *Context) ClientIP() (host string) {
host, _, _ = net.SplitHostPort(c.Request.RemoteAddr)
host = c.Request.RemoteAddr
if host == "@" {
return
}
if c.ip != "" {
return c.ip
}
host, _, _ = net.SplitHostPort(host)
c.ip = host
return
}