diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f265c9e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,33 @@ +Name: Build and Release + +on: + push: + branches: [ master ] + +jobs: + releases-matrix: + name: Build and Release + runs-on: ubuntu-latest + strategy: + matrix: + goos: [linux, windows, darwin] + goarch: ["386", amd64, arm64] + exclude: + - goarch: "386" + goos: darwin + - goarch: arm64 + goos: windows + steps: + - uses: actions/checkout@v3 + - uses: wangyoucao577/go-release-action@v1.35 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + goos: ${{ matrix.goos }} + goarch: ${{ matrix.goarch }} + goversion: "https://dl.google.com/go/go1.19.5.linux-amd64.tar.gz" + project_path: "./cmd/HellPot" + binary_name: "HellPot" + extra_files: LICENSE README.md + build_flags: -trimpath + pre_command: export CGO_ENABLED=0 + ldflags: -s -w diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 2289b72..bb353db 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -14,7 +14,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.18 + go-version: 1.19 - name: go vet -v ./... run: go vet -v ./... - name: gosec ./... @@ -22,5 +22,7 @@ jobs: export PATH=$PATH:$(go env GOPATH)/bin go install github.com/securego/gosec/v2/cmd/gosec@latest gosec ./... + - name: go test -v ./... + run: go test -v ./... - name: go build -v ./... run: go build -v ./... diff --git a/internal/http/router_unix.go b/internal/http/router_unix.go index 82cf0c0..978ad48 100644 --- a/internal/http/router_unix.go +++ b/internal/http/router_unix.go @@ -18,20 +18,25 @@ func listenOnUnixSocket(addr string, r *router.Router) error { var unixAddr *net.UnixAddr var unixListener *net.UnixListener unixAddr, err = net.ResolveUnixAddr("unix", addr) - if err == nil { - // Always unlink sockets before listening on them - _ = syscall.Unlink(addr) - // Before we set socket permissions, we want to make sure only the user HellPot is running under - // has permission to the socket. - oldmask := syscall.Umask(0o077) - unixListener, err = net.ListenUnix("unix", unixAddr) - syscall.Umask(oldmask) - if err == nil { - err = os.Chmod(unixAddr.Name, os.FileMode(config.UnixSocketPermissions)) - if err == nil { - err = fasthttp.Serve(unixListener, r.Handler) - } - } + if err != nil { + return err } - return err + // Always unlink sockets before listening on them + _ = syscall.Unlink(addr) + // Before we set socket permissions, we want to make sure only the user HellPot is running under + // has permission to the socket. + oldmask := syscall.Umask(0o077) + unixListener, err = net.ListenUnix("unix", unixAddr) + syscall.Umask(oldmask) + if err != nil { + return err + } + if err = os.Chmod( + unixAddr.Name, + os.FileMode(config.UnixSocketPermissions), + ); err != nil { + return err + } + + return fasthttp.Serve(unixListener, r.Handler) }