代码拉取完成,页面将自动刷新
package main
import (
"log"
"net/http"
"github.com/sirupsen/logrus"
"github.com/stripe/smokescreen/cmd"
"github.com/stripe/smokescreen/pkg/smokescreen"
)
// This default implementation of RoleFromRequest uses the CommonName of the
// client's certificate. If no certificate is provided, the AllowMissingRole
// configuration option will control whether the request is rejected, or the
// default ACL is applied.
func defaultRoleFromRequest(req *http.Request) (string, error) {
if req.TLS == nil {
return "", smokescreen.MissingRoleError("defaultRoleFromRequest requires TLS")
}
if len(req.TLS.PeerCertificates) == 0 {
return "", smokescreen.MissingRoleError("client did not provide certificate")
}
return req.TLS.PeerCertificates[0].Subject.CommonName, nil
}
func main() {
conf, err := cmd.NewConfiguration(nil, nil)
if err != nil {
logrus.Fatalf("Could not create configuration: %v", err)
} else if conf != nil {
conf.RoleFromRequest = defaultRoleFromRequest
conf.Log.Formatter = &logrus.JSONFormatter{}
adapter := &smokescreen.Log2LogrusWriter{
Entry: conf.Log.WithField("stdlog", "1"),
}
// Set the standard logger to use our logger's writer as output.
log.SetOutput(adapter)
log.SetFlags(0)
smokescreen.StartWithConfig(conf, nil)
}
// Otherwise, --help or --version was passed and handled by NewConfiguration, so do nothing
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。