mirror of
https://github.com/SagerNet/sing-geosite.git
synced 2025-03-11 19:12:11 +08:00
Compare commits
No commits in common. "main" and "20231116085254" have entirely different histories.
main
...
2023111608
15
.github/release-branch.sh
vendored
15
.github/release-branch.sh
vendored
@ -1,15 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e -o pipefail
|
|
||||||
|
|
||||||
mkdir -p release
|
|
||||||
cd release
|
|
||||||
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 release
|
|
||||||
cp ../*.db ../*.sha256sum .
|
|
||||||
git add .
|
|
||||||
git commit -m "Update release"
|
|
||||||
git push -f origin release
|
|
20
.github/release-rule-set.sh
vendored
20
.github/release-rule-set.sh
vendored
@ -1,20 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e -o pipefail
|
|
||||||
|
|
||||||
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
|
|
22
.github/renovate.json
vendored
22
.github/renovate.json
vendored
@ -1,22 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
|
||||||
"commitMessagePrefix": "[dependencies]",
|
|
||||||
"extends": [
|
|
||||||
"config:base",
|
|
||||||
":disableRateLimiting"
|
|
||||||
],
|
|
||||||
"baseBranches": [
|
|
||||||
"main"
|
|
||||||
],
|
|
||||||
"golang": {
|
|
||||||
"enabled": false
|
|
||||||
},
|
|
||||||
"packageRules": [
|
|
||||||
{
|
|
||||||
"matchManagers": [
|
|
||||||
"github-actions"
|
|
||||||
],
|
|
||||||
"groupName": "github-actions"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
17
.github/workflows/build.yaml
vendored
17
.github/workflows/build.yaml
vendored
@ -9,16 +9,25 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
- name: Get latest go version
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
echo ::set-output name=go_version::$(curl -s https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json | grep -oE '"version": "[0-9]{1}.[0-9]{1,}(.[0-9]{1,})?"' | head -1 | cut -d':' -f2 | sed 's/ //g; s/"//g')
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: ^1.22
|
go-version: ${{ steps.version.outputs.go_version }}
|
||||||
- name: Build geosite
|
- name: Build geosite
|
||||||
id: build
|
id: build
|
||||||
env:
|
env:
|
||||||
NO_SKIP: true
|
NO_SKIP: true
|
||||||
run: |
|
run: |
|
||||||
go run -v .
|
go run -v .
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: geosite.db
|
||||||
|
path: geosite.db
|
59
.github/workflows/release.yaml
vendored
59
.github/workflows/release.yaml
vendored
@ -9,45 +9,58 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
- name: Get latest go version
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
echo ::set-output name=go_version::$(curl -s https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json | grep -oE '"version": "[0-9]{1}.[0-9]{1,}(.[0-9]{1,})?"' | head -1 | cut -d':' -f2 | sed 's/ //g; s/"//g')
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: ^1.22
|
go-version: ${{ steps.version.outputs.go_version }}
|
||||||
- name: Build geosite
|
- name: Build geosite
|
||||||
id: build
|
id: build
|
||||||
run: |
|
run: |
|
||||||
go run -v .
|
go run -v .
|
||||||
- name: Release rule sets
|
|
||||||
if: steps.build.outputs.skip != 'true'
|
|
||||||
run: .github/release-rule-set.sh
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
- name: Generate sha256 hash
|
- name: Generate sha256 hash
|
||||||
if: steps.build.outputs.skip != 'true'
|
if: steps.build.outputs.skip != 'true'
|
||||||
run: |
|
run: |
|
||||||
sha256sum geosite.db > geosite.db.sha256sum
|
sha256sum geosite.db > geosite.db.sha256sum
|
||||||
sha256sum geosite-cn.db > geosite-cn.db.sha256sum
|
|
||||||
- name: Release release branch
|
|
||||||
if: steps.build.outputs.skip != 'true'
|
|
||||||
run: .github/release-branch.sh
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
- uses: dev-drprasad/delete-older-releases@v0.3.2
|
- uses: dev-drprasad/delete-older-releases@v0.3.2
|
||||||
if: steps.build.outputs.skip != 'true'
|
|
||||||
with:
|
with:
|
||||||
keep_latest: 10
|
keep_latest: 3
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Release geosite
|
- name: Create a release
|
||||||
if: steps.build.outputs.skip != 'true'
|
if: steps.build.outputs.skip != 'true'
|
||||||
uses: softprops/action-gh-release@v1
|
id: create_release
|
||||||
|
uses: actions/create-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ steps.build.outputs.tag }}
|
tag_name: ${{ steps.build.outputs.tag }}
|
||||||
files: |
|
release_name: ${{ steps.build.outputs.tag }}
|
||||||
geosite.db
|
draft: false
|
||||||
geosite.db.sha256sum
|
prerelease: false
|
||||||
geosite-cn.db
|
- name: Release geosite.db
|
||||||
geosite-cn.db.sha256sum
|
if: steps.build.outputs.skip != 'true'
|
||||||
|
uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: ./geosite.db
|
||||||
|
asset_name: geosite.db
|
||||||
|
asset_content_type: application/octet-stream
|
||||||
|
- name: Release geosite.db sha256sum
|
||||||
|
if: steps.build.outputs.skip != 'true'
|
||||||
|
uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: ./geosite.db.sha256sum
|
||||||
|
asset_name: geosite.db.sha256sum
|
||||||
|
asset_content_type: text/plain
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,5 +1,3 @@
|
|||||||
/.idea/
|
/.idea/
|
||||||
/vendor/
|
/vendor/
|
||||||
**.db
|
/geosite.db
|
||||||
/rule-set/
|
|
||||||
/rule-set-unstable/
|
|
@ -1,17 +1,54 @@
|
|||||||
|
run:
|
||||||
|
timeout: 5m
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
disable-all: true
|
enable-all: true
|
||||||
enable:
|
disable:
|
||||||
- gofumpt
|
- errcheck
|
||||||
- govet
|
- wrapcheck
|
||||||
- gci
|
- varnamelen
|
||||||
- staticcheck
|
- stylecheck
|
||||||
|
- nonamedreturns
|
||||||
|
- nlreturn
|
||||||
|
- ireturn
|
||||||
|
- gomnd
|
||||||
|
- exhaustivestruct
|
||||||
|
- ifshort
|
||||||
|
- goerr113
|
||||||
|
- gochecknoglobals
|
||||||
|
- forcetypeassert
|
||||||
|
- exhaustruct
|
||||||
|
- exhaustive
|
||||||
|
- cyclop
|
||||||
|
- containedctx
|
||||||
|
- wsl
|
||||||
|
- nestif
|
||||||
|
- lll
|
||||||
|
- funlen
|
||||||
|
- goconst
|
||||||
|
- godot
|
||||||
|
- gocognit
|
||||||
|
- golint
|
||||||
|
- goimports
|
||||||
|
- gochecknoinits
|
||||||
|
- maligned
|
||||||
|
- tagliatelle
|
||||||
|
- gocyclo
|
||||||
|
- maintidx
|
||||||
|
- gocritic
|
||||||
|
- nakedret
|
||||||
|
|
||||||
linters-settings:
|
linters-settings:
|
||||||
gci:
|
revive:
|
||||||
custom-order: true
|
rules:
|
||||||
sections:
|
- name: var-naming
|
||||||
- standard
|
disabled: true
|
||||||
- prefix(github.com/sagernet/)
|
govet:
|
||||||
- default
|
enable-all: true
|
||||||
staticcheck:
|
disable:
|
||||||
go: '1.20'
|
- composites
|
||||||
|
- fieldalignment
|
||||||
|
- shadow
|
||||||
|
gosec:
|
||||||
|
excludes:
|
||||||
|
- G404
|
17
Makefile
17
Makefile
@ -1,17 +0,0 @@
|
|||||||
fmt:
|
|
||||||
@gofumpt -l -w .
|
|
||||||
@gofmt -s -w .
|
|
||||||
@gci write --custom-order -s standard -s "prefix(github.com/sagernet/)" -s "default" .
|
|
||||||
|
|
||||||
fmt_install:
|
|
||||||
go install -v mvdan.cc/gofumpt@latest
|
|
||||||
go install -v github.com/daixiang0/gci@latest
|
|
||||||
|
|
||||||
lint:
|
|
||||||
golangci-lint run ./...
|
|
||||||
|
|
||||||
lint_install:
|
|
||||||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
|
||||||
|
|
||||||
test:
|
|
||||||
go test -v ./...
|
|
7
format.go
Normal file
7
format.go
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
//go:generate go install -v mvdan.cc/gofumpt@latest
|
||||||
|
//go:generate go install -v github.com/daixiang0/gci@latest
|
||||||
|
//go:generate gofumpt -l -w .
|
||||||
|
//go:generate gofmt -s -w .
|
||||||
|
//go:generate gci write .
|
36
go.mod
36
go.mod
@ -1,29 +1,25 @@
|
|||||||
module github.com/sagernet/sing-geosite
|
module sing-geosite
|
||||||
|
|
||||||
go 1.21
|
go 1.18
|
||||||
|
|
||||||
toolchain go1.22.3
|
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/google/go-github/v45 v45.2.0
|
github.com/google/go-github/v45 v45.2.0
|
||||||
github.com/sagernet/sing v0.5.0-beta.1
|
github.com/sagernet/sing v0.2.17
|
||||||
github.com/sagernet/sing-box v1.9.5-0.20240912063220-bed673aa630c
|
github.com/sagernet/sing-box v1.6.4
|
||||||
github.com/v2fly/v2ray-core/v5 v5.18.0
|
github.com/sirupsen/logrus v1.9.3
|
||||||
google.golang.org/protobuf v1.34.2
|
github.com/v2fly/v2ray-core/v5 v5.11.0
|
||||||
|
google.golang.org/protobuf v1.31.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/adrg/xdg v0.5.0 // indirect
|
github.com/adrg/xdg v0.4.0 // indirect
|
||||||
github.com/golang/protobuf v1.5.4 // indirect
|
github.com/golang/protobuf v1.5.3 // indirect
|
||||||
github.com/google/go-querystring v1.1.0 // 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.56 // indirect
|
||||||
github.com/miekg/dns v1.1.62 // indirect
|
github.com/sagernet/sing-dns v0.1.10 // indirect
|
||||||
github.com/sagernet/sing-dns v0.3.0-beta.14 // indirect
|
golang.org/x/crypto v0.15.0 // indirect
|
||||||
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect
|
golang.org/x/mod v0.13.0 // indirect
|
||||||
golang.org/x/crypto v0.27.0 // indirect
|
golang.org/x/net v0.18.0 // indirect
|
||||||
golang.org/x/mod v0.19.0 // indirect
|
golang.org/x/sys v0.14.0 // indirect
|
||||||
golang.org/x/net v0.29.0 // indirect
|
golang.org/x/tools v0.14.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
|
|
||||||
)
|
)
|
||||||
|
93
go.sum
93
go.sum
@ -1,64 +1,53 @@
|
|||||||
github.com/adrg/xdg v0.5.0 h1:dDaZvhMXatArP1NPHhnfaQUqWBLBsmx1h1HXQdMoFCY=
|
github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls=
|
||||||
github.com/adrg/xdg v0.5.0/go.mod h1:dDdY4M4DF9Rjy4kHPeNL+ilVF+p2lK8IdM9/rTSGcI4=
|
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/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
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/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/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
|
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
||||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||||
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=
|
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
|
||||||
github.com/google/go-github/v45 v45.2.0 h1:5oRLszbrkvxDDqBCNj2hjDZMKmvexaZ1xw/FCD+K3FI=
|
github.com/google/go-github/v45 v45.2.0 h1:5oRLszbrkvxDDqBCNj2hjDZMKmvexaZ1xw/FCD+K3FI=
|
||||||
github.com/google/go-github/v45 v45.2.0/go.mod h1:FObaZJEDSTa/WGCzZ2Z3eoCDXWJKMenWWTrd8jrta28=
|
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 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
||||||
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
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/miekg/dns v1.1.56 h1:5imZaSeoRNvpM9SzWNhEcP9QliKiz20/dA2QabIGVnE=
|
||||||
github.com/google/pprof v0.0.0-20240320155624-b11c3daa6f07/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw=
|
github.com/miekg/dns v1.1.56/go.mod h1:cRm6Oo2C8TY9ZS/TqsSrseAcncm74lfK5G+ikN2SWWY=
|
||||||
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.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 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo=
|
github.com/sagernet/sing v0.2.17 h1:vMPKb3MV0Aa5ws4dCJkRI8XEjrsUcDn810czd0FwmzI=
|
||||||
github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A=
|
github.com/sagernet/sing v0.2.17/go.mod h1:OL6k2F0vHmEzXz2KW19qQzu172FDgSbUSODylighuVo=
|
||||||
github.com/quic-go/qtls-go1-20 v0.4.1 h1:D33340mCNDAIKBqXuAvexTNMUByrYmFYVfKfDN5nfFs=
|
github.com/sagernet/sing-box v1.6.4 h1:4cz6kQSVehLlRzjfwYrQT52/W1nNYxulSDm7Hd+NHG8=
|
||||||
github.com/quic-go/qtls-go1-20 v0.4.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k=
|
github.com/sagernet/sing-box v1.6.4/go.mod h1:JEvY+zKVPCxiiEuri2mw6bu2YZh38WCd6Iv9TlHzuOM=
|
||||||
github.com/sagernet/quic-go v0.47.0-beta.2 h1:1tCGWFOSaXIeuQaHrwOMJIYvlupjTcaVInGQw5ArULU=
|
github.com/sagernet/sing-dns v0.1.10 h1:iIU7nRBlUYj+fF2TaktGIvRiTFFrHwSMedLQsvlTZCI=
|
||||||
github.com/sagernet/quic-go v0.47.0-beta.2/go.mod h1:bLVKvElSEMNv7pu7SZHscW02TYigzQ5lQu3Nh4wNh8Q=
|
github.com/sagernet/sing-dns v0.1.10/go.mod h1:vtUimtf7Nq9EdvD5WTpfCr69KL1M7bcgOVKiYBiAY/c=
|
||||||
github.com/sagernet/sing v0.5.0-beta.1 h1:THZMZgJcDQxutE++6Ckih1HlvMtXple94RBGa6GSg2I=
|
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||||
github.com/sagernet/sing v0.5.0-beta.1/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
|
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||||
github.com/sagernet/sing-box v1.9.5-0.20240912063220-bed673aa630c h1:iLUOSU5rx96BJAgTbqySE9zloGOvIk18MDHznU5+ass=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/sagernet/sing-box v1.9.5-0.20240912063220-bed673aa630c/go.mod h1:pcO6hmTsvx1LS3DkTz0P1zjQmEFCStINed4ar5NDQzg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/sagernet/sing-dns v0.3.0-beta.14 h1:/s+fJzYKsvLaNDt/2rjpsrDcN8wmCO2JbX6OFrl8Nww=
|
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||||
github.com/sagernet/sing-dns v0.3.0-beta.14/go.mod h1:rscgSr5ixOPk8XM9ZMLuMXCyldEQ1nLvdl0nfv+lp00=
|
github.com/v2fly/v2ray-core/v5 v5.11.0 h1:+fTB6LdCf+pAyRn4IRXU0kAKCkFaBQW1rCCW2HgNMps=
|
||||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
github.com/v2fly/v2ray-core/v5 v5.11.0/go.mod h1:o4G6VGWp7uLp96YE9V6CxJcNOVqepwbWHBEA1vXE5TU=
|
||||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA=
|
||||||
github.com/v2fly/v2ray-core/v5 v5.18.0 h1:KSw6Q7YPuV1ZAQzdjwxQqCKBIkZnp0DewjjPDEYidAg=
|
golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g=
|
||||||
github.com/v2fly/v2ray-core/v5 v5.18.0/go.mod h1:qC7xF/dQh/Dy+kFxn/4/KN3OXeuliG8IJM4AmG5dTO0=
|
golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
|
||||||
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBseWJUpBw5I82+2U4M=
|
golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||||
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y=
|
golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg=
|
||||||
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
|
golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
|
||||||
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
|
golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ=
|
||||||
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8=
|
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8=
|
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
|
||||||
golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
|
golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc=
|
||||||
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
|
golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg=
|
||||||
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=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
|
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||||
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
|
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
|
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
|
||||||
|
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||||
|
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=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
||||||
|
246
main.go
246
main.go
@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
|
||||||
"context"
|
"context"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
@ -9,18 +8,13 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/google/go-github/v45/github"
|
||||||
"github.com/sagernet/sing-box/common/geosite"
|
"github.com/sagernet/sing-box/common/geosite"
|
||||||
"github.com/sagernet/sing-box/common/srs"
|
|
||||||
C "github.com/sagernet/sing-box/constant"
|
|
||||||
"github.com/sagernet/sing-box/log"
|
|
||||||
"github.com/sagernet/sing-box/option"
|
|
||||||
"github.com/sagernet/sing/common"
|
"github.com/sagernet/sing/common"
|
||||||
E "github.com/sagernet/sing/common/exceptions"
|
E "github.com/sagernet/sing/common/exceptions"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/google/go-github/v45/github"
|
|
||||||
"github.com/v2fly/v2ray-core/v5/app/router/routercommon"
|
"github.com/v2fly/v2ray-core/v5/app/router/routercommon"
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
@ -49,7 +43,7 @@ func fetch(from string) (*github.RepositoryRelease, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func get(downloadURL *string) ([]byte, error) {
|
func get(downloadURL *string) ([]byte, error) {
|
||||||
log.Info("download ", *downloadURL)
|
logrus.Info("download ", *downloadURL)
|
||||||
response, err := http.Get(*downloadURL)
|
response, err := http.Get(*downloadURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -171,131 +165,12 @@ func parse(vGeositeData []byte) (map[string][]geosite.Item, error) {
|
|||||||
return domainMap, nil
|
return domainMap, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type filteredCodePair struct {
|
func generate(release *github.RepositoryRelease, output string) error {
|
||||||
code string
|
outputFile, err := os.Create(output)
|
||||||
badCode string
|
if err != nil {
|
||||||
}
|
return err
|
||||||
|
|
||||||
func filterTags(data map[string][]geosite.Item) {
|
|
||||||
var codeList []string
|
|
||||||
for code := range data {
|
|
||||||
codeList = append(codeList, code)
|
|
||||||
}
|
}
|
||||||
var badCodeList []filteredCodePair
|
defer outputFile.Close()
|
||||||
var filteredCodeMap []string
|
|
||||||
var mergedCodeMap []string
|
|
||||||
for _, code := range codeList {
|
|
||||||
codeParts := strings.Split(code, "@")
|
|
||||||
if len(codeParts) != 2 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
leftParts := strings.Split(codeParts[0], "-")
|
|
||||||
var lastName string
|
|
||||||
if len(leftParts) > 1 {
|
|
||||||
lastName = leftParts[len(leftParts)-1]
|
|
||||||
}
|
|
||||||
if lastName == "" {
|
|
||||||
lastName = codeParts[0]
|
|
||||||
}
|
|
||||||
if lastName == codeParts[1] {
|
|
||||||
delete(data, code)
|
|
||||||
filteredCodeMap = append(filteredCodeMap, code)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if "!"+lastName == codeParts[1] {
|
|
||||||
badCodeList = append(badCodeList, filteredCodePair{
|
|
||||||
code: codeParts[0],
|
|
||||||
badCode: code,
|
|
||||||
})
|
|
||||||
} else if lastName == "!"+codeParts[1] {
|
|
||||||
badCodeList = append(badCodeList, filteredCodePair{
|
|
||||||
code: codeParts[0],
|
|
||||||
badCode: code,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, it := range badCodeList {
|
|
||||||
badList := data[it.badCode]
|
|
||||||
if badList == nil {
|
|
||||||
panic("bad list not found: " + it.badCode)
|
|
||||||
}
|
|
||||||
delete(data, it.badCode)
|
|
||||||
newMap := make(map[geosite.Item]bool)
|
|
||||||
for _, item := range data[it.code] {
|
|
||||||
newMap[item] = true
|
|
||||||
}
|
|
||||||
for _, item := range badList {
|
|
||||||
delete(newMap, item)
|
|
||||||
}
|
|
||||||
newList := make([]geosite.Item, 0, len(newMap))
|
|
||||||
for item := range newMap {
|
|
||||||
newList = append(newList, item)
|
|
||||||
}
|
|
||||||
data[it.code] = newList
|
|
||||||
mergedCodeMap = append(mergedCodeMap, it.badCode)
|
|
||||||
}
|
|
||||||
sort.Strings(filteredCodeMap)
|
|
||||||
sort.Strings(mergedCodeMap)
|
|
||||||
os.Stderr.WriteString("filtered " + strings.Join(filteredCodeMap, ",") + "\n")
|
|
||||||
os.Stderr.WriteString("merged " + strings.Join(mergedCodeMap, ",") + "\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
func mergeTags(data map[string][]geosite.Item) {
|
|
||||||
var codeList []string
|
|
||||||
for code := range data {
|
|
||||||
codeList = append(codeList, code)
|
|
||||||
}
|
|
||||||
var cnCodeList []string
|
|
||||||
for _, code := range codeList {
|
|
||||||
codeParts := strings.Split(code, "@")
|
|
||||||
if len(codeParts) != 2 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if codeParts[1] != "cn" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if !strings.HasPrefix(codeParts[0], "category-") {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if strings.HasSuffix(codeParts[0], "-cn") || strings.HasSuffix(codeParts[0], "-!cn") {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
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
|
|
||||||
}
|
|
||||||
for _, code := range cnCodeList {
|
|
||||||
for _, item := range data[code] {
|
|
||||||
newMap[item] = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
newList := make([]geosite.Item, 0, len(newMap))
|
|
||||||
for item := range newMap {
|
|
||||||
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, ruleSetUnstableOutput string) error {
|
|
||||||
vData, err := download(release)
|
vData, err := download(release)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -304,115 +179,31 @@ func generate(release *github.RepositoryRelease, output string, cnOutput string,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
filterTags(domainMap)
|
|
||||||
mergeTags(domainMap)
|
|
||||||
outputPath, _ := filepath.Abs(output)
|
outputPath, _ := filepath.Abs(output)
|
||||||
os.Stderr.WriteString("write " + outputPath + "\n")
|
os.Stderr.WriteString("write " + outputPath + "\n")
|
||||||
outputFile, err := os.Create(output)
|
return geosite.Write(outputFile, domainMap)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer outputFile.Close()
|
|
||||||
writer := bufio.NewWriter(outputFile)
|
|
||||||
err = geosite.Write(writer, domainMap)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
err = writer.Flush()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
cnCodes := []string{
|
|
||||||
"geolocation-cn",
|
|
||||||
}
|
|
||||||
cnDomainMap := make(map[string][]geosite.Item)
|
|
||||||
for _, cnCode := range cnCodes {
|
|
||||||
cnDomainMap[cnCode] = domainMap[cnCode]
|
|
||||||
}
|
|
||||||
cnOutputFile, err := os.Create(cnOutput)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer cnOutputFile.Close()
|
|
||||||
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
|
|
||||||
}
|
|
||||||
for code, domains := range domainMap {
|
|
||||||
var headlessRule option.DefaultHeadlessRule
|
|
||||||
defaultRule := geosite.Compile(domains)
|
|
||||||
headlessRule.Domain = defaultRule.Domain
|
|
||||||
headlessRule.DomainSuffix = defaultRule.DomainSuffix
|
|
||||||
headlessRule.DomainKeyword = defaultRule.DomainKeyword
|
|
||||||
headlessRule.DomainRegex = defaultRule.DomainRegex
|
|
||||||
var plainRuleSet option.PlainRuleSet
|
|
||||||
plainRuleSet.Rules = []option.HeadlessRule{
|
|
||||||
{
|
|
||||||
Type: C.RuleTypeDefault,
|
|
||||||
DefaultOptions: headlessRule,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
srsPath, _ := filepath.Abs(filepath.Join(ruleSetOutput, "geosite-"+code+".srs"))
|
|
||||||
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, 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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func setActionOutput(name string, content string) {
|
func setActionOutput(name string, content string) {
|
||||||
os.Stdout.WriteString("::set-output name=" + name + "::" + content + "\n")
|
os.Stdout.WriteString("::set-output name=" + name + "::" + content + "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func release(source string, destination string, output string, cnOutput string, ruleSetOutput string, ruleSetOutputUnstable string) error {
|
func release(source string, destination string, output string) error {
|
||||||
sourceRelease, err := fetch(source)
|
sourceRelease, err := fetch(source)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
destinationRelease, err := fetch(destination)
|
destinationRelease, err := fetch(destination)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn("missing destination latest release")
|
logrus.Warn("missing destination latest release")
|
||||||
} else {
|
} else {
|
||||||
if os.Getenv("NO_SKIP") != "true" && strings.Contains(*destinationRelease.Name, *sourceRelease.Name) {
|
if os.Getenv("NO_SKIP") != "true" && strings.Contains(*destinationRelease.Name, *sourceRelease.Name) {
|
||||||
log.Info("already latest")
|
logrus.Info("already latest")
|
||||||
setActionOutput("skip", "true")
|
setActionOutput("skip", "true")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err = generate(sourceRelease, output, cnOutput, ruleSetOutput, ruleSetOutputUnstable)
|
err = generate(sourceRelease, output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -421,15 +212,8 @@ func release(source string, destination string, output string, cnOutput string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
err := release(
|
err := release("v2fly/domain-list-community", "sagernet/sing-geosite", "geosite.db")
|
||||||
"v2fly/domain-list-community",
|
|
||||||
"sagernet/sing-geosite",
|
|
||||||
"geosite.db",
|
|
||||||
"geosite-cn.db",
|
|
||||||
"rule-set",
|
|
||||||
"rule-set-unstable",
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user