mirror of
https://github.com/SagerNet/sing-geosite.git
synced 2025-12-17 06:43:13 +08:00
Compare commits
6 Commits
2022072515
...
2023120118
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d51b7ffb3 | ||
|
|
63a151aef9 | ||
|
|
94f16186e7 | ||
|
|
4a32d56c17 | ||
|
|
50c4bf766c | ||
|
|
ec6544f157 |
13
.github/release-rule-set.sh
vendored
Executable file
13
.github/release-rule-set.sh
vendored
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
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
|
||||||
3
.github/workflows/build.yaml
vendored
3
.github/workflows/build.yaml
vendored
@@ -23,11 +23,8 @@ jobs:
|
|||||||
- name: Build geosite
|
- name: Build geosite
|
||||||
id: build
|
id: build
|
||||||
env:
|
env:
|
||||||
GOPRIVATE: github.com/sagernet
|
|
||||||
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
|
||||||
NO_SKIP: true
|
NO_SKIP: true
|
||||||
run: |
|
run: |
|
||||||
git config --global url."https://${{ secrets.ACCESS_TOKEN }}@github.com".insteadOf "https://github.com"
|
|
||||||
go run -v .
|
go run -v .
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
|
|||||||
44
.github/workflows/release.yaml
vendored
44
.github/workflows/release.yaml
vendored
@@ -22,44 +22,28 @@ jobs:
|
|||||||
go-version: ${{ steps.version.outputs.go_version }}
|
go-version: ${{ steps.version.outputs.go_version }}
|
||||||
- name: Build geosite
|
- name: Build geosite
|
||||||
id: build
|
id: build
|
||||||
env:
|
|
||||||
GOPRIVATE: github.com/sagernet
|
|
||||||
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
|
||||||
run: |
|
run: |
|
||||||
git config --global url."https://${{ secrets.ACCESS_TOKEN }}@github.com".insteadOf "https://github.com"
|
|
||||||
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
|
||||||
- name: Create a release
|
- uses: dev-drprasad/delete-older-releases@v0.3.2
|
||||||
if: steps.build.outputs.skip != 'true'
|
if: steps.build.outputs.skip != 'true'
|
||||||
id: create_release
|
with:
|
||||||
uses: actions/create-release@v1
|
keep_latest: 10
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Release geosite
|
||||||
|
if: steps.build.outputs.skip != 'true'
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ steps.build.outputs.tag }}
|
tag_name: ${{ steps.build.outputs.tag }}
|
||||||
release_name: ${{ steps.build.outputs.tag }}
|
files: |
|
||||||
draft: false
|
geosite.db
|
||||||
prerelease: false
|
sha256sum
|
||||||
- name: Release geosite.db
|
|
||||||
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
|
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
/.idea/
|
/.idea/
|
||||||
/vendor/
|
/vendor/
|
||||||
/geosite.db
|
/geosite.db
|
||||||
|
/rule-set/
|
||||||
@@ -1,54 +1,17 @@
|
|||||||
run:
|
|
||||||
timeout: 5m
|
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
enable-all: true
|
disable-all: true
|
||||||
disable:
|
enable:
|
||||||
- errcheck
|
- gofumpt
|
||||||
- wrapcheck
|
- govet
|
||||||
- varnamelen
|
- gci
|
||||||
- stylecheck
|
- staticcheck
|
||||||
- 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:
|
||||||
revive:
|
gci:
|
||||||
rules:
|
custom-order: true
|
||||||
- name: var-naming
|
sections:
|
||||||
disabled: true
|
- standard
|
||||||
govet:
|
- prefix(github.com/sagernet/)
|
||||||
enable-all: true
|
- default
|
||||||
disable:
|
staticcheck:
|
||||||
- composites
|
go: '1.20'
|
||||||
- fieldalignment
|
|
||||||
- shadow
|
|
||||||
gosec:
|
|
||||||
excludes:
|
|
||||||
- G404
|
|
||||||
|
|||||||
17
Makefile
Normal file
17
Makefile
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
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 ./...
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
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 .
|
|
||||||
25
go.mod
25
go.mod
@@ -1,21 +1,26 @@
|
|||||||
module sing-geosite
|
module github.com/sagernet/sing-geosite
|
||||||
|
|
||||||
go 1.18
|
go 1.18
|
||||||
|
|
||||||
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.0.0-20220707133944-6a0987c52ae4
|
github.com/sagernet/sing v0.2.18-0.20231129075305-eb56a60214be
|
||||||
github.com/sagernet/sing-box v0.0.0-20220708030046-d45007b50105
|
github.com/sagernet/sing-box v1.6.8-0.20231129123339-5a56487cf544
|
||||||
github.com/sirupsen/logrus v1.8.1
|
github.com/v2fly/v2ray-core/v5 v5.12.1
|
||||||
github.com/v2fly/v2ray-core/v5 v5.0.7
|
google.golang.org/protobuf v1.31.0
|
||||||
google.golang.org/protobuf v1.28.0
|
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/adrg/xdg v0.4.0 // indirect
|
github.com/adrg/xdg v0.4.0 // indirect
|
||||||
github.com/goccy/go-json v0.9.8 // indirect
|
github.com/golang/protobuf v1.5.3 // indirect
|
||||||
github.com/golang/protobuf v1.5.2 // indirect
|
|
||||||
github.com/google/go-querystring v1.1.0 // indirect
|
github.com/google/go-querystring v1.1.0 // indirect
|
||||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
|
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
|
||||||
golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b // indirect
|
github.com/miekg/dns v1.1.57 // indirect
|
||||||
|
github.com/sagernet/sing-dns v0.1.11 // indirect
|
||||||
|
go4.org/netipx v0.0.0-20230824141953-6213f710f925 // indirect
|
||||||
|
golang.org/x/crypto v0.15.0 // indirect
|
||||||
|
golang.org/x/mod v0.14.0 // indirect
|
||||||
|
golang.org/x/net v0.18.0 // indirect
|
||||||
|
golang.org/x/sys v0.14.0 // indirect
|
||||||
|
golang.org/x/tools v0.15.0 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
54
go.sum
54
go.sum
@@ -2,44 +2,52 @@ github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls=
|
|||||||
github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E=
|
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.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/goccy/go-json v0.9.8 h1:DxXB6MLd6yyel7CLph8EwNIonUtVZd3Ue5iRcL4DQCE=
|
|
||||||
github.com/goccy/go-json v0.9.8/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
|
||||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
||||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||||
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.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||||
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/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.57 h1:Jzi7ApEIzwEPLHWRcafCN9LZSBbqQpxjt/wpgvg7wcM=
|
||||||
|
github.com/miekg/dns v1.1.57/go.mod h1:uqRjCRUuEAA6qsOiJvDd+CFo/vW+y5WR6SNmHE55hZk=
|
||||||
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/sagernet/sing v0.0.0-20220707133944-6a0987c52ae4 h1:nV/DyNi+O1VxNoChD5E9M6Y0VoFdVr0UEW9h9JnqxNs=
|
github.com/sagernet/sing v0.2.18-0.20231129075305-eb56a60214be h1:FigAM9kq7RRXmHvgn8w2a8tqCY5CMV5GIk0id84dI0o=
|
||||||
github.com/sagernet/sing v0.0.0-20220707133944-6a0987c52ae4/go.mod h1:3ZmoGNg/nNJTyHAZFNRSPaXpNIwpDvyIiAUd0KIWV5c=
|
github.com/sagernet/sing v0.2.18-0.20231129075305-eb56a60214be/go.mod h1:OL6k2F0vHmEzXz2KW19qQzu172FDgSbUSODylighuVo=
|
||||||
github.com/sagernet/sing-box v0.0.0-20220708030046-d45007b50105 h1:MC20nFhcQaJjQiMahWidatu1fzVdGl69koGRo9f5HHE=
|
github.com/sagernet/sing-box v1.6.8-0.20231129123339-5a56487cf544 h1:kHe9kQpKMEmGJbTdDntXA0rl1BdQWQZtkDaxmZkAPC4=
|
||||||
github.com/sagernet/sing-box v0.0.0-20220708030046-d45007b50105/go.mod h1:K04trGDX9XELM/8iqkTxq4DCj1RxrgqfMOJg7m8yoHA=
|
github.com/sagernet/sing-box v1.6.8-0.20231129123339-5a56487cf544/go.mod h1:C5Gcyr9BsHs1Iq7eAY53hAlh/j+5fjJVsLA18z/7ZL4=
|
||||||
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
|
github.com/sagernet/sing-dns v0.1.11 h1:PPrMCVVrAeR3f5X23I+cmvacXJ+kzuyAsBiWyUKhGSE=
|
||||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
github.com/sagernet/sing-dns v0.1.11/go.mod h1:zJ/YjnYB61SYE+ubMcMqVdpaSvsyQ2iShQGO3vuLvvE=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||||
github.com/v2fly/v2ray-core/v5 v5.0.7 h1:wR8x5KyYpe0W35tcJz/dlkpCClDhc/xe+36BQjVV3EM=
|
github.com/v2fly/v2ray-core/v5 v5.12.1 h1:y7xdWEjQcjcNRjBbvFqWx9fdM/uMAp5kvy7xg45GQWk=
|
||||||
github.com/v2fly/v2ray-core/v5 v5.0.7/go.mod h1:whgevEWmA6LrAfnPoM97IGMYhUF8837sAZ4U6MNJfzk=
|
github.com/v2fly/v2ray-core/v5 v5.12.1/go.mod h1:97vMnLdw9DdKPR+ZmHL1Qd7By5jMzE5vW5936et9nI0=
|
||||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY=
|
go4.org/netipx v0.0.0-20230824141953-6213f710f925 h1:eeQDDVKFkx0g4Hyy8pHgmZaK0EqB4SD6rvKbUdN3ziQ=
|
||||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
go4.org/netipx v0.0.0-20230824141953-6213f710f925/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y=
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA=
|
||||||
|
golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g=
|
||||||
|
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
|
||||||
|
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||||
|
golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg=
|
||||||
|
golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
|
||||||
|
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
|
||||||
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b h1:2n253B2r0pYSmEV+UNCQoPfU/FiaizQEK5Gu4Bq4JE8=
|
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
|
||||||
golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
golang.org/x/tools v0.15.0 h1:zdAyfUGbYmuVokhzVmghFl2ZJh5QhcfebBgmVPFYA+8=
|
||||||
|
golang.org/x/tools v0.15.0/go.mod h1:hpksKq4dtpQWS1uQ61JkdqWM3LscIS6Slf+VVkm+wQk=
|
||||||
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.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
|
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
|
||||||
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
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/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.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=
|
||||||
|
|||||||
105
main.go
105
main.go
@@ -10,11 +10,15 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"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/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/sagernet/sing-box/log"
|
||||||
"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"
|
||||||
)
|
)
|
||||||
@@ -43,7 +47,7 @@ func fetch(from string) (*github.RepositoryRelease, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func get(downloadURL *string) ([]byte, error) {
|
func get(downloadURL *string) ([]byte, error) {
|
||||||
logrus.Info("download ", *downloadURL)
|
log.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
|
||||||
@@ -88,8 +92,15 @@ func parse(vGeositeData []byte) (map[string][]geosite.Item, error) {
|
|||||||
}
|
}
|
||||||
domainMap := make(map[string][]geosite.Item)
|
domainMap := make(map[string][]geosite.Item)
|
||||||
for _, vGeositeEntry := range vGeositeList.Entry {
|
for _, vGeositeEntry := range vGeositeList.Entry {
|
||||||
|
code := strings.ToLower(vGeositeEntry.CountryCode)
|
||||||
domains := make([]geosite.Item, 0, len(vGeositeEntry.Domain)*2)
|
domains := make([]geosite.Item, 0, len(vGeositeEntry.Domain)*2)
|
||||||
|
attributes := make(map[string][]*routercommon.Domain)
|
||||||
for _, domain := range vGeositeEntry.Domain {
|
for _, domain := range vGeositeEntry.Domain {
|
||||||
|
if len(domain.Attribute) > 0 {
|
||||||
|
for _, attribute := range domain.Attribute {
|
||||||
|
attributes[attribute.Key] = append(attributes[attribute.Key], domain)
|
||||||
|
}
|
||||||
|
}
|
||||||
switch domain.Type {
|
switch domain.Type {
|
||||||
case routercommon.Domain_Plain:
|
case routercommon.Domain_Plain:
|
||||||
domains = append(domains, geosite.Item{
|
domains = append(domains, geosite.Item{
|
||||||
@@ -119,12 +130,46 @@ func parse(vGeositeData []byte) (map[string][]geosite.Item, error) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
domainMap[strings.ToLower(vGeositeEntry.CountryCode)] = common.Uniq(domains)
|
domainMap[code] = common.Uniq(domains)
|
||||||
|
for attribute, attributeEntries := range attributes {
|
||||||
|
attributeDomains := make([]geosite.Item, 0, len(attributeEntries)*2)
|
||||||
|
for _, domain := range attributeEntries {
|
||||||
|
switch domain.Type {
|
||||||
|
case routercommon.Domain_Plain:
|
||||||
|
attributeDomains = append(attributeDomains, geosite.Item{
|
||||||
|
Type: geosite.RuleTypeDomainKeyword,
|
||||||
|
Value: domain.Value,
|
||||||
|
})
|
||||||
|
case routercommon.Domain_Regex:
|
||||||
|
attributeDomains = append(attributeDomains, geosite.Item{
|
||||||
|
Type: geosite.RuleTypeDomainRegex,
|
||||||
|
Value: domain.Value,
|
||||||
|
})
|
||||||
|
case routercommon.Domain_RootDomain:
|
||||||
|
if strings.Contains(domain.Value, ".") {
|
||||||
|
attributeDomains = append(attributeDomains, geosite.Item{
|
||||||
|
Type: geosite.RuleTypeDomain,
|
||||||
|
Value: domain.Value,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
attributeDomains = append(attributeDomains, geosite.Item{
|
||||||
|
Type: geosite.RuleTypeDomainSuffix,
|
||||||
|
Value: "." + domain.Value,
|
||||||
|
})
|
||||||
|
case routercommon.Domain_Full:
|
||||||
|
attributeDomains = append(attributeDomains, geosite.Item{
|
||||||
|
Type: geosite.RuleTypeDomain,
|
||||||
|
Value: domain.Value,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
domainMap[code+"@"+attribute] = common.Uniq(attributeDomains)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return domainMap, nil
|
return domainMap, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func generate(release *github.RepositoryRelease, output string) error {
|
func generate(release *github.RepositoryRelease, output string, ruleSetOutput string) error {
|
||||||
outputFile, err := os.Create(output)
|
outputFile, err := os.Create(output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -140,29 +185,65 @@ func generate(release *github.RepositoryRelease, output string) error {
|
|||||||
}
|
}
|
||||||
outputPath, _ := filepath.Abs(output)
|
outputPath, _ := filepath.Abs(output)
|
||||||
os.Stderr.WriteString("write " + outputPath + "\n")
|
os.Stderr.WriteString("write " + outputPath + "\n")
|
||||||
return geosite.Write(outputFile, domainMap)
|
err = geosite.Write(outputFile, domainMap)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
os.RemoveAll(ruleSetOutput)
|
||||||
|
err = os.MkdirAll(ruleSetOutput, 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"))
|
||||||
|
os.Stderr.WriteString("write " + srsPath + "\n")
|
||||||
|
outputRuleSet, err := os.Create(srsPath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = srs.Write(outputRuleSet, plainRuleSet)
|
||||||
|
if err != nil {
|
||||||
|
outputRuleSet.Close()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
outputRuleSet.Close()
|
||||||
|
}
|
||||||
|
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) error {
|
func release(source string, destination string, output string, ruleSetOutput 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 {
|
||||||
logrus.Warn("missing destination latest release")
|
log.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) {
|
||||||
logrus.Info("already latest")
|
log.Info("already latest")
|
||||||
setActionOutput("skip", "true")
|
setActionOutput("skip", "true")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err = generate(sourceRelease, output)
|
err = generate(sourceRelease, output, ruleSetOutput)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -171,8 +252,8 @@ func release(source string, destination string, output string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
err := release("v2fly/domain-list-community", "sagernet/sing-geosite", "geosite.db")
|
err := release("v2fly/domain-list-community", "sagernet/sing-geosite", "geosite.db", "rule-set")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user