24 lines
458 B
Go
24 lines
458 B
Go
package api
|
|
|
|
import (
|
|
"net/textproto"
|
|
|
|
"git.trj.tw/golang/go-ddns-svc/module/config"
|
|
"git.trj.tw/golang/go-ddns-svc/module/context"
|
|
)
|
|
|
|
// VerifyPrivate -
|
|
func VerifyPrivate(c *context.Context) {
|
|
privateHeader := c.Request.Header.Get(textproto.CanonicalMIMEHeaderKey("x-mtfos-key"))
|
|
if len(privateHeader) == 0 {
|
|
c.Forbidden(nil)
|
|
return
|
|
}
|
|
conf := config.GetConfig()
|
|
if privateHeader != conf.VerifyValue {
|
|
c.Forbidden(nil)
|
|
return
|
|
}
|
|
c.Next()
|
|
}
|