summaryrefslogtreecommitdiff
path: root/plugin/plaintext/clash_in.go
blob: a714b20dcf632b0983e381be4b6fac5b10696472 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package plaintext

import (
	"encoding/json"

	"github.com/Loyalsoldier/geoip/lib"
)

/*
The types in this file extend the type `typeTextIn`,
which make it possible to support more formats for the project.
*/

const (
	TypeClashRuleSetClassicalIn = "clashRuleSetClassical"
	DescClashRuleSetClassicalIn = "Convert classical type of Clash RuleSet to other formats (just processing IP & CIDR lines)"

	TypeClashRuleSetIPCIDRIn = "clashRuleSet"
	DescClashRuleSetIPCIDRIn = "Convert ipcidr type of Clash RuleSet to other formats"
)

func init() {
	lib.RegisterInputConfigCreator(TypeClashRuleSetClassicalIn, func(action lib.Action, data json.RawMessage) (lib.InputConverter, error) {
		return NewTextInFromBytes(TypeClashRuleSetClassicalIn, DescClashRuleSetClassicalIn, action, data)
	})
	lib.RegisterInputConverter(TypeClashRuleSetClassicalIn, &text_in{
		Description: DescClashRuleSetClassicalIn,
	})

	lib.RegisterInputConfigCreator(TypeClashRuleSetIPCIDRIn, func(action lib.Action, data json.RawMessage) (lib.InputConverter, error) {
		return NewTextInFromBytes(TypeClashRuleSetIPCIDRIn, DescClashRuleSetIPCIDRIn, action, data)
	})
	lib.RegisterInputConverter(TypeClashRuleSetIPCIDRIn, &text_in{
		Description: DescClashRuleSetIPCIDRIn,
	})
}