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 /lookup.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 'lookup.go')
| -rw-r--r-- | lookup.go | 131 |
1 files changed, 60 insertions, 71 deletions
@@ -163,38 +163,35 @@ func getInputForLookup(format, name, uri, dir string) lib.InputConverter { switch strings.ToLower(format) { case strings.ToLower(maxmind.TypeGeoLite2CountryMMDBIn): - input = &maxmind.GeoLite2CountryMMDBIn{ - Type: maxmind.TypeGeoLite2CountryMMDBIn, - Action: lib.ActionAdd, - Description: maxmind.DescGeoLite2CountryMMDBIn, - URI: uri, - } + input = maxmind.NewGeoLite2CountryMMDBIn( + maxmind.TypeGeoLite2CountryMMDBIn, + maxmind.DescGeoLite2CountryMMDBIn, + lib.ActionAdd, + maxmind.WithURI(uri), + ) case strings.ToLower(maxmind.TypeDBIPCountryMMDBIn): - input = &maxmind.GeoLite2CountryMMDBIn{ - Type: maxmind.TypeDBIPCountryMMDBIn, - Action: lib.ActionAdd, - Description: maxmind.DescDBIPCountryMMDBIn, - URI: uri, - } + input = maxmind.NewGeoLite2CountryMMDBIn( + maxmind.TypeDBIPCountryMMDBIn, + maxmind.DescDBIPCountryMMDBIn, + lib.ActionAdd, + maxmind.WithURI(uri), + ) case strings.ToLower(maxmind.TypeIPInfoCountryMMDBIn): - input = &maxmind.GeoLite2CountryMMDBIn{ - Type: maxmind.TypeIPInfoCountryMMDBIn, - Action: lib.ActionAdd, - Description: maxmind.DescIPInfoCountryMMDBIn, - URI: uri, - } + input = maxmind.NewGeoLite2CountryMMDBIn( + maxmind.TypeIPInfoCountryMMDBIn, + maxmind.DescIPInfoCountryMMDBIn, + lib.ActionAdd, + maxmind.WithURI(uri), + ) case strings.ToLower(mihomo.TypeMRSIn): - input = &mihomo.MRSIn{ - Type: mihomo.TypeMRSIn, - Action: lib.ActionAdd, - Description: mihomo.DescMRSIn, - Name: name, - URI: uri, - InputDir: dir, - } + input = mihomo.NewMRSIn( + lib.ActionAdd, + mihomo.WithNameAndURI(name, uri), + mihomo.WithInputDir(dir), + ) case strings.ToLower(singbox.TypeSRSIn): input = singbox.NewSRSIn( @@ -204,52 +201,46 @@ func getInputForLookup(format, name, uri, dir string) lib.InputConverter { ) case strings.ToLower(v2ray.TypeGeoIPDatIn): - input = &v2ray.GeoIPDatIn{ - Type: v2ray.TypeGeoIPDatIn, - Action: lib.ActionAdd, - Description: v2ray.DescGeoIPDatIn, - URI: uri, - } + input = v2ray.NewGeoIPDatIn( + lib.ActionAdd, + v2ray.WithURI(uri), + ) case strings.ToLower(plaintext.TypeTextIn): - input = &plaintext.TextIn{ - Type: plaintext.TypeTextIn, - Action: lib.ActionAdd, - Description: plaintext.DescTextIn, - Name: name, - URI: uri, - InputDir: dir, - } + input = plaintext.NewTextIn( + plaintext.TypeTextIn, + plaintext.DescTextIn, + lib.ActionAdd, + plaintext.WithNameAndURI(name, uri), + plaintext.WithInputDir(dir), + ) case strings.ToLower(plaintext.TypeClashRuleSetIPCIDRIn): - input = &plaintext.TextIn{ - Type: plaintext.TypeClashRuleSetIPCIDRIn, - Action: lib.ActionAdd, - Description: plaintext.DescClashRuleSetIPCIDRIn, - Name: name, - URI: uri, - InputDir: dir, - } + input = plaintext.NewTextIn( + plaintext.TypeClashRuleSetIPCIDRIn, + plaintext.DescClashRuleSetIPCIDRIn, + lib.ActionAdd, + plaintext.WithNameAndURI(name, uri), + plaintext.WithInputDir(dir), + ) case strings.ToLower(plaintext.TypeClashRuleSetClassicalIn): - input = &plaintext.TextIn{ - Type: plaintext.TypeClashRuleSetClassicalIn, - Action: lib.ActionAdd, - Description: plaintext.DescClashRuleSetClassicalIn, - Name: name, - URI: uri, - InputDir: dir, - } + input = plaintext.NewTextIn( + plaintext.TypeClashRuleSetClassicalIn, + plaintext.DescClashRuleSetClassicalIn, + lib.ActionAdd, + plaintext.WithNameAndURI(name, uri), + plaintext.WithInputDir(dir), + ) case strings.ToLower(plaintext.TypeSurgeRuleSetIn): - input = &plaintext.TextIn{ - Type: plaintext.TypeSurgeRuleSetIn, - Action: lib.ActionAdd, - Description: plaintext.DescSurgeRuleSetIn, - Name: name, - URI: uri, - InputDir: dir, - } + input = plaintext.NewTextIn( + plaintext.TypeSurgeRuleSetIn, + plaintext.DescSurgeRuleSetIn, + lib.ActionAdd, + plaintext.WithNameAndURI(name, uri), + plaintext.WithInputDir(dir), + ) default: log.Fatal("unsupported input format") @@ -259,11 +250,9 @@ func getInputForLookup(format, name, uri, dir string) lib.InputConverter { } func getOutputForLookup(search string, searchList ...string) lib.OutputConverter { - return &special.Lookup{ - Type: special.TypeLookup, - Action: lib.ActionOutput, - Description: special.DescLookup, - Search: search, - SearchList: searchList, - } + return special.NewLookup( + lib.ActionOutput, + special.WithSearch(search), + special.WithSearchList(searchList), + ) } |
