diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..c4f3145 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,39 @@ +name: Build +on: [push] + +jobs: + + test: + name: Test + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v1 + + - name: Test + run: go test -v . + + build: + name: Build + runs-on: ubuntu-latest + needs: [test] + steps: + + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v1 + + - name: Build + run: go build -v . \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..6cde770 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,27 @@ +name: Release +on: + create: + tags: + - v* + +jobs: + release: + name: Release on GitHub + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v1 + + - name: Validates GO releaser config + uses: docker://goreleaser/goreleaser:latest + with: + args: check + + - name: Create release on GitHub + uses: docker://goreleaser/goreleaser:latest + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + with: + args: release + if: success() + \ No newline at end of file diff --git a/.gitignore b/.gitignore index 370b4de..6e74173 100644 --- a/.gitignore +++ b/.gitignore @@ -19,7 +19,6 @@ .vscode dist -.goreleaser.yml *.zip /*.conf diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..059bd02 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,62 @@ +# Make sure to check the documentation at http://goreleaser.com + +# release: +# git tag -a v0.1.0 -m "v0.1.0" +# git push origin v0.1.0 +# goreleaser release --skip-publish --rm-dist + +# snapshot: +# goreleaser --snapshot --rm-dist + +# https://goreleaser.com/customization/ + +before: + hooks: + - go mod tidy + +# https://goreleaser.com/build/ +builds: + - env: + - CGO_ENABLED=0 + goos: + - windows + - linux + - darwin + goarch: + - 386 + - amd64 + - arm + - arm64 + - mips + - mipsle + - mips64 + - mips64le + goarm: + - 6 + - 7 + + ignore: + - goos: darwin + goarch: 386 + +# https://goreleaser.com/archive/ +archive: + name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" + wrap_in_directory: true + format: tar.gz + format_overrides: + - goos: windows + format: zip + files: + - LICENSE + - README.md + - config/**/* + - systemd/* + +# https://goreleaser.com/snapshots/ +snapshot: + name_template: "dev@{{.ShortCommit}}" + +# https://goreleaser.com/checksum/ +checksum: + name_template: "{{ .ProjectName }}_{{ .Version }}_checksums.txt" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6a64f07..0000000 --- a/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: go - -go: - - "1.13.x" - - master diff --git a/README.md b/README.md index 261809b..4205188 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ Binary: - [https://github.com/nadoo/glider/releases](https://github.com/nadoo/glider/releases) -Go Get (requires **Go 1.12+** ): +Go Get (requires **Go 1.13+** ): ```bash go get -u github.com/nadoo/glider diff --git a/conf.go b/conf.go index e64b916..c95ae94 100644 --- a/conf.go +++ b/conf.go @@ -103,7 +103,7 @@ func confInit() { func usage() { app := os.Args[0] fmt.Fprintf(os.Stderr, "\n") - fmt.Fprintf(os.Stderr, "%s v%s usage:\n", app, VERSION) + fmt.Fprintf(os.Stderr, "%s v%s usage:\n", app, version) flag.PrintDefaults() fmt.Fprintf(os.Stderr, "\n") diff --git a/main.go b/main.go index 43a4728..44f1f77 100644 --- a/main.go +++ b/main.go @@ -29,13 +29,9 @@ import ( _ "github.com/nadoo/glider/proxy/ws" ) -// VERSION . -const VERSION = "0.7.1" +var version = "dev" func main() { - // TODO: remove this line when Go1.13 is released. - os.Setenv("GODEBUG", os.Getenv("GODEBUG")+",tls13=1") - // read configs confInit() diff --git a/proxy/http/http.go b/proxy/http/http.go index e69d9af..5f6f26a 100644 --- a/proxy/http/http.go +++ b/proxy/http/http.go @@ -310,22 +310,14 @@ func cleanHeaders(header textproto.MIMEHeader) { } func writeFirstLine(buf *bytes.Buffer, s1, s2, s3 string) { - buf.Write([]byte(s1)) - buf.Write([]byte(" ")) - buf.Write([]byte(s2)) - buf.Write([]byte(" ")) - buf.Write([]byte(s3)) - buf.Write([]byte("\r\n")) + buf.WriteString(s1 + " " + s2 + " " + s3 + "\r\n") } func writeHeaders(buf *bytes.Buffer, header textproto.MIMEHeader) { for key, values := range header { for _, v := range values { - buf.Write([]byte(key)) - buf.Write([]byte(": ")) - buf.Write([]byte(v)) - buf.Write([]byte("\r\n")) + buf.WriteString(key + ": " + v + "\r\n") } } - buf.Write([]byte("\r\n")) + buf.WriteString("\r\n") } diff --git a/rule/rule.go b/rule/rule.go index 67f4698..582c0ca 100644 --- a/rule/rule.go +++ b/rule/rule.go @@ -100,14 +100,14 @@ func (rd *Dialer) NextDialer(dstAddr string) proxy.Dialer { // Dial dials to targer addr and return a conn func (rd *Dialer) Dial(network, addr string) (net.Conn, error) { d := rd.NextDialer(addr) - log.F("[Dial] %s => %s", addr, d.Addr()) + log.F("[dial] %s => %s", addr, d.Addr()) return d.Dial(network, addr) } // DialUDP connects to the given address via the proxy func (rd *Dialer) DialUDP(network, addr string) (pc net.PacketConn, writeTo net.Addr, err error) { d := rd.NextDialer(addr) - log.F("[DialUDP] %s => %s", addr, d.Addr()) + log.F("[dial-udp] %s => %s", addr, d.Addr()) return d.DialUDP(network, addr) }