mirror of
https://github.com/SagerNet/sing-geosite.git
synced 2025-09-03 21:48:48 +08:00
Compare commits
6 Commits
2024061209
...
main
Author | SHA1 | Date | |
---|---|---|---|
![]() |
dd64ae0ebf | ||
![]() |
f51c57d77a | ||
![]() |
19b54b9626 | ||
![]() |
d4b71e0c8d | ||
![]() |
9f8a5e7cba | ||
![]() |
c69c0c0cc8 |
25
.github/release-rule-set.sh
vendored
25
.github/release-rule-set.sh
vendored
@ -2,12 +2,19 @@
|
||||
|
||||
set -e -o pipefail
|
||||
|
||||
cd rule-set
|
||||
git init
|
||||
git config --local user.email "github-action@users.noreply.github.com"
|
||||
git config --local user.name "GitHub Action"
|
||||
git remote add origin https://github-action:$GITHUB_TOKEN@github.com/SagerNet/sing-geosite.git
|
||||
git branch -M rule-set
|
||||
git add .
|
||||
git commit -m "Update rule-set"
|
||||
git push -f origin rule-set
|
||||
function releaseRuleSet() {
|
||||
dirName=$1
|
||||
pushd $dirName
|
||||
git init
|
||||
git config --local user.email "github-action@users.noreply.github.com"
|
||||
git config --local user.name "GitHub Action"
|
||||
git remote add origin https://github-action:$GITHUB_TOKEN@github.com/SagerNet/sing-geosite.git
|
||||
git branch -M $dirName
|
||||
git add .
|
||||
git commit -m "Update rule-set"
|
||||
git push -f origin $dirName
|
||||
popd
|
||||
}
|
||||
|
||||
releaseRuleSet rule-set
|
||||
releaseRuleSet rule-set-unstable
|
||||
|
7
.github/workflows/build.yaml
vendored
7
.github/workflows/build.yaml
vendored
@ -21,9 +21,4 @@ jobs:
|
||||
env:
|
||||
NO_SKIP: true
|
||||
run: |
|
||||
go run -v .
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: geosite.db
|
||||
path: geosite.db
|
||||
go run -v .
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
/.idea/
|
||||
/vendor/
|
||||
/geosite.db
|
||||
/rule-set/
|
||||
**.db
|
||||
/rule-set/
|
||||
/rule-set-unstable/
|
||||
|
BIN
geosite-cn.db
BIN
geosite-cn.db
Binary file not shown.
26
go.mod
26
go.mod
@ -6,24 +6,24 @@ toolchain go1.22.3
|
||||
|
||||
require (
|
||||
github.com/google/go-github/v45 v45.2.0
|
||||
github.com/sagernet/sing v0.3.8
|
||||
github.com/sagernet/sing-box v1.8.13
|
||||
github.com/v2fly/v2ray-core/v5 v5.16.1
|
||||
google.golang.org/protobuf v1.34.0
|
||||
github.com/sagernet/sing v0.5.0-beta.1
|
||||
github.com/sagernet/sing-box v1.9.5-0.20240912063220-bed673aa630c
|
||||
github.com/v2fly/v2ray-core/v5 v5.18.0
|
||||
google.golang.org/protobuf v1.34.2
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/adrg/xdg v0.4.0 // indirect
|
||||
github.com/adrg/xdg v0.5.0 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/google/go-querystring v1.1.0 // indirect
|
||||
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
|
||||
github.com/miekg/dns v1.1.59 // indirect
|
||||
github.com/sagernet/sing-dns v0.1.14 // indirect
|
||||
github.com/miekg/dns v1.1.62 // indirect
|
||||
github.com/sagernet/sing-dns v0.3.0-beta.14 // indirect
|
||||
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect
|
||||
golang.org/x/crypto v0.22.0 // indirect
|
||||
golang.org/x/mod v0.17.0 // indirect
|
||||
golang.org/x/net v0.24.0 // indirect
|
||||
golang.org/x/sync v0.7.0 // indirect
|
||||
golang.org/x/sys v0.19.0 // indirect
|
||||
golang.org/x/tools v0.20.0 // indirect
|
||||
golang.org/x/crypto v0.27.0 // indirect
|
||||
golang.org/x/mod v0.19.0 // indirect
|
||||
golang.org/x/net v0.29.0 // indirect
|
||||
golang.org/x/sync v0.8.0 // indirect
|
||||
golang.org/x/sys v0.25.0 // indirect
|
||||
golang.org/x/tools v0.23.0 // indirect
|
||||
)
|
||||
|
74
go.sum
74
go.sum
@ -1,8 +1,9 @@
|
||||
github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls=
|
||||
github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/adrg/xdg v0.5.0 h1:dDaZvhMXatArP1NPHhnfaQUqWBLBsmx1h1HXQdMoFCY=
|
||||
github.com/adrg/xdg v0.5.0/go.mod h1:dDdY4M4DF9Rjy4kHPeNL+ilVF+p2lK8IdM9/rTSGcI4=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
|
||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
|
||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
@ -12,43 +13,52 @@ github.com/google/go-github/v45 v45.2.0 h1:5oRLszbrkvxDDqBCNj2hjDZMKmvexaZ1xw/FC
|
||||
github.com/google/go-github/v45 v45.2.0/go.mod h1:FObaZJEDSTa/WGCzZ2Z3eoCDXWJKMenWWTrd8jrta28=
|
||||
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
||||
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
||||
github.com/google/pprof v0.0.0-20240320155624-b11c3daa6f07 h1:57oOH2Mu5Nw16KnZAVLdlUjmPH/TSYCKTJgG0OVfX0Y=
|
||||
github.com/google/pprof v0.0.0-20240320155624-b11c3daa6f07/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw=
|
||||
github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8=
|
||||
github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
|
||||
github.com/miekg/dns v1.1.59 h1:C9EXc/UToRwKLhK5wKU/I4QVsBUc8kE6MkHBkeypWZs=
|
||||
github.com/miekg/dns v1.1.59/go.mod h1:nZpewl5p6IvctfgrckopVx2OlSEHPRO/U4SYkRklrEk=
|
||||
github.com/miekg/dns v1.1.62 h1:cN8OuEF1/x5Rq6Np+h1epln8OiyPWV+lROx9LxcGgIQ=
|
||||
github.com/miekg/dns v1.1.62/go.mod h1:mvDlcItzm+br7MToIKqkglaGhlFMHJ9DTNNWONWXbNQ=
|
||||
github.com/onsi/ginkgo/v2 v2.17.0 h1:kdnunFXpBjbzN56hcJHrXZ8M+LOkenKA7NnBzTNigTI=
|
||||
github.com/onsi/ginkgo/v2 v2.17.0/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/sagernet/sing v0.3.8 h1:gm4JKalPhydMYX2zFOTnnd4TXtM/16WFRqSjMepYQQk=
|
||||
github.com/sagernet/sing v0.3.8/go.mod h1:+60H3Cm91RnL9dpVGWDPHt0zTQImO9Vfqt9a4rSambI=
|
||||
github.com/sagernet/sing-box v1.8.13 h1:M8mLo7AWDKV9d+Bq41fOz7B5CvS4+xhBR1tmwzrr7PY=
|
||||
github.com/sagernet/sing-box v1.8.13/go.mod h1:Cb0FBO7r5UnQJQ7Ql0jgdJ8SmzCyFvCQ7eeXq2clTOI=
|
||||
github.com/sagernet/sing-dns v0.1.14 h1:kxE/Ik3jMXmD3sXsdt9MgrNzLFWt64mghV+MQqzyf40=
|
||||
github.com/sagernet/sing-dns v0.1.14/go.mod h1:AA+vZMNovuPN5i/sPnfF6756Nq94nzb5nXodMWbta5w=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo=
|
||||
github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A=
|
||||
github.com/quic-go/qtls-go1-20 v0.4.1 h1:D33340mCNDAIKBqXuAvexTNMUByrYmFYVfKfDN5nfFs=
|
||||
github.com/quic-go/qtls-go1-20 v0.4.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k=
|
||||
github.com/sagernet/quic-go v0.47.0-beta.2 h1:1tCGWFOSaXIeuQaHrwOMJIYvlupjTcaVInGQw5ArULU=
|
||||
github.com/sagernet/quic-go v0.47.0-beta.2/go.mod h1:bLVKvElSEMNv7pu7SZHscW02TYigzQ5lQu3Nh4wNh8Q=
|
||||
github.com/sagernet/sing v0.5.0-beta.1 h1:THZMZgJcDQxutE++6Ckih1HlvMtXple94RBGa6GSg2I=
|
||||
github.com/sagernet/sing v0.5.0-beta.1/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
|
||||
github.com/sagernet/sing-box v1.9.5-0.20240912063220-bed673aa630c h1:iLUOSU5rx96BJAgTbqySE9zloGOvIk18MDHznU5+ass=
|
||||
github.com/sagernet/sing-box v1.9.5-0.20240912063220-bed673aa630c/go.mod h1:pcO6hmTsvx1LS3DkTz0P1zjQmEFCStINed4ar5NDQzg=
|
||||
github.com/sagernet/sing-dns v0.3.0-beta.14 h1:/s+fJzYKsvLaNDt/2rjpsrDcN8wmCO2JbX6OFrl8Nww=
|
||||
github.com/sagernet/sing-dns v0.3.0-beta.14/go.mod h1:rscgSr5ixOPk8XM9ZMLuMXCyldEQ1nLvdl0nfv+lp00=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/v2fly/v2ray-core/v5 v5.16.1 h1:hIuRzCJhmRYqCA76hGiNLkAHopgbNt91L871wlJ/yUU=
|
||||
github.com/v2fly/v2ray-core/v5 v5.16.1/go.mod h1:3pWIBTmNagMKpzd9/QicXq/7JZCQt716GsGZdBNmYkU=
|
||||
github.com/v2fly/v2ray-core/v5 v5.18.0 h1:KSw6Q7YPuV1ZAQzdjwxQqCKBIkZnp0DewjjPDEYidAg=
|
||||
github.com/v2fly/v2ray-core/v5 v5.18.0/go.mod h1:qC7xF/dQh/Dy+kFxn/4/KN3OXeuliG8IJM4AmG5dTO0=
|
||||
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBseWJUpBw5I82+2U4M=
|
||||
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y=
|
||||
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
|
||||
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
|
||||
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
|
||||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
|
||||
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
|
||||
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
|
||||
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY=
|
||||
golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg=
|
||||
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
|
||||
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
|
||||
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8=
|
||||
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
|
||||
golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8=
|
||||
golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
|
||||
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
|
||||
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
||||
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
|
||||
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
|
||||
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||
golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg=
|
||||
golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/protobuf v1.34.0 h1:Qo/qEd2RZPCf2nKuorzksSknv0d3ERwp1vFG38gSmH4=
|
||||
google.golang.org/protobuf v1.34.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
|
||||
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
71
main.go
71
main.go
@ -1,10 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
@ -216,9 +216,6 @@ func filterTags(data map[string][]geosite.Item) {
|
||||
}
|
||||
for _, it := range badCodeList {
|
||||
badList := data[it.badCode]
|
||||
if it.badCode == "geolocation-!cn@cn" {
|
||||
fmt.Println(badList)
|
||||
}
|
||||
if badList == nil {
|
||||
panic("bad list not found: " + it.badCode)
|
||||
}
|
||||
@ -265,6 +262,18 @@ func mergeTags(data map[string][]geosite.Item) {
|
||||
}
|
||||
cnCodeList = append(cnCodeList, code)
|
||||
}
|
||||
for _, code := range codeList {
|
||||
if !strings.HasPrefix(code, "category-") {
|
||||
continue
|
||||
}
|
||||
if !strings.HasSuffix(code, "-cn") {
|
||||
continue
|
||||
}
|
||||
if strings.Contains(code, "@") {
|
||||
continue
|
||||
}
|
||||
cnCodeList = append(cnCodeList, code)
|
||||
}
|
||||
newMap := make(map[geosite.Item]bool)
|
||||
for _, item := range data["geolocation-cn"] {
|
||||
newMap[item] = true
|
||||
@ -279,10 +288,14 @@ func mergeTags(data map[string][]geosite.Item) {
|
||||
newList = append(newList, item)
|
||||
}
|
||||
data["geolocation-cn"] = newList
|
||||
data["cn"] = append(newList, geosite.Item{
|
||||
Type: geosite.RuleTypeDomainSuffix,
|
||||
Value: "cn",
|
||||
})
|
||||
println("merged cn categories: " + strings.Join(cnCodeList, ","))
|
||||
}
|
||||
|
||||
func generate(release *github.RepositoryRelease, output string, cnOutput string, ruleSetOutput string) error {
|
||||
func generate(release *github.RepositoryRelease, output string, cnOutput string, ruleSetOutput string, ruleSetUnstableOutput string) error {
|
||||
vData, err := download(release)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -300,7 +313,12 @@ func generate(release *github.RepositoryRelease, output string, cnOutput string,
|
||||
return err
|
||||
}
|
||||
defer outputFile.Close()
|
||||
err = geosite.Write(outputFile, domainMap)
|
||||
writer := bufio.NewWriter(outputFile)
|
||||
err = geosite.Write(writer, domainMap)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = writer.Flush()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -316,12 +334,19 @@ func generate(release *github.RepositoryRelease, output string, cnOutput string,
|
||||
return err
|
||||
}
|
||||
defer cnOutputFile.Close()
|
||||
err = geosite.Write(cnOutputFile, cnDomainMap)
|
||||
writer.Reset(cnOutputFile)
|
||||
err = geosite.Write(writer, cnDomainMap)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = writer.Flush()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
os.RemoveAll(ruleSetOutput)
|
||||
os.RemoveAll(ruleSetUnstableOutput)
|
||||
err = os.MkdirAll(ruleSetOutput, 0o755)
|
||||
err = os.MkdirAll(ruleSetUnstableOutput, 0o755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -340,17 +365,30 @@ func generate(release *github.RepositoryRelease, output string, cnOutput string,
|
||||
},
|
||||
}
|
||||
srsPath, _ := filepath.Abs(filepath.Join(ruleSetOutput, "geosite-"+code+".srs"))
|
||||
//os.Stderr.WriteString("write " + srsPath + "\n")
|
||||
outputRuleSet, err := os.Create(srsPath)
|
||||
unstableSRSPath, _ := filepath.Abs(filepath.Join(ruleSetUnstableOutput, "geosite-"+code+".srs"))
|
||||
// os.Stderr.WriteString("write " + srsPath + "\n")
|
||||
var (
|
||||
outputRuleSet *os.File
|
||||
outputRuleSetUnstable *os.File
|
||||
)
|
||||
outputRuleSet, err = os.Create(srsPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = srs.Write(outputRuleSet, plainRuleSet)
|
||||
if err != nil {
|
||||
outputRuleSet.Close()
|
||||
return err
|
||||
}
|
||||
err = srs.Write(outputRuleSet, plainRuleSet, false)
|
||||
outputRuleSet.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
outputRuleSetUnstable, err = os.Create(unstableSRSPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = srs.Write(outputRuleSetUnstable, plainRuleSet, true)
|
||||
outputRuleSetUnstable.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -359,7 +397,7 @@ func setActionOutput(name string, content string) {
|
||||
os.Stdout.WriteString("::set-output name=" + name + "::" + content + "\n")
|
||||
}
|
||||
|
||||
func release(source string, destination string, output string, cnOutput string, ruleSetOutput string) error {
|
||||
func release(source string, destination string, output string, cnOutput string, ruleSetOutput string, ruleSetOutputUnstable string) error {
|
||||
sourceRelease, err := fetch(source)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -374,7 +412,7 @@ func release(source string, destination string, output string, cnOutput string,
|
||||
return nil
|
||||
}
|
||||
}
|
||||
err = generate(sourceRelease, output, cnOutput, ruleSetOutput)
|
||||
err = generate(sourceRelease, output, cnOutput, ruleSetOutput, ruleSetOutputUnstable)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -389,6 +427,7 @@ func main() {
|
||||
"geosite.db",
|
||||
"geosite-cn.db",
|
||||
"rule-set",
|
||||
"rule-set-unstable",
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user