Tidy up + Enable automatic releases (#31) (#65)

This commit is contained in:
kayos 2023-02-02 21:23:32 -08:00 committed by GitHub
parent 88d5b4d875
commit b9b85e858f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 16 deletions

33
.github/workflows/build.yml vendored Normal file
View File

@ -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

View File

@ -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 ./...

View File

@ -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)
}