Skip to content

Commit

Permalink
Merge pull request #8 from 117503445/117503445/json-output
Browse files Browse the repository at this point in the history
output json for debug & view
  • Loading branch information
lyc8503 authored Jul 21, 2024
2 parents 4a054ae + a38938a commit 353606f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rule-set
*.db
17 changes: 17 additions & 0 deletions sing-geoip/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"encoding/json"
"io"
"net"
"net/http"
Expand Down Expand Up @@ -239,6 +240,22 @@ func release(source string, destination string, output string, ruleSetOutput str
return err
}
outputRuleSet.Close()

srsPath, _ = filepath.Abs(filepath.Join(ruleSetOutput, "geoip-"+countryCode+".json"))
os.Stderr.WriteString("write " + srsPath + "\n")
outputRuleSet, err = os.Create(srsPath)
if err != nil {
return err
}
je := json.NewEncoder(outputRuleSet)
je.SetEscapeHTML(false)
je.SetIndent("", " ")
err = je.Encode(plainRuleSet)
if err != nil {
outputRuleSet.Close()
return err
}
outputRuleSet.Close()
}

setActionOutput("tag", *sourceRelease.Name)
Expand Down
17 changes: 17 additions & 0 deletions sing-geosite/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"io"
"net/http"
"os"
Expand Down Expand Up @@ -238,6 +239,22 @@ func generate(release *github.RepositoryRelease, output string, cnOutput string,
return err
}
outputRuleSet.Close()

srsPath, _ = filepath.Abs(filepath.Join(ruleSetOutput, "geosite-"+code+".json"))
os.Stderr.WriteString("write " + srsPath + "\n")
outputRuleSet, err = os.Create(srsPath)
if err != nil {
return err
}
je := json.NewEncoder(outputRuleSet)
je.SetEscapeHTML(false)
je.SetIndent("", " ")
err = je.Encode(plainRuleSet)
if err != nil {
outputRuleSet.Close()
return err
}
outputRuleSet.Close()
}
return nil
}
Expand Down

0 comments on commit 353606f

Please sign in to comment.