mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-24 18:11:19 +01:00
chore: apply golangci-lint fmt
This commit is contained in:
@@ -21,8 +21,10 @@ const (
|
||||
|
||||
var version = [versionSize]byte{'0', '.', '1', '.', '0', 0, 0, 0}
|
||||
|
||||
var ErrInvalidHeader = errors.New("invalid header")
|
||||
var ErrCloseImmediately = errors.New("close immediately")
|
||||
var (
|
||||
ErrInvalidHeader = errors.New("invalid header")
|
||||
ErrCloseImmediately = errors.New("close immediately")
|
||||
)
|
||||
|
||||
type FlagType uint8
|
||||
|
||||
|
||||
@@ -45,9 +45,10 @@ func TestTLSALPNMux_HTTPAndStreamShareOnePort(t *testing.T) {
|
||||
defer func() { _ = tlsLn.Close() }()
|
||||
|
||||
// HTTP server
|
||||
httpSrv := &http.Server{Handler: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
_, _ = w.Write([]byte("ok"))
|
||||
}),
|
||||
httpSrv := &http.Server{
|
||||
Handler: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
_, _ = w.Write([]byte("ok"))
|
||||
}),
|
||||
TLSNextProto: map[string]func(*http.Server, *tls.Conn, http.Handler){
|
||||
stream.StreamALPN: func(_ *http.Server, conn *tls.Conn, _ http.Handler) {
|
||||
streamSrv.ServeConn(conn)
|
||||
|
||||
@@ -102,7 +102,6 @@ func TestUDPServer_RejectInvalidClient(t *testing.T) {
|
||||
|
||||
srv := startUDPServer(t, certs)
|
||||
|
||||
|
||||
// Try to connect with a client cert from a different CA
|
||||
_, err = stream.NewUDPClient(srv.Addr.String(), dstAddr, certs.CaCert, invalidClientCert)
|
||||
require.Error(t, err, "expected error when connecting with client cert from different CA")
|
||||
|
||||
@@ -2,13 +2,14 @@ package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"math/rand/v2"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var printables = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||
var random = make([]byte, 4096)
|
||||
var (
|
||||
printables = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||
random = make([]byte, 4096)
|
||||
)
|
||||
|
||||
func init() {
|
||||
for i := range random {
|
||||
|
||||
@@ -23,33 +23,35 @@ import (
|
||||
strutils "github.com/yusing/goutils/strings"
|
||||
)
|
||||
|
||||
type ConfigExtra Config
|
||||
type Config struct {
|
||||
Email string `json:"email,omitempty"`
|
||||
Domains []string `json:"domains,omitempty"`
|
||||
CertPath string `json:"cert_path,omitempty"`
|
||||
KeyPath string `json:"key_path,omitempty"`
|
||||
Extra []ConfigExtra `json:"extra,omitempty"`
|
||||
ACMEKeyPath string `json:"acme_key_path,omitempty"` // shared by all extra providers with the same CA directory URL
|
||||
Provider string `json:"provider,omitempty"`
|
||||
Options map[string]strutils.Redacted `json:"options,omitempty"`
|
||||
type (
|
||||
ConfigExtra Config
|
||||
Config struct {
|
||||
Email string `json:"email,omitempty"`
|
||||
Domains []string `json:"domains,omitempty"`
|
||||
CertPath string `json:"cert_path,omitempty"`
|
||||
KeyPath string `json:"key_path,omitempty"`
|
||||
Extra []ConfigExtra `json:"extra,omitempty"`
|
||||
ACMEKeyPath string `json:"acme_key_path,omitempty"` // shared by all extra providers with the same CA directory URL
|
||||
Provider string `json:"provider,omitempty"`
|
||||
Options map[string]strutils.Redacted `json:"options,omitempty"`
|
||||
|
||||
Resolvers []string `json:"resolvers,omitempty"`
|
||||
Resolvers []string `json:"resolvers,omitempty"`
|
||||
|
||||
// Custom ACME CA
|
||||
CADirURL string `json:"ca_dir_url,omitempty"`
|
||||
CACerts []string `json:"ca_certs,omitempty"`
|
||||
// Custom ACME CA
|
||||
CADirURL string `json:"ca_dir_url,omitempty"`
|
||||
CACerts []string `json:"ca_certs,omitempty"`
|
||||
|
||||
// EAB
|
||||
EABKid string `json:"eab_kid,omitempty" validate:"required_with=EABHmac"`
|
||||
EABHmac string `json:"eab_hmac,omitempty" validate:"required_with=EABKid"` // base64 encoded
|
||||
// EAB
|
||||
EABKid string `json:"eab_kid,omitempty" validate:"required_with=EABHmac"`
|
||||
EABHmac string `json:"eab_hmac,omitempty" validate:"required_with=EABKid"` // base64 encoded
|
||||
|
||||
HTTPClient *http.Client `json:"-"` // for tests only
|
||||
HTTPClient *http.Client `json:"-"` // for tests only
|
||||
|
||||
challengeProvider challenge.Provider
|
||||
challengeProvider challenge.Provider
|
||||
|
||||
idx int // 0: main, 1+: extra[i]
|
||||
}
|
||||
idx int // 0: main, 1+: extra[i]
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
ErrMissingField = gperr.New("missing field")
|
||||
|
||||
@@ -68,7 +68,7 @@ func TestMultipleCertificatesLifecycle(t *testing.T) {
|
||||
require.Equal(t, "custom", cfg.Extra[1].Provider)
|
||||
|
||||
/* track cert requests for all configs */
|
||||
os.MkdirAll("certs", 0755)
|
||||
os.MkdirAll("certs", 0o755)
|
||||
defer os.RemoveAll("certs")
|
||||
|
||||
err = provider.ObtainCertIfNotExistsAll()
|
||||
|
||||
@@ -24,6 +24,7 @@ var h2cClient = &http.Client{
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
var pinger = &fasthttp.Client{
|
||||
MaxConnDuration: 0,
|
||||
DisableHeaderNamesNormalizing: true,
|
||||
|
||||
@@ -21,7 +21,8 @@ var stdoutLogger = func() *zerolog.Logger {
|
||||
w.FieldsOrder = []string{
|
||||
"uri", "protocol", "type", "size",
|
||||
"useragent", "query", "headers", "cookies",
|
||||
"error", "iso_code", "time_zone"}
|
||||
"error", "iso_code", "time_zone",
|
||||
}
|
||||
})).With().Str("level", zerolog.InfoLevel.String()).Timestamp().Logger()
|
||||
return &l
|
||||
}()
|
||||
|
||||
@@ -63,8 +63,10 @@ const (
|
||||
errBurst = 5
|
||||
)
|
||||
|
||||
var bytesPool = synk.GetUnsizedBytesPool()
|
||||
var sizedPool = synk.GetSizedBytesPool()
|
||||
var (
|
||||
bytesPool = synk.GetUnsizedBytesPool()
|
||||
sizedPool = synk.GetSizedBytesPool()
|
||||
)
|
||||
|
||||
func NewFileAccessLogger(parent task.Parent, file File, anyCfg AnyConfig) AccessLogger {
|
||||
cfg := anyCfg.ToConfig()
|
||||
|
||||
@@ -19,8 +19,10 @@ type ipHash struct {
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
var _ impl = (*ipHash)(nil)
|
||||
var _ customServeHTTP = (*ipHash)(nil)
|
||||
var (
|
||||
_ impl = (*ipHash)(nil)
|
||||
_ customServeHTTP = (*ipHash)(nil)
|
||||
)
|
||||
|
||||
func (lb *LoadBalancer) newIPHash() impl {
|
||||
impl := &ipHash{LoadBalancer: lb}
|
||||
|
||||
@@ -13,8 +13,10 @@ type leastConn struct {
|
||||
nConn *xsync.Map[types.LoadBalancerServer, *atomic.Int64]
|
||||
}
|
||||
|
||||
var _ impl = (*leastConn)(nil)
|
||||
var _ customServeHTTP = (*leastConn)(nil)
|
||||
var (
|
||||
_ impl = (*leastConn)(nil)
|
||||
_ customServeHTTP = (*leastConn)(nil)
|
||||
)
|
||||
|
||||
func (lb *LoadBalancer) newLeastConn() impl {
|
||||
return &leastConn{
|
||||
|
||||
@@ -523,11 +523,11 @@ func TestHTTPFlow_ServeCommand(t *testing.T) {
|
||||
// The path /files/index.html gets mapped to tempDir + "/files/index.html"
|
||||
// We need to create the file at the expected path
|
||||
filesDir := filepath.Join(tempDir, "files")
|
||||
err = os.Mkdir(filesDir, 0755)
|
||||
err = os.Mkdir(filesDir, 0o755)
|
||||
require.NoError(t, err)
|
||||
|
||||
filesIndexFile := filepath.Join(filesDir, "index.html")
|
||||
err = os.WriteFile(filesIndexFile, []byte("<h1>Test Page</h1>"), 0644)
|
||||
err = os.WriteFile(filesIndexFile, []byte("<h1>Test Page</h1>"), 0o644)
|
||||
require.NoError(t, err)
|
||||
|
||||
req1 := httptest.NewRequest(http.MethodGet, "/files/index.html", nil)
|
||||
|
||||
@@ -46,7 +46,7 @@ func BenchmarkRules(b *testing.B) {
|
||||
})
|
||||
|
||||
b.Run("RunHandler", func(b *testing.B) {
|
||||
var r = &http.Request{
|
||||
r := &http.Request{
|
||||
Body: io.NopCloser(bytes.NewReader([]byte(""))),
|
||||
URL: &url.URL{Path: "/api/users/"},
|
||||
}
|
||||
@@ -59,8 +59,7 @@ func BenchmarkRules(b *testing.B) {
|
||||
})
|
||||
}
|
||||
|
||||
type noopResponseWriter struct {
|
||||
}
|
||||
type noopResponseWriter struct{}
|
||||
|
||||
func (w noopResponseWriter) Header() http.Header {
|
||||
return http.Header{}
|
||||
|
||||
@@ -61,7 +61,7 @@ func (cfg *DockerProviderConfig) Parse(value string) error {
|
||||
|
||||
func (cfg *DockerProviderConfig) UnmarshalMap(m map[string]any) error {
|
||||
var tmp DockerProviderConfigDetailed
|
||||
var err = serialization.MapUnmarshalValidate(m, &tmp)
|
||||
err := serialization.MapUnmarshalValidate(m, &tmp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user