diff --git a/cli/cli.go b/cli/cli.go index db3f024..0321852 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -4,7 +4,7 @@ import ( "flag" Mirrors "github.com/soulteary/apt-proxy/internal/mirrors" - "github.com/soulteary/apt-proxy/state" + State "github.com/soulteary/apt-proxy/internal/state" ) const ( @@ -52,9 +52,9 @@ func ParseFlags() (appFlags AppFlags) { appFlags.Listen = host + ":" + port appFlags.Version = Version - state.SetProxyMode(mode) - state.SetDebianMirror(appFlags.Debian) - state.SetUbuntuMirror(appFlags.Ubuntu) + State.SetProxyMode(mode) + State.SetDebianMirror(appFlags.Debian) + State.SetUbuntuMirror(appFlags.Ubuntu) return appFlags } diff --git a/internal/rewriter/rewriter.go b/internal/rewriter/rewriter.go index 70d6682..c80ea47 100644 --- a/internal/rewriter/rewriter.go +++ b/internal/rewriter/rewriter.go @@ -8,7 +8,7 @@ import ( Benchmark "github.com/soulteary/apt-proxy/internal/benchmark" Mirrors "github.com/soulteary/apt-proxy/internal/mirrors" - "github.com/soulteary/apt-proxy/state" + State "github.com/soulteary/apt-proxy/internal/state" ) type URLRewriters struct { @@ -36,7 +36,7 @@ func GetRewriteRulesByMode(mode int) (rules []Mirrors.Rule) { func getRewriterForDebian() *URLRewriter { u := &URLRewriter{} - debianMirror := state.GetDebianMirror() + debianMirror := State.GetDebianMirror() benchmarkUrl, pattern := Mirrors.GetPredefinedConfiguration(Mirrors.TYPE_LINUX_DISTROS_DEBIAN) u.pattern = pattern @@ -62,7 +62,7 @@ func getRewriterForDebian() *URLRewriter { func getRewriterForUbuntu() *URLRewriter { u := &URLRewriter{} - ubuntuMirror := state.GetUbuntuMirror() + ubuntuMirror := State.GetUbuntuMirror() benchmarkUrl, pattern := Mirrors.GetPredefinedConfiguration(Mirrors.TYPE_LINUX_DISTROS_UBUNTU) u.pattern = pattern diff --git a/internal/rewriter/rewriter_test.go b/internal/rewriter/rewriter_test.go index ffd6803..92cf2e8 100644 --- a/internal/rewriter/rewriter_test.go +++ b/internal/rewriter/rewriter_test.go @@ -7,7 +7,7 @@ import ( Benchmark "github.com/soulteary/apt-proxy/internal/benchmark" Mirrors "github.com/soulteary/apt-proxy/internal/mirrors" - "github.com/soulteary/apt-proxy/state" + State "github.com/soulteary/apt-proxy/internal/state" ) func TestGetRewriteRulesByMode(t *testing.T) { @@ -81,7 +81,7 @@ func TestCreateNewRewritersForAll(t *testing.T) { } func TestCreateNewRewritersWithSpecifyMirror(t *testing.T) { - state.SetUbuntuMirror("https://mirrors.tuna.tsinghua.edu.cn/ubuntu/") + State.SetUbuntuMirror("https://mirrors.tuna.tsinghua.edu.cn/ubuntu/") ap := *CreateNewRewriters(Mirrors.TYPE_LINUX_DISTROS_UBUNTU) if ap.ubuntu.mirror.Host != "mirrors.tuna.tsinghua.edu.cn" { @@ -92,7 +92,7 @@ func TestCreateNewRewritersWithSpecifyMirror(t *testing.T) { t.Fatal("mirror path incorrect") } - state.ResetUbuntuMirror() + State.ResetUbuntuMirror() } func TestMatchingRule(t *testing.T) { diff --git a/internal/server/proxy.go b/internal/server/proxy.go index d3a2642..1a3d902 100644 --- a/internal/server/proxy.go +++ b/internal/server/proxy.go @@ -8,7 +8,7 @@ import ( Mirrors "github.com/soulteary/apt-proxy/internal/mirrors" Rewriter "github.com/soulteary/apt-proxy/internal/rewriter" - "github.com/soulteary/apt-proxy/state" + State "github.com/soulteary/apt-proxy/internal/state" ) var rewriter *Rewriter.URLRewriters @@ -25,7 +25,7 @@ type AptProxy struct { } func CreateAptProxyRouter() *AptProxy { - mode := state.GetProxyMode() + mode := State.GetProxyMode() rewriter = Rewriter.CreateNewRewriters(mode) return &AptProxy{ diff --git a/state/state.go b/internal/state/state.go similarity index 100% rename from state/state.go rename to internal/state/state.go diff --git a/state/state_test.go b/internal/state/state_test.go similarity index 100% rename from state/state_test.go rename to internal/state/state_test.go