Commit 7ee4ea24 authored by Aaron Ellington's avatar Aaron Ellington

lint fixes

parent 705cb988
......@@ -768,7 +768,7 @@ func IsLoopback(addr string) bool {
// be an IP or an IP:port combination.
// Loopback addresses are considered false.
func IsInternal(addr string) bool {
private_networks := []string{
privateNetworks := []string{
"10.0.0.0/8",
"172.16.0.0/12",
"192.168.0.0/16",
......@@ -786,8 +786,8 @@ func IsInternal(addr string) bool {
if ip == nil {
return false
}
for _, private_network := range private_networks {
_, ipnet, _ := net.ParseCIDR(private_network)
for _, privateNetwork := range privateNetworks {
_, ipnet, _ := net.ParseCIDR(privateNetwork)
if ipnet.Contains(ip) {
return true
}
......
......@@ -156,10 +156,10 @@ func (l byNameDirFirst) Less(i, j int) bool {
// if both are dir or file sort normally
if l.Items[i].IsDir == l.Items[j].IsDir {
return strings.ToLower(l.Items[i].Name) < strings.ToLower(l.Items[j].Name)
} else {
// always sort dir ahead of file
return l.Items[i].IsDir
}
// always sort dir ahead of file
return l.Items[i].IsDir
}
// By Size
......
......@@ -161,11 +161,11 @@ func parseRawClientHello(data []byte) (info rawHelloInfo) {
if len(data) < 42 {
return
}
sessionIdLen := int(data[38])
if sessionIdLen > 32 || len(data) < 39+sessionIdLen {
sessionIDLen := int(data[38])
if sessionIDLen > 32 || len(data) < 39+sessionIDLen {
return
}
data = data[39+sessionIdLen:]
data = data[39+sessionIDLen:]
if len(data) < 2 {
return
}
......@@ -598,6 +598,7 @@ var greaseCiphers = map[uint16]struct{}{
0xFAFA: {},
}
// Define variables used for TLS communication
const (
extensionOCSPStatusRequest = 5
extensionSupportedCurves = 10 // also called "SupportedGroups"
......
......@@ -330,9 +330,9 @@ func (r *replacer) getSubstitution(key string) string {
if val, ok := r.request.Context().Value(caddy.CtxKey("mitm")).(bool); ok {
if val {
return "likely"
} else {
return "unlikely"
}
return "unlikely"
}
return "unknown"
case "{status}":
......
......@@ -232,8 +232,8 @@ func (c *Config) StorageFor(caURL string) (Storage, error) {
// buildStandardTLSConfig converts cfg (*caddytls.Config) to a *tls.Config
// and stores it in cfg so it can be used in servers. If TLS is disabled,
// no tls.Config is created.
func (cfg *Config) buildStandardTLSConfig() error {
if !cfg.Enabled {
func (c *Config) buildStandardTLSConfig() error {
if !c.Enabled {
return nil
}
......@@ -243,35 +243,35 @@ func (cfg *Config) buildStandardTLSConfig() error {
curvesAdded := make(map[tls.CurveID]struct{})
// add cipher suites
for _, ciph := range cfg.Ciphers {
for _, ciph := range c.Ciphers {
if _, ok := ciphersAdded[ciph]; !ok {
ciphersAdded[ciph] = struct{}{}
config.CipherSuites = append(config.CipherSuites, ciph)
}
}
config.PreferServerCipherSuites = cfg.PreferServerCipherSuites
config.PreferServerCipherSuites = c.PreferServerCipherSuites
// add curve preferences
for _, curv := range cfg.CurvePreferences {
for _, curv := range c.CurvePreferences {
if _, ok := curvesAdded[curv]; !ok {
curvesAdded[curv] = struct{}{}
config.CurvePreferences = append(config.CurvePreferences, curv)
}
}
config.MinVersion = cfg.ProtocolMinVersion
config.MaxVersion = cfg.ProtocolMaxVersion
config.ClientAuth = cfg.ClientAuth
config.NextProtos = cfg.ALPN
config.GetCertificate = cfg.GetCertificate
config.MinVersion = c.ProtocolMinVersion
config.MaxVersion = c.ProtocolMaxVersion
config.ClientAuth = c.ClientAuth
config.NextProtos = c.ALPN
config.GetCertificate = c.GetCertificate
// set up client authentication if enabled
if config.ClientAuth != tls.NoClientCert {
pool := x509.NewCertPool()
clientCertsAdded := make(map[string]struct{})
for _, caFile := range cfg.ClientCerts {
for _, caFile := range c.ClientCerts {
// don't add cert to pool more than once
if _, ok := clientCertsAdded[caFile]; ok {
continue
......@@ -303,7 +303,7 @@ func (cfg *Config) buildStandardTLSConfig() error {
}
// store the resulting new tls.Config
cfg.tlsConfig = config
c.tlsConfig = config
return nil
}
......
......@@ -217,6 +217,7 @@ func RegisterPlugin(name string, plugin Plugin) {
// EventName represents the name of an event used with event hooks.
type EventName string
// Define the event names for the startup and shutdown events
const (
StartupEvent EventName = "startup"
ShutdownEvent EventName = "shutdown"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment