forked from zu1k/proxypool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zu1k
committed
Aug 11, 2020
0 parents
commit d1c539f
Showing
26 changed files
with
1,219 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# These are supported funding model platforms | ||
|
||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] ['zu1k'] | ||
patreon: zu1k # Replace with a single Patreon username | ||
open_collective: # Replace with a single Open Collective username | ||
ko_fi: # Replace with a single Ko-fi username | ||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | ||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | ||
liberapay: # Replace with a single Liberapay username | ||
issuehunt: # Replace with a single IssueHunt username | ||
otechie: # Replace with a single Otechie username | ||
custom: ['https://blog.lgf.im/donate/']# Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
|
||
- package-ecosystem: "docker" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
|
||
- package-ecosystem: "gomod" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: docker | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
if: startsWith(github.ref, 'refs/tags/') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code into the Go module directory | ||
uses: actions/[email protected] | ||
|
||
- name: Build and push Docker images | ||
uses: docker/[email protected] | ||
with: | ||
username: zu1k | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
registry: docker.pkg.github.com | ||
repository: zu1k/proxypool/proxypool | ||
tag_with_ref: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Go | ||
on: [push, pull_request] | ||
jobs: | ||
|
||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.14.x | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/[email protected] | ||
|
||
- name: Cache go module | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Get dependencies and run test | ||
run: | | ||
go test ./... | ||
- name: Build | ||
if: startsWith(github.ref, 'refs/tags/') | ||
env: | ||
NAME: proxypool | ||
BINDIR: bin | ||
run: make -j releases | ||
|
||
- name: Upload Release | ||
uses: softprops/action-gh-release@v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
files: bin/* | ||
draft: true | ||
prerelease: true | ||
|
||
- uses: actions/[email protected] | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
name: build | ||
path: bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
bin/* | ||
|
||
# Test binary, build with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# dep | ||
vendor | ||
|
||
# GoLand | ||
.idea/* | ||
|
||
# macOS file | ||
.DS_Store | ||
|
||
*.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM golang:alpine as builder | ||
|
||
RUN apk add --no-cache make git | ||
WORKDIR /proxypool-src | ||
COPY . /proxypool-src | ||
RUN go mod download && \ | ||
make docker && \ | ||
mv ./bin/proxypool-docker /proxypool | ||
|
||
FROM alpine:latest | ||
|
||
RUN apk add --no-cache ca-certificates | ||
COPY --from=builder /proxypool / | ||
ENTRYPOINT ["/proxypool"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright © 2020 zu1k | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
NAME=proxypool | ||
BINDIR=bin | ||
VERSION=$(shell git describe --tags || echo "unknown version") | ||
GOBUILD=CGO_ENABLED=0 go build -trimpath -ldflags '-w -s' | ||
|
||
PLATFORM_LIST = \ | ||
darwin-amd64 \ | ||
linux-386 \ | ||
linux-amd64 \ | ||
linux-armv5 \ | ||
linux-armv6 \ | ||
linux-armv7 \ | ||
linux-armv8 \ | ||
linux-mips-softfloat \ | ||
linux-mips-hardfloat \ | ||
linux-mipsle-softfloat \ | ||
linux-mipsle-hardfloat \ | ||
linux-mips64 \ | ||
linux-mips64le \ | ||
freebsd-386 \ | ||
freebsd-amd64 | ||
|
||
WINDOWS_ARCH_LIST = \ | ||
windows-386 \ | ||
windows-amd64 | ||
|
||
all: linux-amd64 darwin-amd64 windows-amd64 # Most used | ||
|
||
docker: | ||
$(GOBUILD) -o $(BINDIR)/$(NAME)-$@ | ||
|
||
darwin-amd64: | ||
GOARCH=amd64 GOOS=darwin $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ | ||
|
||
linux-386: | ||
GOARCH=386 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ | ||
|
||
linux-amd64: | ||
GOARCH=amd64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ | ||
|
||
linux-armv5: | ||
GOARCH=arm GOOS=linux GOARM=5 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ | ||
|
||
linux-armv6: | ||
GOARCH=arm GOOS=linux GOARM=6 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ | ||
|
||
linux-armv7: | ||
GOARCH=arm GOOS=linux GOARM=7 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ | ||
|
||
linux-armv8: | ||
GOARCH=arm64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ | ||
|
||
linux-mips-softfloat: | ||
GOARCH=mips GOMIPS=softfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ | ||
|
||
linux-mips-hardfloat: | ||
GOARCH=mips GOMIPS=hardfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ | ||
|
||
linux-mipsle-softfloat: | ||
GOARCH=mipsle GOMIPS=softfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ | ||
|
||
linux-mipsle-hardfloat: | ||
GOARCH=mipsle GOMIPS=hardfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ | ||
|
||
linux-mips64: | ||
GOARCH=mips64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ | ||
|
||
linux-mips64le: | ||
GOARCH=mips64le GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ | ||
|
||
freebsd-386: | ||
GOARCH=386 GOOS=freebsd $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ | ||
|
||
freebsd-amd64: | ||
GOARCH=amd64 GOOS=freebsd $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ | ||
|
||
windows-386: | ||
GOARCH=386 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe | ||
|
||
windows-amd64: | ||
GOARCH=amd64 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe | ||
|
||
gz_releases=$(addsuffix .gz, $(PLATFORM_LIST)) | ||
zip_releases=$(addsuffix .zip, $(WINDOWS_ARCH_LIST)) | ||
|
||
$(gz_releases): %.gz : % | ||
chmod +x $(BINDIR)/$(NAME)-$(basename $@) | ||
gzip -f -S -$(VERSION).gz $(BINDIR)/$(NAME)-$(basename $@) | ||
|
||
$(zip_releases): %.zip : % | ||
zip -m -j $(BINDIR)/$(NAME)-$(basename $@)-$(VERSION).zip $(BINDIR)/$(NAME)-$(basename $@).exe | ||
|
||
all-arch: $(PLATFORM_LIST) $(WINDOWS_ARCH_LIST) | ||
|
||
releases: $(gz_releases) $(zip_releases) | ||
clean: | ||
rm $(BINDIR)/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package api | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/gin-gonic/gin" | ||
_ "github.com/heroku/x/hmetrics/onload" | ||
"github.com/zu1k/proxypool/app" | ||
"github.com/zu1k/proxypool/provider" | ||
) | ||
|
||
var router *gin.Engine | ||
|
||
func setupRouter() { | ||
router = gin.Default() | ||
|
||
router.GET("/clash/proxies", func(c *gin.Context) { | ||
proxies := app.GetProxies() | ||
clash := provider.Clash{Proxies: proxies} | ||
c.String(200, clash.Provide()) | ||
}) | ||
} | ||
|
||
func Run() { | ||
setupRouter() | ||
port := os.Getenv("PORT") | ||
if port == "" { | ||
port = "8080" | ||
} | ||
router.Run(":" + port) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package app | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/zu1k/proxypool/proxy" | ||
|
||
"github.com/patrickmn/go-cache" | ||
) | ||
|
||
var c = cache.New(cache.NoExpiration, 10*time.Minute) | ||
|
||
func GetProxies() []proxy.Proxy { | ||
result, found := c.Get("proxies") | ||
if found { | ||
return result.([]proxy.Proxy) | ||
} | ||
return nil | ||
} | ||
|
||
func SetProxies(proxies []proxy.Proxy) { | ||
c.Set("proxies", proxies, cache.NoExpiration) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package app | ||
|
||
import ( | ||
"github.com/jasonlvhit/gocron" | ||
) | ||
|
||
func Cron() { | ||
gocron.Every(10).Minutes().Do(CrawlTGChannel) | ||
|
||
<-gocron.Start() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package app | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/zu1k/proxypool/getter" | ||
"github.com/zu1k/proxypool/proxy" | ||
) | ||
|
||
func CrawlTGChannel() { | ||
node := make([]proxy.Proxy, 0) | ||
node = append(node, getter.NewTGSsrlistGetter("https://t.me/s/ssrList", 200).Get()...) | ||
node = append(node, getter.NewTGSsrlistGetter("https://t.me/s/SSRSUB", 200).Get()...) | ||
node = append(node, getter.NewTGSsrlistGetter("https://t.me/s/FreeSSRNode", 200).Get()...) | ||
node = append(node, getter.NewTGSsrlistGetter("https://t.me/s/ssrlists", 200).Get()...) | ||
|
||
node = append(node, GetProxies()...) | ||
node = proxy.Deduplication(node) | ||
fmt.Println(len(node)) | ||
SetProxies(node) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# port of HTTP | ||
port: 7890 | ||
|
||
# port of SOCKS5 | ||
socks-port: 7891 | ||
|
||
# (HTTP and SOCKS5 in one port) | ||
# mixed-port: 7890 | ||
|
||
# redir port for Linux and macOS | ||
# redir-port: 7892 | ||
|
||
allow-lan: false | ||
mode: rule | ||
log-level: info | ||
external-controller: 127.0.0.1:9090 | ||
|
||
proxies: | ||
|
||
proxy-groups: | ||
- name: free | ||
type: select | ||
use: | ||
- free | ||
proxies: | ||
- DIRECT | ||
|
||
proxy-providers: | ||
free: | ||
type: http | ||
url: "http://127.0.0.1:8080/clash/proxies" | ||
interval: 3600 | ||
path: ./free.yaml | ||
health-check: | ||
enable: true | ||
interval: 600 | ||
url: http://www.gstatic.com/generate_204 | ||
|
||
rules: | ||
- IP-CIDR,127.0.0.0/8,DIRECT | ||
- IP-CIDR,192.168.0.0/16,DIRECT | ||
- MATCH,free |
Oops, something went wrong.