diff options
| author | copilot-swe-agent[bot] <[email protected]> | 2026-03-09 06:35:47 +0000 |
|---|---|---|
| committer | copilot-swe-agent[bot] <[email protected]> | 2026-03-09 06:35:47 +0000 |
| commit | 2600825c50d7e7f2b4427674f1aefca270bcca27 (patch) | |
| tree | 18f216c6af28fd3975a0665d75ccf7b5c0078cb6 /plugin/maxmind/common_out.go | |
| parent | 5a14eb90f575b983aa407341af91aa7654e65f12 (diff) | |
Refactor: all plugin subdirectories use option patterncopilot/modify-plugin-files-subdirectories
Apply the same functional options pattern from plugin/singbox to:
- plugin/mihomo (mrs_in.go, mrs_out.go)
- plugin/plaintext (text_in.go, common_in.go, common_out.go, text_out.go, clash_in.go, clash_out.go, json_in.go, surge_in.go, surge_out.go)
- plugin/maxmind (all input/output files)
- plugin/v2ray (dat_in.go, dat_out.go)
- plugin/special (cutter.go, lookup.go, private.go, stdin.go, stdout.go)
- lookup.go and merge.go updated to use new constructors
Co-authored-by: Loyalsoldier <[email protected]>
Diffstat (limited to 'plugin/maxmind/common_out.go')
| -rw-r--r-- | plugin/maxmind/common_out.go | 44 |
1 files changed, 12 insertions, 32 deletions
diff --git a/plugin/maxmind/common_out.go b/plugin/maxmind/common_out.go index 21063faa..4ad8b909 100644 --- a/plugin/maxmind/common_out.go +++ b/plugin/maxmind/common_out.go @@ -100,7 +100,7 @@ func (d dbipCountry) HasData() bool { return d != zeroDBIPCountry } -func newGeoLite2CountryMMDBOut(iType string, iDesc string, action lib.Action, data json.RawMessage) (lib.OutputConverter, error) { +func NewGeoLite2CountryMMDBOutFromBytes(iType string, iDesc string, action lib.Action, data json.RawMessage) (lib.OutputConverter, error) { var tmp struct { OutputName string `json:"outputName"` OutputDir string `json:"outputDir"` @@ -118,39 +118,19 @@ func newGeoLite2CountryMMDBOut(iType string, iDesc string, action lib.Action, da } } - if tmp.OutputName == "" { - tmp.OutputName = defaultGeoLite2CountryMMDBOutputName - } - - if tmp.OutputDir == "" { - switch iType { - case TypeGeoLite2CountryMMDBOut: - tmp.OutputDir = defaultMaxmindOutputDir - - case TypeDBIPCountryMMDBOut: - tmp.OutputDir = defaultDBIPOutputDir - - case TypeIPInfoCountryMMDBOut: - tmp.OutputDir = defaultIPInfoOutputDir - } - } - - return &GeoLite2CountryMMDBOut{ - Type: iType, - Action: action, - Description: iDesc, - OutputName: tmp.OutputName, - OutputDir: tmp.OutputDir, - Want: tmp.Want, - Overwrite: tmp.Overwrite, - Exclude: tmp.Exclude, - OnlyIPType: tmp.OnlyIPType, - - SourceMMDBURI: tmp.SourceMMDBURI, - }, nil + return NewGeoLite2CountryMMDBOut( + iType, iDesc, action, + WithOutputName(tmp.OutputName), + WithOutputDir(tmp.OutputDir, iType), + WithOutputWantedList(tmp.Want), + WithOutputOverwriteList(tmp.Overwrite), + WithOutputExcludedList(tmp.Exclude), + WithOutputOnlyIPType(tmp.OnlyIPType), + WithSourceMMDBURI(tmp.SourceMMDBURI), + ), nil } -func (g *GeoLite2CountryMMDBOut) GetExtraInfo() (map[string]any, error) { +func (g *geoLite2CountryMMDBOut) GetExtraInfo() (map[string]any, error) { if strings.TrimSpace(g.SourceMMDBURI) == "" { return nil, nil } |
