summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorLoyalsoldier <[email protected]>2024-07-06 18:59:43 +0800
committerLoyalsoldier <[email protected]>2024-07-06 18:59:43 +0800
commit8c55b323a91acff7cc7f839a371ec9510fe60039 (patch)
treea3d135dfb05b699489c24ea658fdae691ee43f1e /plugin
parente3800440ce05aa1b8f27d56f47bbeef20f9499c6 (diff)
Chore: refine code
Diffstat (limited to 'plugin')
-rw-r--r--plugin/special/stdout.go32
-rw-r--r--plugin/v2ray/dat_out.go6
2 files changed, 12 insertions, 26 deletions
diff --git a/plugin/special/stdout.go b/plugin/special/stdout.go
index 736d642f..9437e597 100644
--- a/plugin/special/stdout.go
+++ b/plugin/special/stdout.go
@@ -74,31 +74,17 @@ func (s *stdout) Output(container lib.Container) error {
}
}
- switch len(wantList) {
- case 0:
- for entry := range container.Loop() {
- cidrList, err := s.generateCIDRList(entry)
- if err != nil {
- continue
- }
- for _, cidr := range cidrList {
- io.WriteString(os.Stdout, cidr+"\n")
- }
+ for entry := range container.Loop() {
+ if len(wantList) > 0 && !wantList[entry.GetName()] {
+ continue
}
- default:
- for name := range wantList {
- entry, found := container.GetEntry(name)
- if !found {
- continue
- }
- cidrList, err := s.generateCIDRList(entry)
- if err != nil {
- continue
- }
- for _, cidr := range cidrList {
- io.WriteString(os.Stdout, cidr+"\n")
- }
+ cidrList, err := s.generateCIDRList(entry)
+ if err != nil {
+ continue
+ }
+ for _, cidr := range cidrList {
+ io.WriteString(os.Stdout, cidr+"\n")
}
}
diff --git a/plugin/v2ray/dat_out.go b/plugin/v2ray/dat_out.go
index 345b85ce..46e3baa2 100644
--- a/plugin/v2ray/dat_out.go
+++ b/plugin/v2ray/dat_out.go
@@ -155,10 +155,10 @@ func (g *geoIPDatOut) Output(container lib.Container) error {
}
}
- // Sort to make reproducible builds
- g.sort(geoIPList)
-
if !g.OneFilePerList && updated {
+ // Sort to make reproducible builds
+ g.sort(geoIPList)
+
geoIPBytes, err := proto.Marshal(geoIPList)
if err != nil {
return err