refactor: rename net/types to nettypes

This commit is contained in:
yusing
2025-06-08 17:59:48 +08:00
parent 01773976d1
commit 421aaecba4
26 changed files with 79 additions and 97 deletions

View File

@@ -16,7 +16,7 @@ import (
loadbalance "github.com/yusing/go-proxy/internal/net/gphttp/loadbalancer/types"
"github.com/yusing/go-proxy/internal/net/gphttp/middleware"
"github.com/yusing/go-proxy/internal/net/gphttp/reverseproxy"
"github.com/yusing/go-proxy/internal/net/types"
nettypes "github.com/yusing/go-proxy/internal/net/types"
"github.com/yusing/go-proxy/internal/route/routes"
"github.com/yusing/go-proxy/internal/task"
"github.com/yusing/go-proxy/internal/watcher/health/monitor"
@@ -42,7 +42,7 @@ func NewReverseProxyRoute(base *Route) (*ReveseProxyRoute, gperr.Error) {
a := base.Agent()
if a != nil {
trans = a.Transport()
proxyURL = types.NewURL(agent.HTTPProxyURL)
proxyURL = nettypes.NewURL(agent.HTTPProxyURL)
} else {
trans = gphttp.NewTransport()
if httpConfig.NoTLSVerify {

View File

@@ -7,13 +7,13 @@ import (
"github.com/yusing/go-proxy/internal/docker"
"github.com/yusing/go-proxy/internal/homepage"
idlewatcher "github.com/yusing/go-proxy/internal/idlewatcher/types"
net "github.com/yusing/go-proxy/internal/net/types"
"github.com/yusing/go-proxy/internal/task"
"github.com/yusing/go-proxy/internal/utils/pool"
"github.com/yusing/go-proxy/internal/watcher/health"
loadbalance "github.com/yusing/go-proxy/internal/net/gphttp/loadbalancer/types"
"github.com/yusing/go-proxy/internal/net/gphttp/reverseproxy"
nettypes "github.com/yusing/go-proxy/internal/net/types"
)
type (
@@ -24,7 +24,7 @@ type (
pool.Object
ProviderName() string
GetProvider() Provider
TargetURL() *net.URL
TargetURL() *nettypes.URL
HealthMonitor() health.HealthMonitor
SetHealthMonitor(m health.HealthMonitor)
References() []string
@@ -57,7 +57,7 @@ type (
}
StreamRoute interface {
Route
net.Stream
nettypes.Stream
}
Provider interface {
GetRoute(alias string) (r Route, ok bool)

View File

@@ -9,7 +9,7 @@ import (
"github.com/yusing/go-proxy/internal/gperr"
gphttp "github.com/yusing/go-proxy/internal/net/gphttp"
"github.com/yusing/go-proxy/internal/net/gphttp/reverseproxy"
"github.com/yusing/go-proxy/internal/net/types"
nettypes "github.com/yusing/go-proxy/internal/net/types"
"github.com/yusing/go-proxy/internal/utils/strutils"
)
@@ -95,7 +95,7 @@ var commands = map[string]struct {
},
validate: validateURL,
build: func(args any) CommandHandler {
target := args.(*types.URL).String()
target := args.(*nettypes.URL).String()
return ReturningCommand(func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, target, http.StatusTemporaryRedirect)
})
@@ -160,7 +160,7 @@ var commands = map[string]struct {
},
validate: validateAbsoluteURL,
build: func(args any) CommandHandler {
target := args.(*types.URL)
target := args.(*nettypes.URL)
if target.Scheme == "" {
target.Scheme = "http"
}

View File

@@ -8,7 +8,7 @@ import (
"github.com/gobwas/glob"
"github.com/yusing/go-proxy/internal/gperr"
"github.com/yusing/go-proxy/internal/net/types"
nettypes "github.com/yusing/go-proxy/internal/net/types"
"github.com/yusing/go-proxy/internal/route/routes"
"github.com/yusing/go-proxy/internal/utils/strutils"
)
@@ -205,7 +205,7 @@ var checkers = map[string]struct {
},
validate: validateCIDR,
builder: func(args any) CheckFunc {
cidr := args.(types.CIDR)
cidr := args.(nettypes.CIDR)
return func(cached Cache, r *http.Request) bool {
ip := cached.GetRemoteIP(r)
if ip == nil {

View File

@@ -10,7 +10,7 @@ import (
"github.com/gobwas/glob"
"github.com/yusing/go-proxy/internal/gperr"
gphttp "github.com/yusing/go-proxy/internal/net/gphttp"
"github.com/yusing/go-proxy/internal/net/types"
nettypes "github.com/yusing/go-proxy/internal/net/types"
)
type (
@@ -62,7 +62,7 @@ func validateURL(args []string) (any, gperr.Error) {
if len(args) != 1 {
return nil, ErrExpectOneArg
}
u, err := types.ParseURL(args[0])
u, err := nettypes.ParseURL(args[0])
if err != nil {
return nil, ErrInvalidArguments.With(err)
}
@@ -74,7 +74,7 @@ func validateAbsoluteURL(args []string) (any, gperr.Error) {
if len(args) != 1 {
return nil, ErrExpectOneArg
}
u, err := types.ParseURL(args[0])
u, err := nettypes.ParseURL(args[0])
if err != nil {
return nil, ErrInvalidArguments.With(err)
}
@@ -95,7 +95,7 @@ func validateCIDR(args []string) (any, gperr.Error) {
if !strings.Contains(args[0], "/") {
args[0] += "/32"
}
cidr, err := types.ParseCIDR(args[0])
cidr, err := nettypes.ParseCIDR(args[0])
if err != nil {
return nil, ErrInvalidArguments.With(err)
}

View File

@@ -8,7 +8,7 @@ import (
"github.com/rs/zerolog/log"
"github.com/yusing/go-proxy/internal/gperr"
"github.com/yusing/go-proxy/internal/idlewatcher"
net "github.com/yusing/go-proxy/internal/net/types"
nettypes "github.com/yusing/go-proxy/internal/net/types"
"github.com/yusing/go-proxy/internal/route/routes"
"github.com/yusing/go-proxy/internal/task"
"github.com/yusing/go-proxy/internal/watcher/health/monitor"
@@ -17,7 +17,7 @@ import (
// TODO: support stream load balance.
type StreamRoute struct {
*Route
net.Stream `json:"-"`
nettypes.Stream `json:"-"`
l zerolog.Logger
}