mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-09 09:06:36 +08:00
refactor(pkg): merge pkg/utils into pkg/util
Consolidate pure helper packages under pkg/util and update imports.
This commit is contained in:
@@ -135,7 +135,7 @@
|
|||||||
- `pkg/push/`:推送渠道客户端集成(Lark/Telegram/Email)。
|
- `pkg/push/`:推送渠道客户端集成(Lark/Telegram/Email)。
|
||||||
- `pkg/mail/`:邮件发送客户端。
|
- `pkg/mail/`:邮件发送客户端。
|
||||||
- `pkg/trace/`:OpenTelemetry 链路追踪配置。
|
- `pkg/trace/`:OpenTelemetry 链路追踪配置。
|
||||||
- `pkg/util/`:纯底层无副作用的系统工具(Crypto/Password/UUID)。
|
- `pkg/util/`:纯底层无副作用的系统工具(Crypto/Password/UUID、格式化、网络、版本比较等)。
|
||||||
|
|
||||||
前端目录:
|
前端目录:
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Rain-kl/Wavelet/internal/apps/edge/nodeip"
|
"github.com/Rain-kl/Wavelet/internal/apps/edge/nodeip"
|
||||||
"github.com/Rain-kl/Wavelet/pkg/utils"
|
"github.com/Rain-kl/Wavelet/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -147,7 +147,7 @@ func Load(path string) (*Config, error) {
|
|||||||
func applyDefaults(cfg *Config, baseDir string) {
|
func applyDefaults(cfg *Config, baseDir string) {
|
||||||
baseDir = filepath.Clean(baseDir)
|
baseDir = filepath.Clean(baseDir)
|
||||||
cfg.Version = Version
|
cfg.Version = Version
|
||||||
cfg.OpenrestyResolvers = utils.UniqueAndCleanStringSlice(cfg.OpenrestyResolvers)
|
cfg.OpenrestyResolvers = util.UniqueAndCleanStringSlice(cfg.OpenrestyResolvers)
|
||||||
applyAgentIdentityDefaults(cfg)
|
applyAgentIdentityDefaults(cfg)
|
||||||
applyAgentPathDefaults(cfg, baseDir)
|
applyAgentPathDefaults(cfg, baseDir)
|
||||||
applyAgentTimingDefaults(cfg)
|
applyAgentTimingDefaults(cfg)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import (
|
|||||||
|
|
||||||
sharedprotocol "github.com/Rain-kl/Wavelet/pkg/protocol"
|
sharedprotocol "github.com/Rain-kl/Wavelet/pkg/protocol"
|
||||||
openrestyrender "github.com/Rain-kl/Wavelet/pkg/render/openresty"
|
openrestyrender "github.com/Rain-kl/Wavelet/pkg/render/openresty"
|
||||||
"github.com/Rain-kl/Wavelet/pkg/utils"
|
"github.com/Rain-kl/Wavelet/pkg/util"
|
||||||
|
|
||||||
"github.com/Rain-kl/Wavelet/internal/apps/agent/protocol"
|
"github.com/Rain-kl/Wavelet/internal/apps/agent/protocol"
|
||||||
"github.com/Rain-kl/Wavelet/internal/apps/agent/runtimeuser"
|
"github.com/Rain-kl/Wavelet/internal/apps/agent/runtimeuser"
|
||||||
@@ -1506,7 +1506,7 @@ func ResolverDirective(explicitResolvers []string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func resolverAddresses(explicitResolvers []string) []string {
|
func resolverAddresses(explicitResolvers []string) []string {
|
||||||
if resolvers := utils.UniqueAndCleanStringSlice(explicitResolvers); len(resolvers) > 0 {
|
if resolvers := util.UniqueAndCleanStringSlice(explicitResolvers); len(resolvers) > 0 {
|
||||||
return resolvers
|
return resolvers
|
||||||
}
|
}
|
||||||
data, err := os.ReadFile("/etc/resolv.conf")
|
data, err := os.ReadFile("/etc/resolv.conf")
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Rain-kl/Wavelet/pkg/utils"
|
"github.com/Rain-kl/Wavelet/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -418,5 +418,5 @@ func buildReleaseCheckKey(options UpdateOptions, remoteVersion string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func compareVersions(local string, remote string) int {
|
func compareVersions(local string, remote string) int {
|
||||||
return utils.CompareVersions(local, remote)
|
return util.CompareVersions(local, remote)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import (
|
|||||||
|
|
||||||
ofws "github.com/Rain-kl/Wavelet/internal/apps/openflare/websocket"
|
ofws "github.com/Rain-kl/Wavelet/internal/apps/openflare/websocket"
|
||||||
"github.com/Rain-kl/Wavelet/internal/model"
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
"github.com/Rain-kl/Wavelet/pkg/utils"
|
"github.com/Rain-kl/Wavelet/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -301,7 +301,7 @@ func isVersionNewer(current string, latest string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func compareVersions(local, remote string) int {
|
func compareVersions(local, remote string) int {
|
||||||
return utils.CompareVersions(local, remote)
|
return util.CompareVersions(local, remote)
|
||||||
}
|
}
|
||||||
|
|
||||||
func fetchLatestGitHubRelease(ctx context.Context, repo string, channel releaseChannel) (*githubReleaseResponse, error) {
|
func fetchLatestGitHubRelease(ctx context.Context, repo string, channel releaseChannel) (*githubReleaseResponse, error) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Package utils provides shared formatting and string helper functions.
|
// Package util provides shared formatting and string helper functions.
|
||||||
package utils
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package utils
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package utils
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log/slog"
|
"log/slog"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package utils
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package utils
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sort"
|
"sort"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package utils
|
package util
|
||||||
|
|
||||||
import "strings"
|
import "strings"
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package utils
|
package util
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package utils
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package utils
|
package util
|
||||||
|
|
||||||
import "strconv"
|
import "strconv"
|
||||||
|
|
||||||
Reference in New Issue
Block a user