mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-23 09:31:02 +01:00
refactor: rename net/types to nettypes
This commit is contained in:
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user