mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 01:08:47 +02:00
refactor(config): reduce references to config.GetInstance()
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/yusing/godoxy/agent/pkg/agent"
|
||||
"github.com/yusing/godoxy/internal/docker"
|
||||
"github.com/yusing/godoxy/internal/homepage"
|
||||
homepagecfg "github.com/yusing/godoxy/internal/homepage/types"
|
||||
netutils "github.com/yusing/godoxy/internal/net"
|
||||
nettypes "github.com/yusing/godoxy/internal/net/types"
|
||||
"github.com/yusing/godoxy/internal/proxmox"
|
||||
@@ -22,7 +23,6 @@ import (
|
||||
"github.com/yusing/goutils/task"
|
||||
|
||||
"github.com/yusing/godoxy/internal/common"
|
||||
config "github.com/yusing/godoxy/internal/config/types"
|
||||
"github.com/yusing/godoxy/internal/logging/accesslog"
|
||||
"github.com/yusing/godoxy/internal/route/rules"
|
||||
route "github.com/yusing/godoxy/internal/route/types"
|
||||
@@ -676,7 +676,7 @@ func (r *Route) FinalizeHomepageConfig() {
|
||||
}
|
||||
|
||||
if hp.Category == "" {
|
||||
if config.GetInstance().Value().Homepage.UseDefaultCategories {
|
||||
if homepagecfg.ActiveConfig.Load().UseDefaultCategories {
|
||||
for _, ref := range refs {
|
||||
if category, ok := homepage.PredefinedCategories[ref]; ok {
|
||||
hp.Category = category
|
||||
|
||||
@@ -6,7 +6,8 @@ import (
|
||||
|
||||
"github.com/pires/go-proxyproto"
|
||||
"github.com/rs/zerolog"
|
||||
config "github.com/yusing/godoxy/internal/config/types"
|
||||
"github.com/yusing/godoxy/internal/acl"
|
||||
"github.com/yusing/godoxy/internal/entrypoint"
|
||||
nettypes "github.com/yusing/godoxy/internal/net/types"
|
||||
ioutils "github.com/yusing/goutils/io"
|
||||
"go.uber.org/atomic"
|
||||
@@ -43,10 +44,10 @@ func (s *TCPTCPStream) ListenAndServe(ctx context.Context, preDial, onRead netty
|
||||
return
|
||||
}
|
||||
|
||||
if proxyProto := config.GetInstance().Value().Entrypoint.SupportProxyProtocol; proxyProto {
|
||||
if proxyProto := entrypoint.ActiveConfig.Load().SupportProxyProtocol; proxyProto {
|
||||
s.listener = &proxyproto.Listener{Listener: s.listener}
|
||||
}
|
||||
if acl := config.GetInstance().Value().ACL; acl != nil {
|
||||
if acl := acl.ActiveConfig.Load(); acl != nil {
|
||||
s.listener = acl.WrapTCP(s.listener)
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
config "github.com/yusing/godoxy/internal/config/types"
|
||||
"github.com/yusing/godoxy/internal/acl"
|
||||
nettypes "github.com/yusing/godoxy/internal/net/types"
|
||||
"github.com/yusing/goutils/synk"
|
||||
"go.uber.org/atomic"
|
||||
@@ -74,7 +74,7 @@ func (s *UDPUDPStream) ListenAndServe(ctx context.Context, preDial, onRead netty
|
||||
logErr(s, err, "failed to listen")
|
||||
return
|
||||
}
|
||||
if acl := config.GetInstance().Value().ACL; acl != nil {
|
||||
if acl := acl.ActiveConfig.Load(); acl != nil {
|
||||
s.listener = acl.WrapUDP(s.listener)
|
||||
}
|
||||
s.preDial = preDial
|
||||
|
||||
Reference in New Issue
Block a user