diff options
| author | Loyalsoldier <[email protected]> | 2026-03-06 10:40:04 +0800 |
|---|---|---|
| committer | Loyalsoldier <[email protected]> | 2026-03-06 10:40:04 +0800 |
| commit | 54c52d334ff35b6583be619b3f665e972ae20d98 (patch) | |
| tree | 523c1be0ae5b7e4390fb449a411197f5959d547c /plugin/singbox | |
| parent | 1fd7373f45810501015373bf202948e8c4fdf2e9 (diff) | |
Chore: extract common GetIgnoreIPType logic202604142159202604090028202604020031202603260032202603190030202603120023202603061527
Diffstat (limited to 'plugin/singbox')
| -rw-r--r-- | plugin/singbox/srs_in.go | 8 | ||||
| -rw-r--r-- | plugin/singbox/srs_out.go | 11 |
2 files changed, 2 insertions, 17 deletions
diff --git a/plugin/singbox/srs_in.go b/plugin/singbox/srs_in.go index 68ccd461..348f4563 100644 --- a/plugin/singbox/srs_in.go +++ b/plugin/singbox/srs_in.go @@ -120,13 +120,7 @@ func (s *SRSIn) Input(container lib.Container) (lib.Container, error) { return nil, fmt.Errorf("❌ [type %s | action %s] no entry is generated", s.Type, s.Action) } - var ignoreIPType lib.IgnoreIPOption - switch s.OnlyIPType { - case lib.IPv4: - ignoreIPType = lib.IgnoreIPv6 - case lib.IPv6: - ignoreIPType = lib.IgnoreIPv4 - } + ignoreIPType := lib.GetIgnoreIPType(s.OnlyIPType) for _, entry := range entries { switch s.Action { diff --git a/plugin/singbox/srs_out.go b/plugin/singbox/srs_out.go index e2fb767e..535eb6b8 100644 --- a/plugin/singbox/srs_out.go +++ b/plugin/singbox/srs_out.go @@ -151,16 +151,7 @@ func (s *SRSOut) generate(entry *lib.Entry) error { } func (s *SRSOut) marshalRuleSet(entry *lib.Entry) (*option.PlainRuleSet, error) { - var entryCidr []string - var err error - switch s.OnlyIPType { - case lib.IPv4: - entryCidr, err = entry.MarshalText(lib.IgnoreIPv6) - case lib.IPv6: - entryCidr, err = entry.MarshalText(lib.IgnoreIPv4) - default: - entryCidr, err = entry.MarshalText() - } + entryCidr, err := entry.MarshalText(lib.GetIgnoreIPType(s.OnlyIPType)) if err != nil { return nil, err } |
