summaryrefslogtreecommitdiff
path: root/lookup.go
diff options
context:
space:
mode:
Diffstat (limited to 'lookup.go')
-rw-r--r--lookup.go131
1 files changed, 60 insertions, 71 deletions
diff --git a/lookup.go b/lookup.go
index 9261d944..439a0a8c 100644
--- a/lookup.go
+++ b/lookup.go
@@ -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),
+ )
}