ci: updated build and lint workflows (#152)

This commit is contained in:
Henrique Dias
2024-07-21 19:43:30 +02:00
committed by GitHub
parent 9433dbd452
commit 6f4be12e8c
5 changed files with 41 additions and 5 deletions
+17
View File
@@ -0,0 +1,17 @@
name: Build
on:
push:
tags:
- v*
branches:
- main
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22.x"
- run: go build .
+19
View File
@@ -0,0 +1,19 @@
name: Lint
on:
push:
tags:
- v*
branches:
- main
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22.x"
- uses: golangci/golangci-lint-action@v6
with:
version: "v1.59"
+1 -1
View File
@@ -71,7 +71,7 @@ set WD_CERT.`,
listener, err := net.Listen(lnet, laddr) listener, err := net.Listen(lnet, laddr)
sigc := make(chan os.Signal, 1) sigc := make(chan os.Signal, 1)
signal.Notify(sigc, os.Interrupt, os.Kill, syscall.SIGTERM) signal.Notify(sigc, os.Interrupt, syscall.SIGTERM)
go func(c chan os.Signal) { go func(c chan os.Signal) {
// Wait for a SIGINT or SIGKILL: // Wait for a SIGINT or SIGKILL:
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"golang.org/x/net/webdav" "golang.org/x/net/webdav"
) )
// Rule is a dissalow/allow rule. // Rule is a disallow/allow rule.
type Rule struct { type Rule struct {
Regex bool Regex bool
Allow bool Allow bool
+3 -3
View File
@@ -77,19 +77,19 @@ func (c *Config) ServeHTTP(w http.ResponseWriter, r *http.Request) {
username, password, ok := r.BasicAuth() username, password, ok := r.BasicAuth()
zap.L().Info("login attempt", zap.String("username", username), zap.String("remote_address", r.RemoteAddr)) zap.L().Info("login attempt", zap.String("username", username), zap.String("remote_address", r.RemoteAddr))
if !ok { if !ok {
http.Error(w, "Not authorized", 401) http.Error(w, "Not authorized", http.StatusUnauthorized)
return return
} }
user, ok := c.Users[username] user, ok := c.Users[username]
if !ok { if !ok {
http.Error(w, "Not authorized", 401) http.Error(w, "Not authorized", http.StatusUnauthorized)
return return
} }
if !checkPassword(user.Password, password) { if !checkPassword(user.Password, password) {
zap.L().Info("invalid password", zap.String("username", username), zap.String("remote_address", r.RemoteAddr)) zap.L().Info("invalid password", zap.String("username", username), zap.String("remote_address", r.RemoteAddr))
http.Error(w, "Not authorized", 401) http.Error(w, "Not authorized", http.StatusUnauthorized)
return return
} }