refactor: move task, error and testing utils to separte repo; apply gofumpt

This commit is contained in:
yusing
2025-09-27 13:41:50 +08:00
parent 5043ef778f
commit 6776f20332
203 changed files with 696 additions and 2800 deletions

View File

@@ -2,15 +2,16 @@ package agent
import (
"iter"
"os"
"strings"
"github.com/puzpuzpuz/xsync/v4"
"github.com/yusing/godoxy/internal/common"
)
var agentPool = xsync.NewMap[string, *AgentConfig](xsync.WithPresize(10))
func init() {
if common.IsTest {
if strings.HasSuffix(os.Args[0], ".test") {
agentPool.Store("test-agent", &AgentConfig{
Addr: "test-agent",
})
@@ -63,5 +64,5 @@ func NumAgents() int {
func getAgentByAddr(addr string) (agent *AgentConfig, ok bool) {
agent, ok = agentPool.Load(addr)
return
return agent, ok
}

View File

@@ -3,6 +3,8 @@ package agent
import (
"crypto/aes"
"crypto/cipher"
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"crypto/tls"
"crypto/x509"
@@ -10,14 +12,11 @@ import (
"encoding/base64"
"encoding/pem"
"errors"
"fmt"
"io"
"math/big"
"strings"
"time"
"crypto/ecdsa"
"crypto/elliptic"
"fmt"
)
const (
@@ -244,5 +243,5 @@ func NewAgent() (ca, srv, client *PEMPair, err error) {
}
client = toPEMPair(clientCertDER, clientKey)
return
return ca, srv, client, err
}

View File

@@ -43,7 +43,7 @@ func proxyConfigFromHeadersLegacy(h http.Header) (cfg Config) {
cfg.Scheme = "https"
}
return
return cfg
}
func proxyConfigFromHeaders(h http.Header) (cfg Config, err error) {

View File

@@ -10,7 +10,7 @@ import (
"github.com/yusing/godoxy/agent/pkg/env"
"github.com/yusing/godoxy/agent/pkg/handler"
"github.com/yusing/godoxy/internal/net/gphttp/server"
"github.com/yusing/godoxy/internal/task"
"github.com/yusing/goutils/task"
)
type Options struct {