Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
---
linters:
enable:
# - goimports
# - misspell
- forbidigo
- goimports
- misspell
# - revive
- whitespace

issues:
exclude-rules:
- path: _test.go
linters:
- errcheck

linters-settings:
forbidigo:
forbid:
- p: ^fmt\.Print.*$
msg: Do not commit print statements. Use logger package.
- p: ^log\.(Fatal|Panic|Print)(f|ln)?.*$
msg: Do not commit log statements. Use logger package.
4 changes: 0 additions & 4 deletions prometheus.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package kvm

import (
"net/http"

"github.com/prometheus/client_golang/prometheus"
versioncollector "github.com/prometheus/client_golang/prometheus/collectors/version"
"github.com/prometheus/common/version"
)

var promHandler http.Handler

func initPrometheus() {
// A Prometheus metrics endpoint.
version.Version = builtAppVersion
Expand Down
1 change: 0 additions & 1 deletion serial.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ func runATXControl() {
newLedPWRState != ledPWRState ||
newBtnRSTState != btnRSTState ||
newBtnPWRState != btnPWRState {

logger.Debugf("Status changed: HDD LED: %v, PWR LED: %v, RST BTN: %v, PWR BTN: %v",
newLedHDDState, newLedPWRState, newBtnRSTState, newBtnPWRState)

Expand Down
2 changes: 1 addition & 1 deletion web.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"golang.org/x/crypto/bcrypt"
)

//nolint:typecheck
//go:embed all:static
var staticFiles embed.FS

Expand Down Expand Up @@ -419,7 +420,6 @@ func handleSetup(c *gin.Context) {

// Set the cookie
c.SetCookie("authToken", config.LocalAuthToken, 7*24*60*60, "/", "", false, true)

} else {
// For noPassword mode, ensure the password field is empty
config.HashedPassword = ""
Expand Down
8 changes: 4 additions & 4 deletions web_tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"log"
"math/big"
"net"
"net/http"
"os"
"strings"
"sync"
"time"
Expand All @@ -38,7 +38,7 @@ func RunWebSecureServer() {
TLSConfig: &tls.Config{
// TODO: cache certificate in persistent storage
GetCertificate: func(info *tls.ClientHelloInfo) (*tls.Certificate, error) {
hostname := WebSecureSelfSignedDefaultDomain
var hostname string
if info.ServerName != "" {
hostname = info.ServerName
} else {
Expand All @@ -58,7 +58,6 @@ func RunWebSecureServer() {
if err != nil {
panic(err)
}
return
}

func createSelfSignedCert(hostname string) *tls.Certificate {
Expand All @@ -72,7 +71,8 @@ func createSelfSignedCert(hostname string) *tls.Certificate {

priv, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
if err != nil {
log.Fatalf("Failed to generate private key: %v", err)
logger.Errorf("Failed to generate private key: %v", err)
os.Exit(1)
}
keyUsage := x509.KeyUsageDigitalSignature

Expand Down