add github action
This commit is contained in:
parent
15a68623ab
commit
f3411832a8
74
.github/workflows/buildx.yaml
vendored
Normal file
74
.github/workflows/buildx.yaml
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
# ref: https://github.com/crazy-max/diun/blob/master/.github/workflows/build.yml
|
||||
|
||||
name: Docker
|
||||
on: [push]
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Prepare
|
||||
id: prepare
|
||||
run: |
|
||||
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||
echo ::set-output name=version::${GITHUB_REF#refs/tags/v}
|
||||
elif [[ $GITHUB_REF == refs/heads/master ]]; then
|
||||
echo ::set-output name=version::latest
|
||||
elif [[ $GITHUB_REF == refs/heads/* ]]; then
|
||||
echo ::set-output name=version::${GITHUB_REF#refs/heads/}
|
||||
else
|
||||
echo ::set-output name=version::snapshot
|
||||
fi
|
||||
|
||||
echo ::set-output name=docker_platforms::linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/386
|
||||
echo ::set-output name=docker_image::${{ secrets.DOCKER_IMAGE }}
|
||||
|
||||
# https://github.com/crazy-max/ghaction-docker-buildx
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: crazy-max/ghaction-docker-buildx@v1
|
||||
with:
|
||||
version: latest
|
||||
|
||||
- name: Environment
|
||||
run: |
|
||||
echo home=$HOME
|
||||
echo git_ref=$GITHUB_REF
|
||||
echo git_sha=$GITHUB_SHA
|
||||
echo version=${{ steps.prepare.outputs.version }}
|
||||
echo image=${{ steps.prepare.outputs.docker_image }}
|
||||
echo platforms=${{ steps.prepare.outputs.docker_platforms }}
|
||||
echo avail_platforms=${{ steps.buildx.outputs.platforms }}
|
||||
|
||||
# https://github.com/actions/checkout
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Docker Buildx (no push)
|
||||
run: |
|
||||
docker buildx bake \
|
||||
--set ${{ github.event.repository.name }}.platform=${{ steps.prepare.outputs.docker_platforms }} \
|
||||
--set ${{ github.event.repository.name }}.output=type=image,push=false \
|
||||
--set ${{ github.event.repository.name }}.tags="${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}" \
|
||||
--file docker-compose.yaml
|
||||
|
||||
- name: Docker Login
|
||||
if: success()
|
||||
env:
|
||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||
run: |
|
||||
echo "${DOCKER_PASSWORD}" | docker login --username "${{ secrets.DOCKER_USERNAME }}" --password-stdin
|
||||
|
||||
- name: Docker Buildx (push)
|
||||
if: success()
|
||||
run: |
|
||||
docker buildx bake \
|
||||
--set ${{ github.event.repository.name }}.platform=${{ steps.prepare.outputs.docker_platforms }} \
|
||||
--set ${{ github.event.repository.name }}.output=type=image,push=true \
|
||||
--set ${{ github.event.repository.name }}.tags="${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}" \
|
||||
--file docker-compose.yaml
|
||||
|
||||
- name: Clear
|
||||
if: always()
|
||||
run: |
|
||||
rm -f ${HOME}/.docker/config.json
|
||||
|
25
Dockerfile
Normal file
25
Dockerfile
Normal file
@ -0,0 +1,25 @@
|
||||
FROM --platform=$BUILDPLATFORM golang:1-alpine as builder
|
||||
|
||||
# Convert TARGETPLATFORM to GOARCH format
|
||||
# https://github.com/tonistiigi/xx
|
||||
COPY --from=tonistiigi/xx:golang / /
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
|
||||
RUN apk add --no-cache musl-dev git gcc
|
||||
|
||||
ADD . /src
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
ENV GO111MODULE=on
|
||||
|
||||
RUN cd cmd/gost && go env && go build -v
|
||||
|
||||
FROM alpine:latest
|
||||
|
||||
WORKDIR /bin/
|
||||
|
||||
COPY --from=builder /src/cmd/gost/gost .
|
||||
|
||||
ENTRYPOINT ["/bin/gost"]
|
99
Makefile
Normal file
99
Makefile
Normal file
@ -0,0 +1,99 @@
|
||||
NAME=gost
|
||||
BINDIR=bin
|
||||
VERSION=$(shell cat cmd/gost/version.go | grep 'version =' | sed 's/.*\"\(.*\)\".*/\1/g')
|
||||
GOBUILD=CGO_ENABLED=0 go build --ldflags="-s -w" -v -x -a
|
||||
GOFILES=cmd/gost/*
|
||||
|
||||
PLATFORM_LIST = \
|
||||
darwin-amd64 \
|
||||
darwin-arm64 \
|
||||
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
|
||||
|
||||
darwin-amd64:
|
||||
GOARCH=amd64 GOOS=darwin $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
|
||||
|
||||
darwin-arm64:
|
||||
GOARCH=arm64 GOOS=darwin $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
|
||||
|
||||
linux-386:
|
||||
GOARCH=386 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
|
||||
|
||||
linux-amd64:
|
||||
GOARCH=amd64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
|
||||
|
||||
linux-armv5:
|
||||
GOARCH=arm GOOS=linux GOARM=5 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
|
||||
|
||||
linux-armv6:
|
||||
GOARCH=arm GOOS=linux GOARM=6 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
|
||||
|
||||
linux-armv7:
|
||||
GOARCH=arm GOOS=linux GOARM=7 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
|
||||
|
||||
linux-armv8:
|
||||
GOARCH=arm64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
|
||||
|
||||
linux-mips-softfloat:
|
||||
GOARCH=mips GOMIPS=softfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
|
||||
|
||||
linux-mips-hardfloat:
|
||||
GOARCH=mips GOMIPS=hardfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
|
||||
|
||||
linux-mipsle-softfloat:
|
||||
GOARCH=mipsle GOMIPS=softfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
|
||||
|
||||
linux-mipsle-hardfloat:
|
||||
GOARCH=mipsle GOMIPS=hardfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
|
||||
|
||||
linux-mips64:
|
||||
GOARCH=mips64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
|
||||
|
||||
linux-mips64le:
|
||||
GOARCH=mips64le GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
|
||||
|
||||
freebsd-386:
|
||||
GOARCH=386 GOOS=freebsd $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
|
||||
|
||||
freebsd-amd64:
|
||||
GOARCH=amd64 GOOS=freebsd $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
|
||||
|
||||
windows-386:
|
||||
GOARCH=386 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe $(GOFILES)
|
||||
|
||||
windows-amd64:
|
||||
GOARCH=amd64 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe $(GOFILES)
|
||||
|
||||
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)/*
|
@ -1,27 +0,0 @@
|
||||
log:
|
||||
level: debug
|
||||
services:
|
||||
- name: service-0
|
||||
url: udp://:10053/192.168.8.8:53,192.168.8.1:53
|
||||
addr: :10053
|
||||
chain: chain-0
|
||||
listener:
|
||||
type: udp
|
||||
handler:
|
||||
type: udp
|
||||
forwarder:
|
||||
targets:
|
||||
- 192.168.8.8:53
|
||||
- 192.168.8.1:53
|
||||
chains:
|
||||
- name: chain-0
|
||||
hops:
|
||||
- name: hop-0
|
||||
nodes:
|
||||
- name: node-0
|
||||
url: relay://:8420
|
||||
addr: :8420
|
||||
dialer:
|
||||
type: tcp
|
||||
connector:
|
||||
type: relay
|
@ -1,115 +0,0 @@
|
||||
log:
|
||||
output: stderr # stderr, stdout, /path/to/file
|
||||
level: debug # debug, info, warn, error, fatal
|
||||
format: json # text, json
|
||||
|
||||
profiling:
|
||||
addr: ":6060"
|
||||
enabled: true
|
||||
|
||||
services:
|
||||
- name: socks5
|
||||
addr: ":21080"
|
||||
handler:
|
||||
type: socks5
|
||||
metadata:
|
||||
readTimeout: 5s
|
||||
retry: 3
|
||||
udp: true
|
||||
bufferSize: 4096
|
||||
listener:
|
||||
type: tcp
|
||||
metadata:
|
||||
keepAlive: 15s
|
||||
- name: ss
|
||||
addr: ":28338"
|
||||
handler:
|
||||
type: ss
|
||||
metadata:
|
||||
method: chacha20-ietf
|
||||
password: gost
|
||||
readTimeout: 5s
|
||||
retry: 3
|
||||
udp: true
|
||||
bufferSize: 4096
|
||||
listener:
|
||||
type: udp
|
||||
metadata:
|
||||
keepAlive: 15s
|
||||
- name: relay-proxy
|
||||
addr: ":28080"
|
||||
chain: chain-socks5
|
||||
handler:
|
||||
type: relay
|
||||
metadata:
|
||||
readTimeout: 5s
|
||||
listener:
|
||||
type: tcp
|
||||
metadata:
|
||||
keepAlive: 15s
|
||||
|
||||
chains:
|
||||
- name: chain-socks5
|
||||
hops:
|
||||
- name: hop01
|
||||
nodes:
|
||||
- name: node01
|
||||
addr: ":21080"
|
||||
connector:
|
||||
type: socks5
|
||||
metadata:
|
||||
readTimeout: 5s
|
||||
bufferSize: 4096
|
||||
notls: true
|
||||
dialer:
|
||||
type: tcp
|
||||
metadata: {}
|
||||
|
||||
- name: chain-ss
|
||||
hops:
|
||||
- name: hop01
|
||||
nodes:
|
||||
- name: node01
|
||||
addr: ":28338"
|
||||
connector:
|
||||
type: ss
|
||||
metadata:
|
||||
method: chacha20-ietf
|
||||
password: gost
|
||||
readTimeout: 5s
|
||||
nodelay: true
|
||||
udp: true
|
||||
bufferSize: 4096
|
||||
dialer:
|
||||
type: udp
|
||||
metadata: {}
|
||||
|
||||
bypasses:
|
||||
- name: bypass01
|
||||
reverse: false
|
||||
matchers:
|
||||
- .baidu.com
|
||||
- "*.example.com" # domain wildcard
|
||||
- .example.org # will match example.org and *.example.org
|
||||
|
||||
# From IANA IPv4 Special-Purpose Address Registry
|
||||
# http://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
|
||||
- 0.0.0.0/8 # RFC1122: "This host on this network"
|
||||
- 10.0.0.0/8 # RFC1918: Private-Use
|
||||
- 100.64.0.0/10 # RFC6598: Shared Address Space
|
||||
- 127.0.0.0/8 # RFC1122: Loopback
|
||||
- 169.254.0.0/16 # RFC3927: Link Local
|
||||
- 172.16.0.0/12 # RFC1918: Private-Use
|
||||
- 192.0.0.0/24 # RFC6890: IETF Protocol Assignments
|
||||
- 192.0.2.0/24 # RFC5737: Documentation (TEST-NET-1)
|
||||
- 192.88.99.0/24 # RFC3068: 6to4 Relay Anycast
|
||||
- 192.168.0.0/16 # RFC1918: Private-Use
|
||||
- 198.18.0.0/15 # RFC2544: Benchmarking
|
||||
- 198.51.100.0/24 # RFC5737: Documentation (TEST-NET-2)
|
||||
- 203.0.113.0/24 # RFC5737: Documentation (TEST-NET-3)
|
||||
- 240.0.0.0/4 # RFC1112: Reserved
|
||||
- 255.255.255.255/32 # RFC0919: Limited Broadcast
|
||||
|
||||
# From IANA Multicast Address Space Registry
|
||||
# http://www.iana.org/assignments/multicast-addresses/multicast-addresses.xhtml
|
||||
- 224.0.0.0/4 # RFC5771: Multicast/Reserved
|
4
docker-compose.yaml
Normal file
4
docker-compose.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
version: "3.4"
|
||||
services:
|
||||
gost:
|
||||
build: .
|
Loading…
Reference in New Issue
Block a user