Update On Tue Aug 6 20:32:53 CEST 2024

This commit is contained in:
github-action[bot]
2024-08-06 20:32:53 +02:00
parent abb7c9abe3
commit 4516aba8c6
127 changed files with 1382 additions and 970 deletions

View File

@@ -23,15 +23,23 @@ type textOut struct {
Action lib.Action
Description string
OutputDir string
OutputExt string
Want []string
OnlyIPType lib.IPType
AddPrefixInLine string
AddSuffixInLine string
}
func newTextOut(iType string, action lib.Action, data json.RawMessage) (lib.OutputConverter, error) {
var tmp struct {
OutputDir string `json:"outputDir"`
OutputExt string `json:"outputExtension"`
Want []string `json:"wantedList"`
OnlyIPType lib.IPType `json:"onlyIPType"`
AddPrefixInLine string `json:"addPrefixInLine"`
AddSuffixInLine string `json:"addSuffixInLine"`
}
if len(data) > 0 {
@@ -53,13 +61,21 @@ func newTextOut(iType string, action lib.Action, data json.RawMessage) (lib.Outp
}
}
if tmp.OutputExt == "" {
tmp.OutputExt = ".txt"
}
return &textOut{
Type: iType,
Action: action,
Description: descTextOut,
OutputDir: tmp.OutputDir,
OutputExt: tmp.OutputExt,
Want: tmp.Want,
OnlyIPType: tmp.OnlyIPType,
AddPrefixInLine: tmp.AddPrefixInLine,
AddSuffixInLine: tmp.AddSuffixInLine,
}, nil
}
@@ -101,7 +117,13 @@ func (t *textOut) marshalBytes(entry *lib.Entry) ([]byte, error) {
func (t *textOut) marshalBytesForTextOut(buf *bytes.Buffer, entryCidr []string) error {
for _, cidr := range entryCidr {
if t.AddPrefixInLine != "" {
buf.WriteString(t.AddPrefixInLine)
}
buf.WriteString(cidr)
if t.AddSuffixInLine != "" {
buf.WriteString(t.AddSuffixInLine)
}
buf.WriteString("\n")
}
return nil
@@ -149,6 +171,9 @@ func (t *textOut) marshalBytesForSurgeRuleSetOut(buf *bytes.Buffer, entryCidr []
buf.WriteString("IP-CIDR6,")
}
buf.WriteString(cidr)
if t.AddSuffixInLine != "" {
buf.WriteString(t.AddSuffixInLine)
}
buf.WriteString("\n")
}