From 2fc2eefe9abace0ba69b0e5214b626d3e5eae2c2 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 26 May 2024 09:27:40 -0700 Subject: [PATCH 001/192] Bug fixes --- pkg/bindata/templates/tunnel.html | 10 ++++++---- pkg/client/html_templates.go | 5 ++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pkg/bindata/templates/tunnel.html b/pkg/bindata/templates/tunnel.html index c81fea51c..f9066a67b 100644 --- a/pkg/bindata/templates/tunnel.html +++ b/pkg/bindata/templates/tunnel.html @@ -11,8 +11,8 @@

Site Tunnel

Click the Ping button, and select the tunnel with the fastest response time as your primary. Select any other tunnel as backup. Again, choose one with a faster response time.

-

-

  • Active Tunnel: {{(cache "activeTunnel").Data}}
  • +

    {{$activeTunnel := (cache "activeTunnel")}} +

  • Active Tunnel: {{if $activeTunnel}}{{$activeTunnel.Data}}{{else}}unknown{{end}}
  • @@ -68,7 +68,8 @@

    Site Tunnel

    Tunnel Stats

    - {{- range $socket, $stats := .PoolStats }} + {{- if .Tunnel }} + {{- range $socket, $stats := .Tunnel.PoolStats }} @@ -81,6 +82,7 @@

    Tunnel Stats

    - {{- end}} + {{- end }} + {{- end }}
    Socket URL ({{if $stats.Active}}active{{else}}inactive{{end}}) {{$socket}}
    Last Connection{{since $stats.LastConn}}
    Last Active Check{{since $stats.LastTry}}
    diff --git a/pkg/client/html_templates.go b/pkg/client/html_templates.go index 70c7c6766..e15dbc710 100644 --- a/pkg/client/html_templates.go +++ b/pkg/client/html_templates.go @@ -412,7 +412,7 @@ type templateData struct { Headers http.Header `json:"headers"` ProxyAllow bool `json:"proxyAllow"` UpstreamIP string `json:"upstreamIp"` - Tunnel *mulery.Config `json:"tunnel"` + Tunnel *mulery.Client `json:"tunnel"` PoolStats map[string]*mulery.PoolSize `json:"poolStats"` } @@ -450,8 +450,7 @@ func (c *Client) renderTemplate( //nolint:funlen ClientInfo: clientInfo, Disks: c.getDisks(ctx), Headers: req.Header, - Tunnel: c.tunnel.Config, - PoolStats: c.tunnel.PoolStats(), + Tunnel: c.tunnel, Version: map[string]interface{}{ "started": version.Started.Round(time.Second), "program": c.Flags.Name(), From 692f9e6c60811d68ddee9ec4d706b84bd44828f6 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 26 May 2024 10:32:36 -0700 Subject: [PATCH 002/192] darken tunnel page --- pkg/bindata/templates/tunnel.html | 45 +++++++++++++------------------ 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/pkg/bindata/templates/tunnel.html b/pkg/bindata/templates/tunnel.html index f9066a67b..517bbc393 100644 --- a/pkg/bindata/templates/tunnel.html +++ b/pkg/bindata/templates/tunnel.html @@ -9,7 +9,7 @@

    Site Tunnel

    Click the Ping button, and select the tunnel with the fastest response time as your primary. - Select any other tunnel as backup. Again, choose one with a faster response time. + Select another fast tunnel as backup.

    {{$activeTunnel := (cache "activeTunnel")}}

  • Active Tunnel: {{if $activeTunnel}}{{$activeTunnel.Data}}{{else}}unknown{{end}}
  • @@ -19,30 +19,30 @@

    Site Tunnel


    -
    - Primary Tunnel +
    + + + + +
    +
    +

    Primary Tunnel

    -
    -
    + {{- range $idx, $mule := .ClientInfo.User.Mulery}} {{$primary := and (gt (len $.ClientInfo.User.Tunnels) 0) (eq (index $.ClientInfo.User.Tunnels 0) $mule.Socket)}} -
    -
    - -
    -
    +
    + + + + {{- end}} - - - -
    - Backup Tunnel +
    - - - + {{$mule.Socket}}
    +

    Backup Tunnel

    - -
    - - - - -
    -
    -

    From 5e0d30b8265625618bf02a4a24461d44dec65648 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 26 May 2024 10:36:54 -0700 Subject: [PATCH 003/192] update go deps --- go.mod | 32 ++++++++++++------------- go.sum | 74 ++++++++++++++++++++++++++++------------------------------ 2 files changed, 52 insertions(+), 54 deletions(-) diff --git a/go.mod b/go.mod index 52368d007..466696b76 100644 --- a/go.mod +++ b/go.mod @@ -5,24 +5,24 @@ go 1.22 // pflag and tail are pinned to master. 12/31/2022 require ( - github.com/BurntSushi/toml v1.3.2 + github.com/BurntSushi/toml v1.4.0 github.com/akavel/rsrc v0.10.2 github.com/dsnet/compress v0.0.1 github.com/energye/systray v1.0.2 github.com/fsnotify/fsnotify v1.7.0 - github.com/gen2brain/beeep v0.0.0-20240112042604-c7bb2cd88fea + github.com/gen2brain/beeep v0.0.0-20240516210008-9c006672e7f4 github.com/gen2brain/dlgs v0.0.0-20220603100644-40c77870fa8d github.com/go-ping/ping v1.1.0 github.com/go-sql-driver/mysql v1.8.1 github.com/gonutz/w32/v2 v2.11.1 github.com/gorilla/mux v1.8.1 - github.com/gorilla/schema v1.2.1 + github.com/gorilla/schema v1.3.0 github.com/gorilla/securecookie v1.1.2 - github.com/gorilla/websocket v1.5.0 + github.com/gorilla/websocket v1.5.1 github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b github.com/hekmon/transmissionrpc/v3 v3.0.0 github.com/hugelgupf/go-shlex v0.0.0-20200702092117-c80c9d0918fa - github.com/jackpal/gateway v1.0.14 + github.com/jackpal/gateway v1.0.15 github.com/jaypipes/ghw v0.12.0 github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 github.com/kevinburke/go-bindata/v4 v4.0.2 @@ -30,14 +30,14 @@ require ( github.com/mitchellh/go-homedir v1.1.0 github.com/mrobinsn/go-rtorrent v1.8.0 github.com/nxadm/tail v1.4.11 - github.com/shirou/gopsutil/v3 v3.24.3 + github.com/shirou/gopsutil/v3 v3.24.4 github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace github.com/stretchr/testify v1.9.0 github.com/swaggo/swag v1.16.3 - golang.org/x/crypto v0.22.0 + golang.org/x/crypto v0.23.0 golang.org/x/mod v0.17.0 - golang.org/x/sys v0.19.0 - golang.org/x/text v0.14.0 + golang.org/x/sys v0.20.0 + golang.org/x/text v0.15.0 golang.org/x/time v0.5.0 golift.io/cache v0.0.2 golift.io/cnfg v0.2.3 @@ -51,7 +51,7 @@ require ( golift.io/starr v1.0.1-0.20240315164714-247399771c46 golift.io/version v0.0.2 golift.io/xtractr v0.2.2 - modernc.org/sqlite v1.29.7 + modernc.org/sqlite v1.29.10 ) require ( @@ -85,7 +85,7 @@ require ( github.com/kdomanski/iso9660 v0.4.0 // indirect github.com/klauspost/compress v1.17.8 // indirect github.com/lestrrat-go/strftime v1.0.6 // indirect - github.com/lufia/plan9stats v0.0.0-20240408141607-282e7b5d6b74 // indirect + github.com/lufia/plan9stats v0.0.0-20240513124658-fba389f38bae // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/ncruces/go-strftime v0.1.9 // indirect @@ -100,20 +100,20 @@ require ( github.com/stretchr/objx v0.5.2 // indirect github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect github.com/tevino/abool v1.2.0 // indirect - github.com/tklauser/go-sysconf v0.3.13 // indirect - github.com/tklauser/numcpus v0.7.0 // indirect + github.com/tklauser/go-sysconf v0.3.14 // indirect + github.com/tklauser/numcpus v0.8.0 // indirect github.com/ulikunitz/xz v0.5.12 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect go4.org v0.0.0-20230225012048-214862532bf5 // indirect - golang.org/x/net v0.24.0 // indirect + golang.org/x/net v0.25.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/tools v0.20.0 // indirect + golang.org/x/tools v0.21.0 // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect howett.net/plist v1.0.1 // indirect modernc.org/gc/v3 v3.0.0-20240304020402-f0dba7c97c2b // indirect - modernc.org/libc v1.49.3 // indirect + modernc.org/libc v1.50.9 // indirect modernc.org/mathutil v1.6.0 // indirect modernc.org/memory v1.8.0 // indirect modernc.org/strutil v1.2.0 // indirect diff --git a/go.sum b/go.sum index b26f7dd59..b4d694714 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7 filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= -github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= +github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= @@ -59,8 +59,8 @@ github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a/go.mod h1:7Ga40eg github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/gen2brain/beeep v0.0.0-20240112042604-c7bb2cd88fea h1:oWUHxzaBvwkRWiINbBOY39XIF+n9b4RJEPHdQ8waJUo= -github.com/gen2brain/beeep v0.0.0-20240112042604-c7bb2cd88fea/go.mod h1:0W7dI87PvXJ1Sjs0QPvWXKcQmNERY77e8l7GFhZB/s4= +github.com/gen2brain/beeep v0.0.0-20240516210008-9c006672e7f4 h1:ygs9POGDQpQGLJPlq4+0LBUmMBNox1N4JSpw+OETcvI= +github.com/gen2brain/beeep v0.0.0-20240516210008-9c006672e7f4/go.mod h1:0W7dI87PvXJ1Sjs0QPvWXKcQmNERY77e8l7GFhZB/s4= github.com/gen2brain/dlgs v0.0.0-20220603100644-40c77870fa8d h1:dHYKX8CBAs1zSGXm3q3M15CLAEwPEkwrK1ed8FCo+Xo= github.com/gen2brain/dlgs v0.0.0-20220603100644-40c77870fa8d/go.mod h1:/eFcjDXaU2THSOOqLxOPETIbHETnamk8FA/hMjhg/gU= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= @@ -134,12 +134,12 @@ github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/gorilla/rpc v1.2.1 h1:yC+LMV5esttgpVvNORL/xX4jvTTEUE30UZhZ5JF7K9k= github.com/gorilla/rpc v1.2.1/go.mod h1:uNpOihAlF5xRFLuTYhfR0yfCTm0WTQSQttkMSptRfGk= -github.com/gorilla/schema v1.2.1 h1:tjDxcmdb+siIqkTNoV+qRH2mjYdr2hHe5MKXbp61ziM= -github.com/gorilla/schema v1.2.1/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM= +github.com/gorilla/schema v1.3.0 h1:rbciOzXAx3IB8stEFnfTwO3sYa6EWlQk79XdyustPDA= +github.com/gorilla/schema v1.3.0/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM= github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA= github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo= -github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= -github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= +github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b h1:wDUNC2eKiL35DbLvsDhiblTUXHxcOPwQSCzi7xpQUN4= github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b/go.mod h1:VzxiSdG6j1pi7rwGm/xYI5RbtpBgM8sARDXlvEvxlu0= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -160,8 +160,8 @@ github.com/hekmon/transmissionrpc/v3 v3.0.0/go.mod h1:38SlNhFzinVUuY87wGj3acOmRx github.com/hugelgupf/go-shlex v0.0.0-20200702092117-c80c9d0918fa h1:s3KPo0nThtvjEamF/aElD4k5jSsBHew3/sgNTnth+2M= github.com/hugelgupf/go-shlex v0.0.0-20200702092117-c80c9d0918fa/go.mod h1:I1uW6ymzwsy5TlQgD1bFAghdMgBYqH1qtCeHoZgHMqs= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/jackpal/gateway v1.0.14 h1:6ZfIuFvnvWrS59hHbvZGR/R33ojV2LASBODomt7zlJU= -github.com/jackpal/gateway v1.0.14/go.mod h1:6c8LjW+FVESFmwxaXySkt7fU98Yv806ADS3OY6Cvh2U= +github.com/jackpal/gateway v1.0.15 h1:yb4Gltgr8ApHWWnSyybnDL1vURbqw7ooo7IIL5VZSeg= +github.com/jackpal/gateway v1.0.15/go.mod h1:dbyEDcDhHUh9EmjB9ung81elMUZfG0SoNc2TfTbcj4c= github.com/jaypipes/ghw v0.12.0 h1:xU2/MDJfWmBhJnujHY9qwXQLs3DBsf0/Xa9vECY0Tho= github.com/jaypipes/ghw v0.12.0/go.mod h1:jeJGbkRB2lL3/gxYzNYzEDETV1ZJ56OKr+CSeSEym+g= github.com/jaypipes/pcidb v1.0.0 h1:vtZIfkiCUE42oYbJS0TAq9XSfSmcsgo9IdxSm9qzYU8= @@ -197,14 +197,12 @@ github.com/lestrrat-go/strftime v1.0.4/go.mod h1:E1nN3pCbtMSu1yjSVeyuRFVm/U0xoR7 github.com/lestrrat-go/strftime v1.0.6 h1:CFGsDEt1pOpFNU+TJB0nhz9jl+K0hZSLE205AhTIGQQ= github.com/lestrrat-go/strftime v1.0.6/go.mod h1:f7jQKgV5nnJpYgdEasS+/y7EsTb8ykN2z68n3TtcTaw= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= -github.com/lufia/plan9stats v0.0.0-20240408141607-282e7b5d6b74 h1:1KuuSOy4ZNgW0KA2oYIngXVFhQcXxhLqCVK7cBcldkk= -github.com/lufia/plan9stats v0.0.0-20240408141607-282e7b5d6b74/go.mod h1:ilwx/Dta8jXAgpFYFvSWEMwxmbWXyiUHkd5FwyKhb5k= +github.com/lufia/plan9stats v0.0.0-20240513124658-fba389f38bae h1:dIZY4ULFcto4tAFlj1FYZl8ztUZ13bdq+PLY+NOfbyI= +github.com/lufia/plan9stats v0.0.0-20240513124658-fba389f38bae/go.mod h1:ilwx/Dta8jXAgpFYFvSWEMwxmbWXyiUHkd5FwyKhb5k= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= -github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mrobinsn/go-rtorrent v1.8.0 h1:+61aDIP0asy57lRD/uZtmxfE0/gjkHnt3uddOhMKUJ8= @@ -236,8 +234,8 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk= -github.com/shirou/gopsutil/v3 v3.24.3 h1:eoUGJSmdfLzJ3mxIhmOAhgKEKgQkeOwKpz1NbhVnuPE= -github.com/shirou/gopsutil/v3 v3.24.3/go.mod h1:JpND7O217xa72ewWz9zN2eIIkPWsDN/3pl0H8Qt0uwg= +github.com/shirou/gopsutil/v3 v3.24.4 h1:dEHgzZXt4LMNm+oYELpzl9YCqV65Yr/6SfrvgRBtXeU= +github.com/shirou/gopsutil/v3 v3.24.4/go.mod h1:lTd2mdiOspcqLgAnr9/nGi71NkeMpWKdmhuxm9GusH8= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= @@ -266,11 +264,11 @@ github.com/tevino/abool v0.0.0-20220530134649-2bfc934cb23c/go.mod h1:qc66Pna1RiI github.com/tevino/abool v1.2.0 h1:heAkClL8H6w+mK5md9dzsuohKeXHUpY7Vw0ZCKW+huA= github.com/tevino/abool v1.2.0/go.mod h1:qc66Pna1RiIsPa7O4Egxxs9OqkuxDX55zznh9K07Tzg= github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= -github.com/tklauser/go-sysconf v0.3.13 h1:GBUpcahXSpR2xN01jhkNAbTLRk2Yzgggk8IM08lq3r4= -github.com/tklauser/go-sysconf v0.3.13/go.mod h1:zwleP4Q4OehZHGn4CYZDipCgg9usW5IJePewFCGVEa0= +github.com/tklauser/go-sysconf v0.3.14 h1:g5vzr9iPFFz24v2KZXs/pvpvh8/V9Fw6vQK5ZZb78yU= +github.com/tklauser/go-sysconf v0.3.14/go.mod h1:1ym4lWMLUOhuBOPGtRcJm7tEGX4SCYNEEEtghGG/8uY= github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= -github.com/tklauser/numcpus v0.7.0 h1:yjuerZP127QG9m5Zh/mSO4wqurYil27tHrqwRoRjpr4= -github.com/tklauser/numcpus v0.7.0/go.mod h1:bb6dMVcj8A42tSE7i32fsIUCbQNllK5iDguyOZRUzAY= +github.com/tklauser/numcpus v0.8.0 h1:Mx4Wwe/FjZLeQsK/6kt2EOepwwSl7SmJrK5bV/dXYgY= +github.com/tklauser/numcpus v0.8.0/go.mod h1:ZJZlAY+dmR4eut8epnzf0u/VwodKmryxR8txiloSqBE= github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8= github.com/ulikunitz/xz v0.5.12 h1:37Nm15o69RwBkXM0J6A5OlE67RZTfzUxTj8fB3dfcsc= github.com/ulikunitz/xz v0.5.12/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= @@ -290,8 +288,8 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= -golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= +golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -339,8 +337,8 @@ golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLd golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= -golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -384,9 +382,9 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= +golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= @@ -397,8 +395,8 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= +golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= @@ -429,8 +427,8 @@ golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY= -golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg= +golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw= +golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -513,18 +511,18 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= howett.net/plist v1.0.1 h1:37GdZ8tP09Q35o9ych3ehygcsL+HqKSwzctveSlarvM= howett.net/plist v1.0.1/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g= -modernc.org/cc/v4 v4.20.0 h1:45Or8mQfbUqJOG9WaxvlFYOAQO0lQ5RvqBcFCXngjxk= -modernc.org/cc/v4 v4.20.0/go.mod h1:HM7VJTZbUCR3rV8EYBi9wxnJ0ZBRiGE5OeGXNA0IsLQ= -modernc.org/ccgo/v4 v4.16.0 h1:ofwORa6vx2FMm0916/CkZjpFPSR70VwTjUCe2Eg5BnA= -modernc.org/ccgo/v4 v4.16.0/go.mod h1:dkNyWIjFrVIZ68DTo36vHK+6/ShBn4ysU61So6PIqCI= +modernc.org/cc/v4 v4.21.2 h1:dycHFB/jDc3IyacKipCNSDrjIC0Lm1hyoWOZTRR20Lk= +modernc.org/cc/v4 v4.21.2/go.mod h1:HM7VJTZbUCR3rV8EYBi9wxnJ0ZBRiGE5OeGXNA0IsLQ= +modernc.org/ccgo/v4 v4.17.8 h1:yyWBf2ipA0Y9GGz/MmCmi3EFpKgeS7ICrAFes+suEbs= +modernc.org/ccgo/v4 v4.17.8/go.mod h1:buJnJ6Fn0tyAdP/dqePbrrvLyr6qslFfTbFrCuaYvtA= modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE= modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ= modernc.org/gc/v2 v2.4.1 h1:9cNzOqPyMJBvrUipmynX0ZohMhcxPtMccYgGOJdOiBw= modernc.org/gc/v2 v2.4.1/go.mod h1:wzN5dK1AzVGoH6XOzc3YZ+ey/jPgYHLuVckd62P0GYU= modernc.org/gc/v3 v3.0.0-20240304020402-f0dba7c97c2b h1:BnN1t+pb1cy61zbvSUV7SeI0PwosMhlAEi/vBY4qxp8= modernc.org/gc/v3 v3.0.0-20240304020402-f0dba7c97c2b/go.mod h1:Qz0X07sNOR1jWYCrJMEnbW/X55x206Q7Vt4mz6/wHp4= -modernc.org/libc v1.49.3 h1:j2MRCRdwJI2ls/sGbeSk0t2bypOG/uvPZUsGQFDulqg= -modernc.org/libc v1.49.3/go.mod h1:yMZuGkn7pXbKfoT/M35gFJOAEdSKdxL0q64sF7KqCDo= +modernc.org/libc v1.50.9 h1:hIWf1uz55lorXQhfoEoezdUHjxzuO6ceshET/yWjSjk= +modernc.org/libc v1.50.9/go.mod h1:15P6ublJ9FJR8YQCGy8DeQ2Uwur7iW9Hserr/T3OFZE= modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E= @@ -533,8 +531,8 @@ modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4= modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= modernc.org/sortutil v1.2.0 h1:jQiD3PfS2REGJNzNCMMaLSp/wdMNieTbKX920Cqdgqc= modernc.org/sortutil v1.2.0/go.mod h1:TKU2s7kJMf1AE84OoiGppNHJwvB753OYfNl2WRb++Ss= -modernc.org/sqlite v1.29.7 h1:Puwf5TIYuOipbcRnpFnLlGlR03DKenw8ggf3ijnuNQ0= -modernc.org/sqlite v1.29.7/go.mod h1:lQPm27iqa4UNZpmr4Aor0MH0HkCLbt1huYDfWylLZFk= +modernc.org/sqlite v1.29.10 h1:3u93dz83myFnMilBGCOLbr+HjklS6+5rJLx4q86RDAg= +modernc.org/sqlite v1.29.10/go.mod h1:ItX2a1OVGgNsFh6Dv60JQvGfJfTPHPVpV6DF59akYOA= modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA= modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0= modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= From 99f04dc813ed6e102220362862387a6ef31431db Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 26 May 2024 10:39:09 -0700 Subject: [PATCH 004/192] update linter --- .github/workflows/codetests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codetests.yml b/.github/workflows/codetests.yml index 4b4ca21d4..770c539af 100644 --- a/.github/workflows/codetests.yml +++ b/.github/workflows/codetests.yml @@ -48,9 +48,9 @@ jobs: - name: go-generate run: GOOS=darwin go generate ./... - name: golangci-lint - uses: golangci/golangci-lint-action@v4 + uses: golangci/golangci-lint-action@v5 with: - version: 'v1.56' + version: 'v1.57' golangci-linux: # description: "Runs golangci-lint on linux against linux and windows." @@ -69,9 +69,9 @@ jobs: - name: go-generate run: GOOS=linux go generate ./... - name: golangci-lint - uses: golangci/golangci-lint-action@v4 + uses: golangci/golangci-lint-action@v5 with: - version: 'v1.56' + version: 'v1.57' homebrew-test: # description: "Installs dependencies on macOS and runs `make install` to mimic a homebrew install." From 8da855e959e32196a1b174e92254986c169f3d91 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 26 May 2024 10:40:37 -0700 Subject: [PATCH 005/192] v6 --- .github/workflows/codetests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codetests.yml b/.github/workflows/codetests.yml index 770c539af..1554ec9c2 100644 --- a/.github/workflows/codetests.yml +++ b/.github/workflows/codetests.yml @@ -48,7 +48,7 @@ jobs: - name: go-generate run: GOOS=darwin go generate ./... - name: golangci-lint - uses: golangci/golangci-lint-action@v5 + uses: golangci/golangci-lint-action@v6 with: version: 'v1.57' @@ -69,7 +69,7 @@ jobs: - name: go-generate run: GOOS=linux go generate ./... - name: golangci-lint - uses: golangci/golangci-lint-action@v5 + uses: golangci/golangci-lint-action@v6 with: version: 'v1.57' From ad2ec3f1e3201222c4976a087ea712a7d2873e39 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 26 May 2024 10:51:39 -0700 Subject: [PATCH 006/192] websocket downgrade --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 466696b76..79f76cbbd 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/gorilla/mux v1.8.1 github.com/gorilla/schema v1.3.0 github.com/gorilla/securecookie v1.1.2 - github.com/gorilla/websocket v1.5.1 + github.com/gorilla/websocket v1.5.0 github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b github.com/hekmon/transmissionrpc/v3 v3.0.0 github.com/hugelgupf/go-shlex v0.0.0-20200702092117-c80c9d0918fa diff --git a/go.sum b/go.sum index b4d694714..c57db4415 100644 --- a/go.sum +++ b/go.sum @@ -138,8 +138,8 @@ github.com/gorilla/schema v1.3.0 h1:rbciOzXAx3IB8stEFnfTwO3sYa6EWlQk79XdyustPDA= github.com/gorilla/schema v1.3.0/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM= github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA= github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo= -github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= -github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= +github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b h1:wDUNC2eKiL35DbLvsDhiblTUXHxcOPwQSCzi7xpQUN4= github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b/go.mod h1:VzxiSdG6j1pi7rwGm/xYI5RbtpBgM8sARDXlvEvxlu0= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= From 40a23bc8b394d08e67006482280b36aa0389b422 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 26 May 2024 13:01:16 -0700 Subject: [PATCH 007/192] Add tunnel location and previous tunnel --- pkg/client/tunnel.go | 4 ++-- pkg/website/clientinfo/clientinfo.go | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/client/tunnel.go b/pkg/client/tunnel.go index 18cae399f..ab17f29aa 100644 --- a/pkg/client/tunnel.go +++ b/pkg/client/tunnel.go @@ -115,12 +115,12 @@ func (c *Client) roundRobinConfig(ci *clientinfo.ClientInfo) *mulery.RoundRobinC return &mulery.RoundRobinConfig{ RetryInterval: interval, Callback: func(_ context.Context, socket string) { - data.Save("activeTunnel", socket) + defer data.Save("activeTunnel", socket) // Tell the website we connected to a new tunnel, so it knows how to reach us. c.website.SendData(&website.Request{ Route: website.TunnelRoute, Event: website.EventSignal, - Payload: map[string]string{"socket": socket}, + Payload: map[string]interface{}{"socket": socket, "previous": data.Get("activeTunnel")}, LogMsg: fmt.Sprintf("Update Tunnel Target (%s)", socket), LogPayload: true, }) diff --git a/pkg/website/clientinfo/clientinfo.go b/pkg/website/clientinfo/clientinfo.go index 6caf3499a..616cb6d87 100644 --- a/pkg/website/clientinfo/clientinfo.go +++ b/pkg/website/clientinfo/clientinfo.go @@ -52,8 +52,9 @@ type ClientInfo struct { // MuleryServer is data from the website. It's a tunnel's https and wss urls. type MuleryServer struct { - Tunnel string `json:"tunnel"` // ex: "https://africa.notifiarr.com/" - Socket string `json:"socket"` // ex: "wss://africa.notifiarr.com/register" + Tunnel string `json:"tunnel"` // ex: "https://africa.notifiarr.com/" + Socket string `json:"socket"` // ex: "wss://africa.notifiarr.com/register" + Location string `json:"location"` // ex: "Nairobi, Kenya, Africa" } // CronConfig defines a custom GET timer from the website. From 8557aa8a98677044efb7ee83a22be15ca92292bb Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 26 May 2024 13:08:59 -0700 Subject: [PATCH 008/192] Remove windows console window --- Makefile | 2 ++ go.mod | 1 - go.sum | 2 -- main.go | 2 -- pkg/client/tray.go | 11 ----------- pkg/logs/logs.go | 2 -- pkg/ui/ui_darwin.go | 6 ------ pkg/ui/ui_other.go | 6 ------ pkg/ui/ui_windows.go | 21 --------------------- 9 files changed, 2 insertions(+), 51 deletions(-) diff --git a/Makefile b/Makefile index 8ffff27db..7936e267d 100644 --- a/Makefile +++ b/Makefile @@ -59,6 +59,8 @@ VERSION_LDFLAGS:= -X \"golift.io/version.Branch=$(BRANCH) ($(COMMIT))\" \ -X \"golift.io/version.Revision=$(ITERATION)\" \ -X \"golift.io/version.Version=$(VERSION)\" +WINDOWS_LDFLAGS:= -H=windowsgui + # Makefile targets follow. all: notifiarr diff --git a/go.mod b/go.mod index 79f76cbbd..ca4efdbd9 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,6 @@ require ( github.com/gen2brain/dlgs v0.0.0-20220603100644-40c77870fa8d github.com/go-ping/ping v1.1.0 github.com/go-sql-driver/mysql v1.8.1 - github.com/gonutz/w32/v2 v2.11.1 github.com/gorilla/mux v1.8.1 github.com/gorilla/schema v1.3.0 github.com/gorilla/securecookie v1.1.2 diff --git a/go.sum b/go.sum index c57db4415..191553980 100644 --- a/go.sum +++ b/go.sum @@ -102,8 +102,6 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/gonutz/w32/v2 v2.11.1 h1:plG738ZY7VIkPGf3adZ6lFeAf2evCKrULKyZT5GrPoc= -github.com/gonutz/w32/v2 v2.11.1/go.mod h1:MgtHx0AScDVNKyB+kjyPder4xIi3XAcHS6LDDU2DmdE= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= diff --git a/main.go b/main.go index 1b84f1046..da5c5db36 100644 --- a/main.go +++ b/main.go @@ -23,14 +23,12 @@ import ( // @in header // @name X-API-Key func main() { - ui.HideConsoleWindow() // setup log package in case we throw an error in main.go before logging is setup. log.SetFlags(log.LstdFlags) log.SetPrefix("[ERROR] ") defer func() { if r := recover(); r != nil { - ui.ShowConsoleWindow() log.Printf("Go Panic! %s\n%v\n%s", mnd.BugIssue, r, string(debug.Stack())) } }() diff --git a/pkg/client/tray.go b/pkg/client/tray.go index b8ec94c96..2a78b3002 100644 --- a/pkg/client/tray.go +++ b/pkg/client/tray.go @@ -327,17 +327,6 @@ func (c *Client) debugMenu() { c.Config.Services.RunChecks("log") }) - menu["console"] = debug.AddSubMenuItem("Console", "toggle the console window") - menu["console"].Click(func() { - if menu["console"].Checked() { - menu["console"].Uncheck() - ui.HideConsoleWindow() - } else { - menu["console"].Check() - ui.ShowConsoleWindow() - } - }) - if runtime.GOOS != mnd.Windows { menu["console"].Hide() } diff --git a/pkg/logs/logs.go b/pkg/logs/logs.go index 96c393b15..2aee0d47d 100644 --- a/pkg/logs/logs.go +++ b/pkg/logs/logs.go @@ -16,7 +16,6 @@ import ( "github.com/Notifiarr/notifiarr/pkg/logs/share" "github.com/Notifiarr/notifiarr/pkg/mnd" - "github.com/Notifiarr/notifiarr/pkg/ui" homedir "github.com/mitchellh/go-homedir" "golift.io/rotatorr" "golift.io/rotatorr/timerotator" @@ -168,7 +167,6 @@ func (l *Logger) Close() (errors []error) { // CapturePanic can be deferred in any go routine to log any panic that occurs. func (l *Logger) CapturePanic() { if r := recover(); r != nil { - ui.ShowConsoleWindow() l.ErrorLog.Output(callDepth, //nolint:errcheck fmt.Sprintf("Go Panic! %s\n%s-%s %s %v\n%s", mnd.BugIssue, version.Version, version.Revision, version.Branch, r, string(debug.Stack()))) diff --git a/pkg/ui/ui_darwin.go b/pkg/ui/ui_darwin.go index 63e104dc7..7720a63c3 100644 --- a/pkg/ui/ui_darwin.go +++ b/pkg/ui/ui_darwin.go @@ -22,12 +22,6 @@ func HasGUI() bool { return hasGUI } -// HideConsoleWindow doesn't work on maacOS. -func HideConsoleWindow() {} - -// ShowConsoleWindow does nothing on OSes besides Windows. -func ShowConsoleWindow() {} - func Notify(msg string, vars ...interface{}) error { if !hasGUI { return nil diff --git a/pkg/ui/ui_other.go b/pkg/ui/ui_other.go index c7f1f2378..8c980f4a2 100644 --- a/pkg/ui/ui_other.go +++ b/pkg/ui/ui_other.go @@ -25,12 +25,6 @@ func Notify(_ string, _ ...interface{}) error { return nil } -// HideConsoleWindow doesn't work on most OSes. -func HideConsoleWindow() {} - -// ShowConsoleWindow does nothing on OSes besides Windows. -func ShowConsoleWindow() {} - // StartCmd starts a command. func StartCmd(c string, v ...string) error { cmd := exec.Command(c, v...) diff --git a/pkg/ui/ui_windows.go b/pkg/ui/ui_windows.go index ecb0056b7..4da34afc0 100644 --- a/pkg/ui/ui_windows.go +++ b/pkg/ui/ui_windows.go @@ -12,7 +12,6 @@ import ( "github.com/Notifiarr/notifiarr/pkg/bindata" "github.com/Notifiarr/notifiarr/pkg/mnd" "github.com/gen2brain/beeep" - "github.com/gonutz/w32/v2" "github.com/kardianos/osext" ) @@ -68,26 +67,6 @@ func getPNG() string { return pngPath } -// HideConsoleWindow makes the console window vanish on startup. -func HideConsoleWindow() { - if console := w32.GetConsoleWindow(); console != 0 { - _, consoleProcID := w32.GetWindowThreadProcessId(console) - if w32.GetCurrentProcessId() == consoleProcID { - w32.ShowWindowAsync(console, w32.SW_HIDE) - } - } -} - -// ShowConsoleWindow does nothing on OSes besides Windows. -func ShowConsoleWindow() { - if console := w32.GetConsoleWindow(); console != 0 { - _, consoleProcID := w32.GetWindowThreadProcessId(console) - if w32.GetCurrentProcessId() == consoleProcID { - w32.ShowWindowAsync(console, w32.SW_SHOW) - } - } -} - // StartCmd starts a command. func StartCmd(c string, v ...string) error { cmd := exec.Command(c, v...) From 5dbad6c32b3af3604d800141da56bba23a6d44fd Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 26 May 2024 14:24:48 -0700 Subject: [PATCH 009/192] finish adding location to tunnel page --- pkg/bindata/templates/tunnel.html | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/bindata/templates/tunnel.html b/pkg/bindata/templates/tunnel.html index 517bbc393..3e401e5de 100644 --- a/pkg/bindata/templates/tunnel.html +++ b/pkg/bindata/templates/tunnel.html @@ -1,7 +1,7 @@

    Site Tunnel

    This client keeps a persistent websocket connection to a notifiarr.com - Mulery tunnel. + Mulery tunnel. This tunnel allows the website to make requests to your client without the need for opening a port, or having a static IP. This page allows you to select your primary tunnel and which tunnel you wish to use as backup in case the primary @@ -12,7 +12,7 @@

    Site Tunnel

    Select another fast tunnel as backup.

    {{$activeTunnel := (cache "activeTunnel")}} -

  • Active Tunnel: {{if $activeTunnel}}{{$activeTunnel.Data}}{{else}}unknown{{end}}
  • +
  • Active Tunnel: {{if $activeTunnel}}{{$activeTunnel.Data}}{{else}}unknown{{end}}
  • @@ -33,10 +33,11 @@

    Site Tunnel

    {{- range $idx, $mule := .ClientInfo.User.Mulery}} {{$primary := and (gt (len $.ClientInfo.User.Tunnels) 0) (eq (index $.ClientInfo.User.Tunnels 0) $mule.Socket)}} - - + + {{$mule.Location}} + {{$mule.Socket}} {{- end}} @@ -48,7 +49,7 @@

    Site Tunnel

    {{- range $mule := .ClientInfo.User.Mulery}} {{$backup := and (gt (len $.ClientInfo.User.Tunnels) 1) (eq (index $.ClientInfo.User.Tunnels 1) $mule.Socket)}} {{- end}} @@ -62,7 +63,7 @@

    Tunnel Stats

    {{- if .Tunnel }} {{- range $socket, $stats := .Tunnel.PoolStats }} - Socket URL ({{if $stats.Active}}active{{else}}inactive{{end}}) + Socket URL ({{if $stats.Active}}active{{else}}inactive{{end}}) {{$socket}} Disconnects{{$stats.Disconnects}} From 86368acfac802103c420c74591e5e063b6666d34 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Mon, 27 May 2024 08:48:49 -0700 Subject: [PATCH 010/192] fix two bugs --- go.mod | 2 +- go.sum | 4 ++-- pkg/logs/logs.go | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ca4efdbd9..a0e52e56f 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/go-ping/ping v1.1.0 github.com/go-sql-driver/mysql v1.8.1 github.com/gorilla/mux v1.8.1 - github.com/gorilla/schema v1.3.0 + github.com/gorilla/schema v1.2.1 github.com/gorilla/securecookie v1.1.2 github.com/gorilla/websocket v1.5.0 github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b diff --git a/go.sum b/go.sum index 191553980..5e2d69181 100644 --- a/go.sum +++ b/go.sum @@ -132,8 +132,8 @@ github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/gorilla/rpc v1.2.1 h1:yC+LMV5esttgpVvNORL/xX4jvTTEUE30UZhZ5JF7K9k= github.com/gorilla/rpc v1.2.1/go.mod h1:uNpOihAlF5xRFLuTYhfR0yfCTm0WTQSQttkMSptRfGk= -github.com/gorilla/schema v1.3.0 h1:rbciOzXAx3IB8stEFnfTwO3sYa6EWlQk79XdyustPDA= -github.com/gorilla/schema v1.3.0/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM= +github.com/gorilla/schema v1.2.1 h1:tjDxcmdb+siIqkTNoV+qRH2mjYdr2hHe5MKXbp61ziM= +github.com/gorilla/schema v1.2.1/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM= github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA= github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= diff --git a/pkg/logs/logs.go b/pkg/logs/logs.go index 2aee0d47d..8b756f03b 100644 --- a/pkg/logs/logs.go +++ b/pkg/logs/logs.go @@ -95,6 +95,11 @@ func (l *Logger) SetupLogging(config *LogConfig) { logFiles = config.LogFiles logFileMb = config.LogFileMb l.LogConfig = config + + if mnd.IsWindows { + config.Quiet = true + } + l.setDefaultLogPaths() l.setLogPaths() l.openLogFile() From 2a05ae4cbd47d3a7068492f60f94e928e9debb86 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Mon, 27 May 2024 09:24:14 -0700 Subject: [PATCH 011/192] fix docker build tags --- .github/workflows/ghcr.yml | 11 ++++++----- init/docker/{Dockerfile.scratch => Dockerfile.latest} | 0 init/docker/makedocker.sh | 2 +- settings.sh | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) rename init/docker/{Dockerfile.scratch => Dockerfile.latest} (100%) diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml index 49993d6cb..0a039a801 100644 --- a/.github/workflows/ghcr.yml +++ b/.github/workflows/ghcr.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - docker: [ {name: 'scratch', sfx: ''}, {name: 'cuda', sfx: '-cuda'}, {name: 'alpine', sfx: '-alpine'} ] + docker: [ {name: 'latest', sfx: ''}, {name: 'cuda', sfx: '-cuda'}, {name: 'alpine', sfx: '-alpine'} ] permissions: contents: read packages: write @@ -60,10 +60,11 @@ jobs: with: images: ghcr.io/${{ github.repository }} tags: | - type=semver,pattern=v{{version}}${{ matrix.docker.sfx }} - type=semver,pattern={{version}}${{ matrix.docker.sfx }} - type=semver,pattern={{major}}.{{minor}}${{ matrix.docker.sfx }} - type=semver,pattern={{major}}${{ matrix.docker.sfx }} + type=semver,priority=1010,pattern=${{ matrix.docker.name }} + type=semver,priority=1009,pattern={{major}}${{ matrix.docker.sfx }} + type=semver,priority=1008,pattern={{major}}.{{minor}}${{ matrix.docker.sfx }} + type=semver,priority=1007,pattern={{version}}${{ matrix.docker.sfx }} + type=semver,priority=1006,pattern=v{{version}}${{ matrix.docker.sfx }} type=ref,enable=true,event=branch,suffix=${{ matrix.docker.sfx }} # Build and push Docker image with Buildx diff --git a/init/docker/Dockerfile.scratch b/init/docker/Dockerfile.latest similarity index 100% rename from init/docker/Dockerfile.scratch rename to init/docker/Dockerfile.latest diff --git a/init/docker/makedocker.sh b/init/docker/makedocker.sh index 4a3f2938f..7c58ef1de 100755 --- a/init/docker/makedocker.sh +++ b/init/docker/makedocker.sh @@ -17,4 +17,4 @@ docker buildx build --load --pull --tag notifiarr \ --build-arg "VENDOR=${VENDOR}" \ --build-arg "AUTHOR=${MAINT}" \ --build-arg "SOURCE_URL=${SOURCE_URL}" \ - --file init/docker/Dockerfile.scratch . + --file init/docker/Dockerfile.latest . diff --git a/settings.sh b/settings.sh index a768e919b..6cece1c54 100644 --- a/settings.sh +++ b/settings.sh @@ -29,4 +29,4 @@ fi [ -n "$DOCKER_TAG" ] || export DOCKER_TAG=$(echo $SOURCE_BRANCH | sed 's/^v*\([0-9].*\)/\1/') [ -n "$DOCKER_REPO" ] || export DOCKER_REPO="golift/notifiarr" [ -n "$IMAGE_NAME" ] || export IMAGE_NAME="${DOCKER_REPO}:${DOCKER_TAG}" -[ -n "$DOCKERFILE_PATH" ] || export DOCKERFILE_PATH="init/docker/Dockerfile.scratch" +[ -n "$DOCKERFILE_PATH" ] || export DOCKERFILE_PATH="init/docker/Dockerfile.latest" From 3a1e77a78e152bedaf2a72caab38be9ea7b78ca6 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Mon, 27 May 2024 10:08:10 -0700 Subject: [PATCH 012/192] fix latest tag more --- .github/workflows/ghcr.yml | 6 ++++-- init/docker/{Dockerfile.latest => Dockerfile.scratch} | 0 init/docker/makedocker.sh | 2 +- settings.sh | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) rename init/docker/{Dockerfile.latest => Dockerfile.scratch} (100%) diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml index 0a039a801..f0e4f8a64 100644 --- a/.github/workflows/ghcr.yml +++ b/.github/workflows/ghcr.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - docker: [ {name: 'latest', sfx: ''}, {name: 'cuda', sfx: '-cuda'}, {name: 'alpine', sfx: '-alpine'} ] + docker: [ {name: 'scratch', sfx: ''}, {name: 'cuda', sfx: '-cuda'}, {name: 'alpine', sfx: '-alpine'} ] permissions: contents: read packages: write @@ -59,8 +59,10 @@ jobs: uses: docker/metadata-action@v5 with: images: ghcr.io/${{ github.repository }} + flavor: latest=false tags: | - type=semver,priority=1010,pattern=${{ matrix.docker.name }} + type=semver,priority=1010,value=latest,enable=${{ matrix.docker.sfx == '' }} + type=semver,priority=1010,value=${{ matrix.docker.name }},enable=${{ matrix.docker.sfx != '' }} type=semver,priority=1009,pattern={{major}}${{ matrix.docker.sfx }} type=semver,priority=1008,pattern={{major}}.{{minor}}${{ matrix.docker.sfx }} type=semver,priority=1007,pattern={{version}}${{ matrix.docker.sfx }} diff --git a/init/docker/Dockerfile.latest b/init/docker/Dockerfile.scratch similarity index 100% rename from init/docker/Dockerfile.latest rename to init/docker/Dockerfile.scratch diff --git a/init/docker/makedocker.sh b/init/docker/makedocker.sh index 7c58ef1de..4a3f2938f 100755 --- a/init/docker/makedocker.sh +++ b/init/docker/makedocker.sh @@ -17,4 +17,4 @@ docker buildx build --load --pull --tag notifiarr \ --build-arg "VENDOR=${VENDOR}" \ --build-arg "AUTHOR=${MAINT}" \ --build-arg "SOURCE_URL=${SOURCE_URL}" \ - --file init/docker/Dockerfile.latest . + --file init/docker/Dockerfile.scratch . diff --git a/settings.sh b/settings.sh index 6cece1c54..a768e919b 100644 --- a/settings.sh +++ b/settings.sh @@ -29,4 +29,4 @@ fi [ -n "$DOCKER_TAG" ] || export DOCKER_TAG=$(echo $SOURCE_BRANCH | sed 's/^v*\([0-9].*\)/\1/') [ -n "$DOCKER_REPO" ] || export DOCKER_REPO="golift/notifiarr" [ -n "$IMAGE_NAME" ] || export IMAGE_NAME="${DOCKER_REPO}:${DOCKER_TAG}" -[ -n "$DOCKERFILE_PATH" ] || export DOCKERFILE_PATH="init/docker/Dockerfile.latest" +[ -n "$DOCKERFILE_PATH" ] || export DOCKERFILE_PATH="init/docker/Dockerfile.scratch" From dae6656e096ca4c37067c34e012108c2ce10de68 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Mon, 27 May 2024 12:40:27 -0700 Subject: [PATCH 013/192] fix mac crash --- pkg/client/tray.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pkg/client/tray.go b/pkg/client/tray.go index 2a78b3002..586ca827e 100644 --- a/pkg/client/tray.go +++ b/pkg/client/tray.go @@ -7,7 +7,6 @@ import ( "context" "fmt" "os" - "runtime" "strings" "time" @@ -327,10 +326,6 @@ func (c *Client) debugMenu() { c.Config.Services.RunChecks("log") }) - if runtime.GOOS != mnd.Windows { - menu["console"].Hide() - } - debug.AddSubMenuItem("- Danger Zone -", "").Disable() menu["debug_panic"] = debug.AddSubMenuItem("Application Panic", "cause an application panic (crash)") menu["debug_panic"].Click(c.menuPanic) From 1a9f77a3a62da6b2d1702779f753d1485b4d6e9e Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Mon, 27 May 2024 13:01:09 -0700 Subject: [PATCH 014/192] fix check --- .github/workflows/ghcr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml index f0e4f8a64..5f814a142 100644 --- a/.github/workflows/ghcr.yml +++ b/.github/workflows/ghcr.yml @@ -61,8 +61,8 @@ jobs: images: ghcr.io/${{ github.repository }} flavor: latest=false tags: | - type=semver,priority=1010,value=latest,enable=${{ matrix.docker.sfx == '' }} - type=semver,priority=1010,value=${{ matrix.docker.name }},enable=${{ matrix.docker.sfx != '' }} + type=semver,priority=1010,pattern=latest,enable=${{ matrix.docker.sfx == '' }} + type=semver,priority=1010,pattern=${{ matrix.docker.name }},enable=${{ matrix.docker.sfx != '' }} type=semver,priority=1009,pattern={{major}}${{ matrix.docker.sfx }} type=semver,priority=1008,pattern={{major}}.{{minor}}${{ matrix.docker.sfx }} type=semver,priority=1007,pattern={{version}}${{ matrix.docker.sfx }} From deca1ca1eb633c896938c80c465e9afc502e06fc Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Mon, 27 May 2024 18:38:21 -0700 Subject: [PATCH 015/192] Set log files when folder provided --- pkg/logs/logfiles.go | 64 +++++++++++++++++++++++++++++--------------- pkg/logs/logs.go | 3 ++- 2 files changed, 45 insertions(+), 22 deletions(-) diff --git a/pkg/logs/logfiles.go b/pkg/logs/logfiles.go index b40eb56ca..df126f1d8 100644 --- a/pkg/logs/logfiles.go +++ b/pkg/logs/logfiles.go @@ -40,32 +40,48 @@ func (l *Logger) setDefaultLogPaths() { } } -// setLogPaths sets the log paths for app and http logs. -func (l *Logger) setLogPaths() { +// setAppLogPath sets the log path for app log. +func (l *Logger) setAppLogPath() { // Regular log file. - if l.LogConfig.LogFile != "" { - if f, err := homedir.Expand(l.LogConfig.LogFile); err == nil { - l.LogConfig.LogFile = f - } else if l.LogConfig.AppName != "" { - l.LogConfig.LogFile = l.LogConfig.AppName + defExt - } + if l.LogConfig.LogFile == "" { + return + } - if f, err := filepath.Abs(l.LogConfig.LogFile); err == nil { - l.LogConfig.LogFile = f - } + if f, err := homedir.Expand(l.LogConfig.LogFile); err == nil { + l.LogConfig.LogFile = f + } else if l.LogConfig.AppName != "" { + l.LogConfig.LogFile = l.LogConfig.AppName + defExt } - // HTTP log file. - if l.LogConfig.HTTPLog != "" { - if f, err := homedir.Expand(l.LogConfig.HTTPLog); err == nil { - l.LogConfig.HTTPLog = f - } else if l.LogConfig.AppName != "" { - l.LogConfig.HTTPLog = l.LogConfig.AppName + httpExt - } + if f, err := filepath.Abs(l.LogConfig.LogFile); err == nil { + l.LogConfig.LogFile = f + } - if f, err := filepath.Abs(l.LogConfig.HTTPLog); err == nil { - l.LogConfig.HTTPLog = f - } + // If a directory was provided, append a file name. + if stat, _ := os.Stat(l.LogConfig.LogFile); stat != nil && stat.IsDir() { + l.LogConfig.LogFile = filepath.Join(l.LogConfig.LogFile, mnd.Title+defExt) + } +} + +// setHTTPLogPath sets the log path for HTTP log. +func (l *Logger) setHTTPLogPath() { + if l.LogConfig.HTTPLog == "" { + return + } + + if f, err := homedir.Expand(l.LogConfig.HTTPLog); err == nil { + l.LogConfig.HTTPLog = f + } else if l.LogConfig.AppName != "" { + l.LogConfig.HTTPLog = l.LogConfig.AppName + httpExt + } + + if f, err := filepath.Abs(l.LogConfig.HTTPLog); err == nil { + l.LogConfig.HTTPLog = f + } + + // If a directory was provided, append a file name. + if stat, _ := os.Stat(l.LogConfig.HTTPLog); stat != nil && stat.IsDir() { + l.LogConfig.HTTPLog = filepath.Join(l.LogConfig.HTTPLog, mnd.Title+httpExt) } } @@ -130,6 +146,12 @@ func (l *Logger) openDebugLog() { l.LogConfig.DebugLog = f } + if stat, err := os.Stat(l.LogConfig.DebugLog); err == nil { + if stat.IsDir() { + l.LogConfig.DebugLog = filepath.Join(l.LogConfig.DebugLog, mnd.Title+".debug"+defExt) + } + } + rotateDebug := &rotatorr.Config{ Filepath: l.LogConfig.DebugLog, // log file name. FileSize: int64(l.LogConfig.LogFileMb) * mnd.Megabyte, // mnd.Megabytes diff --git a/pkg/logs/logs.go b/pkg/logs/logs.go index 8b756f03b..83caf294e 100644 --- a/pkg/logs/logs.go +++ b/pkg/logs/logs.go @@ -101,7 +101,8 @@ func (l *Logger) SetupLogging(config *LogConfig) { } l.setDefaultLogPaths() - l.setLogPaths() + l.setAppLogPath() + l.setHTTPLogPath() l.openLogFile() l.openHTTPLog() l.openDebugLog() From a4a6d16a7c328ca5863316e81c75ec49c0604577 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Mon, 27 May 2024 23:19:27 -0700 Subject: [PATCH 016/192] add unstable update tray command --- pkg/client/client_windows.go | 2 +- pkg/client/tray.go | 14 +++++-- pkg/client/tray_commands.go | 45 +++++++++++++++------ pkg/mnd/variables.go | 6 ++- pkg/update/check.go | 24 +++++------ pkg/update/unstable.go | 77 ++++++++++++++++++++++++++++++++++++ 6 files changed, 139 insertions(+), 29 deletions(-) create mode 100644 pkg/update/unstable.go diff --git a/pkg/client/client_windows.go b/pkg/client/client_windows.go index 4bf668c84..76e61f43a 100644 --- a/pkg/client/client_windows.go +++ b/pkg/client/client_windows.go @@ -89,7 +89,7 @@ func (c *Client) AutoWatchUpdate(ctx context.Context) { func (c *Client) checkAndUpdate(ctx context.Context, how string) error { c.Debugf("Checking GitHub for Update.") - u, err := update.Check(ctx, mnd.UserRepo, version.Version) + u, err := update.CheckGitHub(ctx, mnd.UserRepo, version.Version) if err != nil { return fmt.Errorf("checking GitHub for update: %w", err) } else if !u.Outdate { diff --git a/pkg/client/tray.go b/pkg/client/tray.go index 586ca827e..070296a1a 100644 --- a/pkg/client/tray.go +++ b/pkg/client/tray.go @@ -41,8 +41,8 @@ func (c *Client) startTray(ctx context.Context, cancel context.CancelFunc, clien // systray.SetOnClick(c.showMenu) // buggy systray.SetOnRClick(c.showMenu) systray.SetOnDClick(func(_ systray.IMenu) { c.openGUI() }) - c.makeMenus(ctx) // make the menu before starting the web server. - c.setupMenus(clientInfo) // code that runs on reload, too. + c.makeMenus(ctx, clientInfo) // make the menu before starting the web server. + c.setupMenus(clientInfo) // code that runs on reload, too. // This starts the web server, and waits for reload/exit signals. if err := c.Exit(ctx, cancel); err != nil { @@ -116,7 +116,7 @@ func (c *Client) setupMenus(clientInfo *clientinfo.ClientInfo) { } } -func (c *Client) makeMenus(ctx context.Context) { +func (c *Client) makeMenus(ctx context.Context, clientInfo *clientinfo.ClientInfo) { menu["stat"] = systray.AddMenuItem("Running", "web server state unknown") menu["stat"].Click(func() { c.toggleServer(ctx) }) @@ -127,7 +127,13 @@ func (c *Client) makeMenus(ctx context.Context) { c.debugMenu() menu["update"] = systray.AddMenuItem("Update", "check GitHub for updated version") - menu["update"].Click(func() { go c.checkForUpdate(ctx) }) + + if mnd.IsUnstable || (clientInfo != nil && clientInfo.User.DevAllowed) { + menu["unstable"] = systray.AddMenuItem("Unstable", "check Unstable website for updated version") + } + + menu["update"].Click(func() { go c.checkForUpdate(ctx, false) }) + menu["unstable"].Click(func() { go c.checkForUpdate(ctx, true) }) menu["gui"] = systray.AddMenuItem("Open WebUI", "open the web page for this Notifiarr client") menu["gui"].Click(c.openGUI) menu["sub"] = systray.AddMenuItem("Subscribe", "subscribe for premium features") diff --git a/pkg/client/tray_commands.go b/pkg/client/tray_commands.go index e29b75e11..a3ca61baf 100644 --- a/pkg/client/tray_commands.go +++ b/pkg/client/tray_commands.go @@ -49,25 +49,46 @@ func (c *Client) rotateLogs() { } } -func (c *Client) checkForUpdate(ctx context.Context) { - c.Print("[user requested] GitHub Update Check") +func (c *Client) checkForUpdate(ctx context.Context, unstable bool) { + var ( + data *update.Update + err error + where = "GitHub" + ) + + if unstable { + c.Print("[user requested] Unstable Update Check") + + data, err = update.CheckUnstable(ctx, mnd.Title, version.Version) + where = "Unstable website" + } else { + c.Print("[user requested] GitHub Update Check") + + data, err = update.CheckGitHub(ctx, mnd.UserRepo, version.Version) + } - switch update, err := update.Check(ctx, mnd.UserRepo, version.Version); { + switch { case err != nil: c.Errorf("Update Check: %v", err) - _, _ = ui.Error(TitleError, "Checking version on GitHub: "+err.Error()) - case update.Outdate && runtime.GOOS == mnd.Windows: - c.upgradeWindows(ctx, update) - case update.Outdate: - c.downloadOther(update) + _, _ = ui.Error(TitleError, "Checking version on "+where+": "+err.Error()) + case data.Outdate && runtime.GOOS == mnd.Windows: + c.upgradeWindows(ctx, data) + case data.Outdate: + c.downloadOther(data, unstable) default: - _, _ = ui.Info(mnd.Title, "You're up to date! Version: "+update.Version+"\n"+ - "Updated: "+update.RelDate.Format("Jan 2, 2006")+mnd.DurationAgo(update.RelDate)) + _, _ = ui.Info(mnd.Title, "You're up to date! Version: "+data.Version+"\n"+ + "Updated: "+data.RelDate.Format("Jan 2, 2006")+mnd.DurationAgo(data.RelDate)) } } -func (c *Client) downloadOther(update *update.Update) { - yes, _ := ui.Question(mnd.Title, "An Update is available! Download?\n\n"+ +func (c *Client) downloadOther(update *update.Update, unstable bool) { + msg := "An Update is available! Download?\n\n" + + if unstable { + msg = "An Unstable Update is available! Download?\n\n" + } + + yes, _ := ui.Question(mnd.Title, msg+ "Your Version: "+update.Version+"\n"+ "New Version: "+update.Current+"\n"+ "Date: "+update.RelDate.Format("Jan 2, 2006")+mnd.DurationAgo(update.RelDate), false) diff --git a/pkg/mnd/variables.go b/pkg/mnd/variables.go index 0faa4d5f2..7fc3f1a5c 100644 --- a/pkg/mnd/variables.go +++ b/pkg/mnd/variables.go @@ -3,6 +3,9 @@ package mnd import ( "fmt" "os" + "strings" + + "golift.io/version" ) //nolint:gochecknoglobals @@ -10,7 +13,8 @@ var ( // IsSynology tells us if this we're running on a Synology. IsSynology bool // IsDocker tells us if this is our Docker container. - IsDocker = os.Getpid() == 1 + IsDocker = os.Getpid() == 1 + IsUnstable = strings.HasPrefix(version.Branch, "unstable") ) // ErrDisabledInstance is returned when a request for a disabled instance is performed. diff --git a/pkg/update/check.go b/pkg/update/check.go index b83b9936a..963102d9c 100644 --- a/pkg/update/check.go +++ b/pkg/update/check.go @@ -27,8 +27,8 @@ var ( ErrNoFile = fmt.Errorf("no downloadable file found in release") ) -// Latest is where we find the latest release. -const Latest = "https://api.github.com/repos/%s/releases/latest" +// LatestGH is where we find the latest release. +const LatestGH = "https://api.github.com/repos/%s/releases/latest" // GitHub API and JSON unmarshal timeout. const timeout = 10 * time.Second @@ -36,16 +36,17 @@ const timeout = 10 * time.Second // Update contains running Version, Current version and Download URL for Current version. // Outdate is true if the running version is older than the current version. type Update struct { - Outdate bool - RelDate time.Time - Version string - Current string - CurrURL string + Outdate bool // True if we're outdated, update available. + Version string // Version passed in externally. + Current string // Current release available on GH or US. + CurrURL string // URL of current release on GH or US. + RelDate time.Time // Current version release date. + RelSize int64 // Current release file size. } -// Check checks if the app this library lives in has an updated version on GitHub. -func Check(ctx context.Context, userRepo string, version string) (*Update, error) { - release, err := GetRelease(ctx, fmt.Sprintf(Latest, userRepo)) +// CheckGitHub checks if the app this library lives in has an updated version on GitHub. +func CheckGitHub(ctx context.Context, userRepo string, version string) (*Update, error) { + release, err := GetRelease(ctx, fmt.Sprintf(LatestGH, userRepo)) if err != nil { return nil, err } @@ -104,6 +105,7 @@ func FillUpdate(release *GitHubReleasesLatest, version string) (*Update, error) if strings.HasSuffix(file.BrowserDownloadURL, suffix) { update.CurrURL = file.BrowserDownloadURL update.RelDate = file.UpdatedAt + update.RelSize = file.Size break } @@ -148,7 +150,7 @@ type GHasset struct { Uploader GHuser `json:"uploader"` ContentType string `json:"content_type"` State string `json:"state"` - Size int `json:"size"` + Size int64 `json:"size"` DownloadCount int `json:"download_count"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` diff --git a/pkg/update/unstable.go b/pkg/update/unstable.go new file mode 100644 index 000000000..7caa8ae52 --- /dev/null +++ b/pkg/update/unstable.go @@ -0,0 +1,77 @@ +package update + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + "runtime" + "strconv" + "strings" + "time" +) + +type UnstableFile struct { + Time time.Time `json:"time"` + File string `json:"file"` + Ver string `json:"version"` + Rev int `json:"revision"` + Size int64 `json:"size"` +} + +// LatestUS is where we find the latest unstable. +const unstableURL = "https://unstable.golift.io" + +// CheckUnstable checks if the provided app has an updated version on GitHub. +// Pass in revision only, no version. +func CheckUnstable(ctx context.Context, app string, revision string) (*Update, error) { + uri := fmt.Sprintf("%s/%s/%s.%s.installer.exe", unstableURL, strings.ToLower(app), app, runtime.GOARCH) + if runtime.GOOS == "linux" { + uri = fmt.Sprintf("%s/%s/%s.%s.gz", unstableURL, strings.ToLower(app), app, runtime.GOARCH) + } else if runtime.GOOS == "darwin" { + uri = fmt.Sprintf("%s/%s/%s.dmg", unstableURL, strings.ToLower(app), app) + } + + release, err := GetUnstable(ctx, uri) + if err != nil { + return nil, err + } + + oldRev, _ := strconv.Atoi(revision) + + return &Update{ + RelDate: release.Time, + CurrURL: release.File, + Current: fmt.Sprint(release.Ver, "-", release.Rev), + Version: revision, // on well. + RelSize: release.Size, + Outdate: release.Rev > oldRev, + }, nil +} + +// GetUnstable returns an unstable release. See CheckUnstable for an example on how to use it. +func GetUnstable(ctx context.Context, uri string) (*UnstableFile, error) { + ctx, cancel := context.WithTimeout(ctx, timeout) + defer cancel() + + req, err := http.NewRequestWithContext(ctx, http.MethodGet, uri+".txt", nil) + if err != nil { + return nil, fmt.Errorf("requesting unstable: %w", err) + } + + resp, err := (&http.Client{}).Do(req) + if err != nil { + return nil, fmt.Errorf("querying unstable: %w", err) + } + defer resp.Body.Close() + + var release UnstableFile + if err = json.NewDecoder(resp.Body).Decode(&release); err != nil { + return nil, fmt.Errorf("decoding unstable response: %w", err) + } + + release.Time, _ = time.Parse(time.RFC1123, resp.Header.Get("last-modified")) + release.File = uri + + return &release, nil +} From a2870fa12f1560d0b4fdf5641af9487687589969 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Mon, 27 May 2024 23:54:19 -0700 Subject: [PATCH 017/192] add auto update channel --- pkg/bindata/templates/config.html | 35 +++++++++++++++++++++++++++++++ pkg/client/client_windows.go | 31 +++++++++++++++++++++------ pkg/configfile/config.go | 1 + pkg/configfile/template.go | 17 +++++++++------ 4 files changed, 72 insertions(+), 12 deletions(-) diff --git a/pkg/bindata/templates/config.html b/pkg/bindata/templates/config.html index 5e6b7c25d..6580b466c 100644 --- a/pkg/bindata/templates/config.html +++ b/pkg/bindata/templates/config.html @@ -158,6 +158,41 @@

    General

    + {{- if .ClientInfo.User.DevAllowed }} + + + + + Unstable Channel + + + {{if .Config.UnstableCh}}Enabled{{else}}Disabled{{end}} + + +
    +
    + {{- if locked (printf "%s_UNSTABLE_CH" .Flags.EnvPrefix)}} +
    + + + +
    + {{- end}} + +
    +
    + + + {{- end }} {{- end }} diff --git a/pkg/client/client_windows.go b/pkg/client/client_windows.go index 76e61f43a..3b5bfa4e4 100644 --- a/pkg/client/client_windows.go +++ b/pkg/client/client_windows.go @@ -66,7 +66,12 @@ func (c *Client) AutoWatchUpdate(ctx context.Context) { } } - c.Print("Auto-updater enabled. Check interval:", durafmt.Parse(dur).String()) + pfx := "" + if c.Config.UnstableCh { + pfx = "Unstable Channel " + } + + c.Print(pfx+"Auto-updater enabled. Check interval:", durafmt.Parse(dur).String()) go func() { defer c.CapturePanic() @@ -87,14 +92,28 @@ func (c *Client) AutoWatchUpdate(ctx context.Context) { } func (c *Client) checkAndUpdate(ctx context.Context, how string) error { - c.Debugf("Checking GitHub for Update.") + var ( + data *update.Update + err error + where = "GitHub" + ) + + if c.Config.UnstableCh { + c.Debugf("[cron requested] Checking Unstable website for Update.") + + data, err = update.CheckUnstable(ctx, mnd.Title, version.Version) + where = "Unstable website" + } else { + c.Debugf("[cron requested] Checking GitHub for Update.") + + data, err = update.CheckGitHub(ctx, mnd.UserRepo, version.Version) + } - u, err := update.CheckGitHub(ctx, mnd.UserRepo, version.Version) if err != nil { - return fmt.Errorf("checking GitHub for update: %w", err) - } else if !u.Outdate { + return fmt.Errorf("checking %s for update: %w", where, err) + } else if !data.Outdate { return nil - } else if err = c.updateNow(ctx, u, how); err != nil { + } else if err = c.updateNow(ctx, data, how); err != nil { return err } diff --git a/pkg/configfile/config.go b/pkg/configfile/config.go index ba3309cbc..55d5cd567 100644 --- a/pkg/configfile/config.go +++ b/pkg/configfile/config.go @@ -56,6 +56,7 @@ type Config struct { SSLKeyFile string `json:"sslKeyFile" toml:"ssl_key_file" xml:"ssl_key_file" yaml:"sslKeyFile"` Upstreams []string `json:"upstreams" toml:"upstreams" xml:"upstreams" yaml:"upstreams"` AutoUpdate string `json:"autoUpdate" toml:"auto_update" xml:"auto_update" yaml:"autoUpdate"` + UnstableCh bool `json:"unstableCh" toml:"unstable_ch" xml:"unstable_ch" yaml:"unstableCh"` Timeout cnfg.Duration `json:"timeout" toml:"timeout" xml:"timeout" yaml:"timeout"` Retries int `json:"retries" toml:"retries" xml:"retries" yaml:"retries"` Snapshot *snapshot.Config `json:"snapshot" toml:"snapshot" xml:"snapshot" yaml:"snapshot"` diff --git a/pkg/configfile/template.go b/pkg/configfile/template.go index 030bf4283..668c65cd5 100644 --- a/pkg/configfile/template.go +++ b/pkg/configfile/template.go @@ -66,6 +66,11 @@ bind_addr = '''{{.BindAddr}}''' ## You may also set it to a Go duration like "12h" or "72h". ## THIS ONLY WORKS ON WINDOWS {{if .AutoUpdate}}auto_update = "{{.AutoUpdate}}"{{else}}auto_update = "off"{{end}} +{{- if .UnstableCh}} + +## Setting this to true uses the unstable website instead of GitHub for auto updates. +unstable_ch = true +{{- end}} {{- end}} ## Quiet makes the app not log anything to output. @@ -444,10 +449,10 @@ retries = {{.Retries}} [[snapshot.mysql]] name = "{{.Name}}" host = "{{.Host}}" - user = "{{.User}}" - pass = '''{{.Pass}}''' + user = "{{.User}}" + pass = '''{{.Pass}}''' interval = "{{.Interval}}" # Service check duration (if name is not empty). - timeout = "{{.Timeout}}" + timeout = "{{.Timeout}}" {{end}} {{else}} #[[snapshot.mysql]] @@ -466,9 +471,9 @@ retries = {{.Retries}} # SMI Path is found automatically if left blank. Set it to path to nvidia-smi (nvidia-smi.exe on Windows). [snapshot.nvidia] -disabled = {{.Snapshot.Nvidia.Disabled}} -smi_path = '''{{.Snapshot.Nvidia.SMIPath}}''' -bus_ids = [{{range $s := .Snapshot.Nvidia.BusIDs}}"{{$s}}",{{end}}] + disabled = {{.Snapshot.Nvidia.Disabled}} + smi_path = '''{{.Snapshot.Nvidia.SMIPath}}''' + bus_ids = [{{range $s := .Snapshot.Nvidia.BusIDs}}"{{$s}}",{{end}}] ################## # Service Checks # From 01159916a7945d627c37d2efb50ed84b2fb1bcfc Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Tue, 28 May 2024 00:14:11 -0700 Subject: [PATCH 018/192] lint it up --- pkg/bindata/templates/config.html | 3 +-- pkg/client/client_windows.go | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/pkg/bindata/templates/config.html b/pkg/bindata/templates/config.html index 6580b466c..2edec8294 100644 --- a/pkg/bindata/templates/config.html +++ b/pkg/bindata/templates/config.html @@ -162,8 +162,7 @@

    General

    diff --git a/pkg/client/client_windows.go b/pkg/client/client_windows.go index 3b5bfa4e4..6f0074eea 100644 --- a/pkg/client/client_windows.go +++ b/pkg/client/client_windows.go @@ -66,25 +66,25 @@ func (c *Client) AutoWatchUpdate(ctx context.Context) { } } + c.startAutoUpdater(ctx, dur) +} + +func (c *Client) startAutoUpdater(ctx context.Context, dur time.Duration) { pfx := "" if c.Config.UnstableCh { pfx = "Unstable Channel " } - c.Print(pfx+"Auto-updater enabled. Check interval:", durafmt.Parse(dur).String()) - - go func() { - defer c.CapturePanic() + c.Print(pfx+"Auto-updater started. Check interval:", durafmt.Parse(dur).String()) - time.Sleep(update.SleepTime) - // Check for update on startup. - if err := c.checkAndUpdate(ctx, "startup check"); err != nil { - c.Errorf("Startup-Update Failed: %v", err) - } - }() + time.Sleep(update.SleepTime) + // Check for update on startup. + if err := c.checkAndUpdate(ctx, "startup check"); err != nil { + c.Errorf("Startup-Update Failed: %v", err) + } ticker := time.NewTicker(dur) - for range ticker.C { + for range ticker.C { // the ticker never exits. if err := c.checkAndUpdate(ctx, "automatic"); err != nil { c.Errorf("Auto-Update Failed: %v", err) } From 0843234d17a2f7b751c27837273c4bc296f3fbc9 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Tue, 28 May 2024 19:38:43 -0700 Subject: [PATCH 019/192] jsonify txt file --- .github/workflows/release.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index acaadcc9a..11f7c569c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -69,7 +69,9 @@ jobs: sudo gem install --no-document fpm echo "${GPG_SIGNING_KEY}" | gpg --import - make release - source settings.sh ; echo "version=${VERSION}-${ITERATION}" >> $GITHUB_OUTPUT + source settings.sh + echo "version=${VERSION}" >> $GITHUB_OUTPUT + echo "revision=${ITERATION}" >> $GITHUB_OUTPUT - name: upload artifacts uses: actions/upload-artifact@v4 with: @@ -98,8 +100,8 @@ jobs: [ -f "$file" ] || continue; echo "Uploading: ${file}"; curl -sSH "X-API-KEY: ${{ secrets.UNSTABLE_UPLOAD_KEY }}" "https://unstable.golift.io/upload.php?folder=notifiarr" -F "file=@${file}"; - versionfile="${{needs.release-test.outputs.version}};filename=${file}.txt;type=text/plain"; - curl -sSH "X-API-KEY: ${{ secrets.UNSTABLE_UPLOAD_KEY }}" "https://unstable.golift.io/upload.php?folder=notifiarr" -F "file=${versionfile}"; + echo '{"version":"${{needs.release-test.outputs.version}}","revision":${{needs.release-test.outputs.revision}},"size":'$(stat --printf="%s" ${file})'}' >> ${file}.txt + curl -sSH "X-API-KEY: ${{ secrets.UNSTABLE_UPLOAD_KEY }}" "https://unstable.golift.io/upload.php?folder=notifiarr" -F "file=@${file}.txt"; done deploy-unstable-packagecloud: From 5d014350223523c57f08f8fca72b9dcdc57405c3 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Tue, 28 May 2024 20:16:23 -0700 Subject: [PATCH 020/192] gh actions is just screwing with me now --- .github/workflows/release.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 11f7c569c..d17f6bb15 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -69,9 +69,8 @@ jobs: sudo gem install --no-document fpm echo "${GPG_SIGNING_KEY}" | gpg --import - make release - source settings.sh - echo "version=${VERSION}" >> $GITHUB_OUTPUT - echo "revision=${ITERATION}" >> $GITHUB_OUTPUT + source settings.sh ; echo "version=${VERSION}" >> $GITHUB_OUTPUT + source settings.sh ; echo "revision=${ITERATION}" >> $GITHUB_OUTPUT - name: upload artifacts uses: actions/upload-artifact@v4 with: From a6f686aa763adb30d8d08b61f8e7fa1e5e61070f Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Tue, 28 May 2024 20:58:17 -0700 Subject: [PATCH 021/192] i dunno --- .github/workflows/release.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d17f6bb15..9a8e15fd7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -70,7 +70,8 @@ jobs: echo "${GPG_SIGNING_KEY}" | gpg --import - make release source settings.sh ; echo "version=${VERSION}" >> $GITHUB_OUTPUT - source settings.sh ; echo "revision=${ITERATION}" >> $GITHUB_OUTPUT + source settings.sh ; echo "iteration=${ITERATION}" >> $GITHUB_OUTPUT + echo "v/i ${VERSION}-${ITERATION}" - name: upload artifacts uses: actions/upload-artifact@v4 with: @@ -99,7 +100,7 @@ jobs: [ -f "$file" ] || continue; echo "Uploading: ${file}"; curl -sSH "X-API-KEY: ${{ secrets.UNSTABLE_UPLOAD_KEY }}" "https://unstable.golift.io/upload.php?folder=notifiarr" -F "file=@${file}"; - echo '{"version":"${{needs.release-test.outputs.version}}","revision":${{needs.release-test.outputs.revision}},"size":'$(stat --printf="%s" ${file})'}' >> ${file}.txt + echo '{"version":"${{needs.release-test.outputs.version}}","revision":${{needs.release-test.outputs.iteration}},"size":'$(stat --printf="%s" ${file})'}' >> ${file}.txt curl -sSH "X-API-KEY: ${{ secrets.UNSTABLE_UPLOAD_KEY }}" "https://unstable.golift.io/upload.php?folder=notifiarr" -F "file=@${file}.txt"; done From f005328793768c83dddc3dd4f0cb58e588fc6601 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Tue, 28 May 2024 21:09:50 -0700 Subject: [PATCH 022/192] found it --- .github/workflows/release.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9a8e15fd7..e33ca8137 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -50,6 +50,7 @@ jobs: if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/unstable' || github.ref == 'refs/heads/main' outputs: version: ${{ steps.release.outputs.version }} + revision: ${{ steps.release.outputs.version }} name: Make Release Assets runs-on: ubuntu-latest env: @@ -69,9 +70,9 @@ jobs: sudo gem install --no-document fpm echo "${GPG_SIGNING_KEY}" | gpg --import - make release - source settings.sh ; echo "version=${VERSION}" >> $GITHUB_OUTPUT - source settings.sh ; echo "iteration=${ITERATION}" >> $GITHUB_OUTPUT - echo "v/i ${VERSION}-${ITERATION}" + source settings.sh + echo "version=${VERSION}" >> $GITHUB_OUTPUT + echo "revision=${ITERATION}" >> $GITHUB_OUTPUT - name: upload artifacts uses: actions/upload-artifact@v4 with: @@ -100,7 +101,7 @@ jobs: [ -f "$file" ] || continue; echo "Uploading: ${file}"; curl -sSH "X-API-KEY: ${{ secrets.UNSTABLE_UPLOAD_KEY }}" "https://unstable.golift.io/upload.php?folder=notifiarr" -F "file=@${file}"; - echo '{"version":"${{needs.release-test.outputs.version}}","revision":${{needs.release-test.outputs.iteration}},"size":'$(stat --printf="%s" ${file})'}' >> ${file}.txt + echo '{"version":"${{needs.release-test.outputs.version}}","revision":${{needs.release-test.outputs.revision}},"size":'$(stat --printf="%s" ${file})'}' >> ${file}.txt curl -sSH "X-API-KEY: ${{ secrets.UNSTABLE_UPLOAD_KEY }}" "https://unstable.golift.io/upload.php?folder=notifiarr" -F "file=@${file}.txt"; done From 570a58bc7ad6c1056de252fa5271f42cfedee9a7 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Tue, 28 May 2024 21:16:51 -0700 Subject: [PATCH 023/192] typo slap --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e33ca8137..eda4449e1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -50,7 +50,7 @@ jobs: if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/unstable' || github.ref == 'refs/heads/main' outputs: version: ${{ steps.release.outputs.version }} - revision: ${{ steps.release.outputs.version }} + revision: ${{ steps.release.outputs.revision }} name: Make Release Assets runs-on: ubuntu-latest env: From 64418aa8a480c0aed27d8c8585ed25e0f79530ff Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Tue, 28 May 2024 21:35:13 -0700 Subject: [PATCH 024/192] fix revision --- pkg/client/tray.go | 4 ++-- pkg/client/tray_commands.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/client/tray.go b/pkg/client/tray.go index 070296a1a..a9ed5d28a 100644 --- a/pkg/client/tray.go +++ b/pkg/client/tray.go @@ -127,13 +127,13 @@ func (c *Client) makeMenus(ctx context.Context, clientInfo *clientinfo.ClientInf c.debugMenu() menu["update"] = systray.AddMenuItem("Update", "check GitHub for updated version") + menu["update"].Click(func() { go c.checkForUpdate(ctx, false) }) if mnd.IsUnstable || (clientInfo != nil && clientInfo.User.DevAllowed) { menu["unstable"] = systray.AddMenuItem("Unstable", "check Unstable website for updated version") + menu["unstable"].Click(func() { go c.checkForUpdate(ctx, true) }) } - menu["update"].Click(func() { go c.checkForUpdate(ctx, false) }) - menu["unstable"].Click(func() { go c.checkForUpdate(ctx, true) }) menu["gui"] = systray.AddMenuItem("Open WebUI", "open the web page for this Notifiarr client") menu["gui"].Click(c.openGUI) menu["sub"] = systray.AddMenuItem("Subscribe", "subscribe for premium features") diff --git a/pkg/client/tray_commands.go b/pkg/client/tray_commands.go index a3ca61baf..456c376f3 100644 --- a/pkg/client/tray_commands.go +++ b/pkg/client/tray_commands.go @@ -59,7 +59,7 @@ func (c *Client) checkForUpdate(ctx context.Context, unstable bool) { if unstable { c.Print("[user requested] Unstable Update Check") - data, err = update.CheckUnstable(ctx, mnd.Title, version.Version) + data, err = update.CheckUnstable(ctx, mnd.Title, version.Revision) where = "Unstable website" } else { c.Print("[user requested] GitHub Update Check") From 8d3dbc0a3a974f9b1e01110efaa0787a79327719 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Tue, 28 May 2024 21:55:38 -0700 Subject: [PATCH 025/192] show rev too --- pkg/client/tray_commands.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/client/tray_commands.go b/pkg/client/tray_commands.go index 456c376f3..4cbd2ae61 100644 --- a/pkg/client/tray_commands.go +++ b/pkg/client/tray_commands.go @@ -89,7 +89,7 @@ func (c *Client) downloadOther(update *update.Update, unstable bool) { } yes, _ := ui.Question(mnd.Title, msg+ - "Your Version: "+update.Version+"\n"+ + "Your Version: "+version.Version+"-"+version.Revision+"\n"+ "New Version: "+update.Current+"\n"+ "Date: "+update.RelDate.Format("Jan 2, 2006")+mnd.DurationAgo(update.RelDate), false) if yes { From 3b4da3658c0a10c8b0c9f7223171875971b8238f Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Tue, 28 May 2024 22:18:07 -0700 Subject: [PATCH 026/192] print full version --- pkg/client/tray_commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/client/tray_commands.go b/pkg/client/tray_commands.go index 4cbd2ae61..933b22203 100644 --- a/pkg/client/tray_commands.go +++ b/pkg/client/tray_commands.go @@ -43,7 +43,7 @@ func (c *Client) rotateLogs() { for _, err := range c.Logger.Rotate() { if err != nil { - ui.Notify("Error rotateing log files: %v", err) //nolint:errcheck + ui.Notify("Error rotating log files: %v", err) //nolint:errcheck c.Errorf("Rotating Log Files: %v", err) } } @@ -76,7 +76,7 @@ func (c *Client) checkForUpdate(ctx context.Context, unstable bool) { case data.Outdate: c.downloadOther(data, unstable) default: - _, _ = ui.Info(mnd.Title, "You're up to date! Version: "+data.Version+"\n"+ + _, _ = ui.Info(mnd.Title, "You're up to date! Version: "+data.Current+"\n"+ "Updated: "+data.RelDate.Format("Jan 2, 2006")+mnd.DurationAgo(data.RelDate)) } } From b48a33b835c0d826ce925cbb1e13ca0c32cbad04 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Wed, 29 May 2024 12:35:37 -0700 Subject: [PATCH 027/192] fix windows uri --- pkg/client/client_windows.go | 2 +- pkg/update/unstable.go | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pkg/client/client_windows.go b/pkg/client/client_windows.go index 6f0074eea..5ff007342 100644 --- a/pkg/client/client_windows.go +++ b/pkg/client/client_windows.go @@ -20,7 +20,7 @@ import ( // This is the pop-up a user sees when they click update in the menu. func (c *Client) upgradeWindows(ctx context.Context, update *update.Update) { yes, _ := ui.Question(mnd.Title, "An Update is available! Upgrade Now?\n\n"+ - "Your Version: "+update.Version+"\n"+ + "Your Version: "+version.Version+"-"+version.Revision+"\n"+ "New Version: "+update.Current+"\n"+ "Date: "+update.RelDate.Format("Jan 2, 2006")+mnd.DurationAgo(update.RelDate), false) if yes { diff --git a/pkg/update/unstable.go b/pkg/update/unstable.go index 7caa8ae52..839b2c344 100644 --- a/pkg/update/unstable.go +++ b/pkg/update/unstable.go @@ -25,7 +25,7 @@ const unstableURL = "https://unstable.golift.io" // CheckUnstable checks if the provided app has an updated version on GitHub. // Pass in revision only, no version. func CheckUnstable(ctx context.Context, app string, revision string) (*Update, error) { - uri := fmt.Sprintf("%s/%s/%s.%s.installer.exe", unstableURL, strings.ToLower(app), app, runtime.GOARCH) + uri := fmt.Sprintf("%s/%s/%s.%s.exe.zip", unstableURL, strings.ToLower(app), app, runtime.GOARCH) if runtime.GOOS == "linux" { uri = fmt.Sprintf("%s/%s/%s.%s.gz", unstableURL, strings.ToLower(app), app, runtime.GOARCH) } else if runtime.GOOS == "darwin" { @@ -54,24 +54,25 @@ func GetUnstable(ctx context.Context, uri string) (*UnstableFile, error) { ctx, cancel := context.WithTimeout(ctx, timeout) defer cancel() - req, err := http.NewRequestWithContext(ctx, http.MethodGet, uri+".txt", nil) + release := UnstableFile{File: uri} + uri = uri + ".txt" + + req, err := http.NewRequestWithContext(ctx, http.MethodGet, uri, nil) if err != nil { - return nil, fmt.Errorf("requesting unstable: %w", err) + return nil, fmt.Errorf("requesting %s: %w", uri, err) } resp, err := (&http.Client{}).Do(req) if err != nil { - return nil, fmt.Errorf("querying unstable: %w", err) + return nil, fmt.Errorf("querying %s: %w", uri, err) } defer resp.Body.Close() - var release UnstableFile if err = json.NewDecoder(resp.Body).Decode(&release); err != nil { - return nil, fmt.Errorf("decoding unstable response: %w", err) + return nil, fmt.Errorf("decoding %s response: %w", uri, err) } release.Time, _ = time.Parse(time.RFC1123, resp.Header.Get("last-modified")) - release.File = uri return &release, nil } From f84094aaa74c0e8371195c6522c3c962bc5ef1c9 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Wed, 29 May 2024 12:52:00 -0700 Subject: [PATCH 028/192] fix url for windows and linux --- pkg/update/unstable.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/update/unstable.go b/pkg/update/unstable.go index 839b2c344..595381d40 100644 --- a/pkg/update/unstable.go +++ b/pkg/update/unstable.go @@ -25,11 +25,13 @@ const unstableURL = "https://unstable.golift.io" // CheckUnstable checks if the provided app has an updated version on GitHub. // Pass in revision only, no version. func CheckUnstable(ctx context.Context, app string, revision string) (*Update, error) { - uri := fmt.Sprintf("%s/%s/%s.%s.exe.zip", unstableURL, strings.ToLower(app), app, runtime.GOARCH) - if runtime.GOOS == "linux" { - uri = fmt.Sprintf("%s/%s/%s.%s.gz", unstableURL, strings.ToLower(app), app, runtime.GOARCH) - } else if runtime.GOOS == "darwin" { - uri = fmt.Sprintf("%s/%s/%s.dmg", unstableURL, strings.ToLower(app), app) + app = strings.ToLower(app) + uri := fmt.Sprintf("%s/%s/%s.%s.exe.zip", unstableURL, app, app, runtime.GOARCH) + + if runtime.GOOS == "darwin" { + uri = fmt.Sprintf("%s/%s/%s.dmg", unstableURL, app, app) + } else if runtime.GOOS != "windows" { + uri = fmt.Sprintf("%s/%s/%s.%s.%s.gz", unstableURL, app, app, runtime.GOARCH, runtime.GOOS) } release, err := GetUnstable(ctx, uri) From 47509ea57e874c336f76943255d97aae82b5a077 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Wed, 29 May 2024 14:52:40 -0700 Subject: [PATCH 029/192] trigger new unstable --- pkg/update/unstable.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/update/unstable.go b/pkg/update/unstable.go index 595381d40..00736af67 100644 --- a/pkg/update/unstable.go +++ b/pkg/update/unstable.go @@ -9,6 +9,8 @@ import ( "strconv" "strings" "time" + + "github.com/Notifiarr/notifiarr/pkg/mnd" ) type UnstableFile struct { @@ -30,7 +32,7 @@ func CheckUnstable(ctx context.Context, app string, revision string) (*Update, e if runtime.GOOS == "darwin" { uri = fmt.Sprintf("%s/%s/%s.dmg", unstableURL, app, app) - } else if runtime.GOOS != "windows" { + } else if !mnd.IsWindows { uri = fmt.Sprintf("%s/%s/%s.%s.%s.gz", unstableURL, app, app, runtime.GOARCH, runtime.GOOS) } From 454470578904c52bbb793d5df82fd1c821b4b125 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Wed, 29 May 2024 16:50:06 -0700 Subject: [PATCH 030/192] gocritic --- pkg/update/unstable.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/update/unstable.go b/pkg/update/unstable.go index 00736af67..a10bb78a6 100644 --- a/pkg/update/unstable.go +++ b/pkg/update/unstable.go @@ -59,7 +59,7 @@ func GetUnstable(ctx context.Context, uri string) (*UnstableFile, error) { defer cancel() release := UnstableFile{File: uri} - uri = uri + ".txt" + uri += ".txt" req, err := http.NewRequestWithContext(ctx, http.MethodGet, uri, nil) if err != nil { From 0234d13fe3385385924732099b7e228dd26a38c6 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 17:19:55 +0000 Subject: [PATCH 031/192] Update nvidia/cuda Docker tag to v12.5.0 --- init/docker/Dockerfile.cuda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init/docker/Dockerfile.cuda b/init/docker/Dockerfile.cuda index 2904ae260..e5c93f3a6 100644 --- a/init/docker/Dockerfile.cuda +++ b/init/docker/Dockerfile.cuda @@ -41,7 +41,7 @@ RUN GOFLAGS="-trimpath -mod=readonly -modcacherw" \ -X \"golift.io/version.Revision=${ITERATION}\" \ -X \"golift.io/version.Version=${VERSION}\"" -FROM nvidia/cuda:12.4.1-base-ubuntu22.04 +FROM nvidia/cuda:12.5.0-base-ubuntu22.04 COPY --from=builder /tmp/notifiarr / # Other tools. From e3f518bd7ec52731f280962ce7e9b06a31d4b188 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sat, 22 Jun 2024 15:20:50 -0700 Subject: [PATCH 032/192] add fstype and opts to disk snapshots --- pkg/snapshot/diskusage.go | 19 ++++++++++++++----- pkg/snapshot/snapshot.go | 11 +++++++---- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/pkg/snapshot/diskusage.go b/pkg/snapshot/diskusage.go index 811013f32..e6c460e06 100644 --- a/pkg/snapshot/diskusage.go +++ b/pkg/snapshot/diskusage.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "runtime" + "slices" "strconv" "strings" @@ -46,10 +47,13 @@ func (s *Snapshot) getDisksUsage(ctx context.Context, run bool, allDrives bool) } s.DiskUsage[partitions[idx].Device] = &Partition{ - Device: partitions[idx].Mountpoint, - Total: usage.Total, - Free: usage.Free, - Used: usage.Used, + Device: partitions[idx].Mountpoint, + Total: usage.Total, + Free: usage.Free, + Used: usage.Used, + FSType: usage.Fstype, + ReadOnly: slices.Contains(partitions[idx].Opts, "ro"), + Opts: partitions[idx].Opts, } } @@ -119,6 +123,11 @@ func (s *Snapshot) getZFSPoolData(ctx context.Context, pools []string) error { return nil } + // # zpool list -pH + // NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT + // data 3985729650688 2223640698880 1762088951808 - - 10 55 1.00 ONLINE - + // data2 996432412672 98463039488 897969373184 - - 8 9 1.00 ONLINE - + // data3 996432412672 44307656704 952124755968 - - 4 4 1.00 ONLINE - cmd, stdout, waitg, err := readyCommand(ctx, false, "zpool", "list", "-pH") if err != nil { return err @@ -132,7 +141,7 @@ func (s *Snapshot) getZFSPoolData(ctx context.Context, pools []string) error { for _, pool := range pools { if len(fields) > 3 && strings.EqualFold(fields[0], pool) { - s.ZFSPool[pool] = &Partition{Device: fields[4]} + s.ZFSPool[pool] = &Partition{Device: fields[4], FSType: "zfs", Opts: []string{fields[9]}} s.ZFSPool[pool].Total, _ = strconv.ParseUint(fields[1], mnd.Base10, mnd.Bits64) s.ZFSPool[pool].Free, _ = strconv.ParseUint(fields[3], mnd.Base10, mnd.Bits64) } diff --git a/pkg/snapshot/snapshot.go b/pkg/snapshot/snapshot.go index be72e0b19..5b082e162 100644 --- a/pkg/snapshot/snapshot.go +++ b/pkg/snapshot/snapshot.go @@ -108,10 +108,13 @@ type RaidData struct { // Partition is used for ZFS pools as well as normal Disk arrays. type Partition struct { - Device string `json:"name"` - Total uint64 `json:"total"` - Free uint64 `json:"free"` - Used uint64 `json:"used"` + Device string `json:"name"` + Total uint64 `json:"total"` + Free uint64 `json:"free"` + Used uint64 `json:"used"` + FSType string `json:"fsType,omitempty"` + ReadOnly bool `json:"readOnly,omitempty"` + Opts []string `json:"opts,omitempty"` } // Validate makes sure the snapshot configuration is valid. From c8a010685d118faa502102b89bb65035546bb89e Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sat, 22 Jun 2024 16:30:49 -0700 Subject: [PATCH 033/192] update storage ui --- pkg/bindata/templates/system.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/bindata/templates/system.html b/pkg/bindata/templates/system.html index c39af215d..e84b6c539 100644 --- a/pkg/bindata/templates/system.html +++ b/pkg/bindata/templates/system.html @@ -236,10 +236,12 @@

    Storage

    {{$v.Device}}
    -
    {{$v.Device}}
    -
    Total: {{megabyte $v.Total}}
    -
    Free: {{megabyte $v.Free}}
    -
    Used: {{megabyte $v.Used}}
    +
    {{$v.Device}}
    +
    Total: {{megabyte $v.Total}}
    +
    Free: {{megabyte $v.Free}}
    +
    Used: {{megabyte $v.Used}}
    +
    FS: {{$v.FSType}}{{if $v.ReadOnly}} (ro){{end}}
    + {{if $.ClientInfo.User.DevAllowed}}
    {{$v.Opts}}
    {{end}}
    From 7716099c91ae118229c570d3f88e1dcdca5cb1a6 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sat, 22 Jun 2024 16:32:41 -0700 Subject: [PATCH 034/192] update all deps --- go.mod | 26 +++++++++++----------- go.sum | 69 +++++++++++++++++++++++++--------------------------------- 2 files changed, 43 insertions(+), 52 deletions(-) diff --git a/go.mod b/go.mod index a0e52e56f..8202655a7 100644 --- a/go.mod +++ b/go.mod @@ -15,9 +15,9 @@ require ( github.com/go-ping/ping v1.1.0 github.com/go-sql-driver/mysql v1.8.1 github.com/gorilla/mux v1.8.1 - github.com/gorilla/schema v1.2.1 + github.com/gorilla/schema v1.4.0 github.com/gorilla/securecookie v1.1.2 - github.com/gorilla/websocket v1.5.0 + github.com/gorilla/websocket v1.5.3 github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b github.com/hekmon/transmissionrpc/v3 v3.0.0 github.com/hugelgupf/go-shlex v0.0.0-20200702092117-c80c9d0918fa @@ -29,14 +29,14 @@ require ( github.com/mitchellh/go-homedir v1.1.0 github.com/mrobinsn/go-rtorrent v1.8.0 github.com/nxadm/tail v1.4.11 - github.com/shirou/gopsutil/v3 v3.24.4 + github.com/shirou/gopsutil/v3 v3.24.5 github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace github.com/stretchr/testify v1.9.0 github.com/swaggo/swag v1.16.3 - golang.org/x/crypto v0.23.0 - golang.org/x/mod v0.17.0 - golang.org/x/sys v0.20.0 - golang.org/x/text v0.15.0 + golang.org/x/crypto v0.24.0 + golang.org/x/mod v0.18.0 + golang.org/x/sys v0.21.0 + golang.org/x/text v0.16.0 golang.org/x/time v0.5.0 golift.io/cache v0.0.2 golift.io/cnfg v0.2.3 @@ -50,7 +50,7 @@ require ( golift.io/starr v1.0.1-0.20240315164714-247399771c46 golift.io/version v0.0.2 golift.io/xtractr v0.2.2 - modernc.org/sqlite v1.29.10 + modernc.org/sqlite v1.30.1 ) require ( @@ -79,10 +79,10 @@ require ( github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/hekmon/cunits/v2 v2.1.0 // indirect - github.com/jaypipes/pcidb v1.0.0 // indirect + github.com/jaypipes/pcidb v1.0.1 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/kdomanski/iso9660 v0.4.0 // indirect - github.com/klauspost/compress v1.17.8 // indirect + github.com/klauspost/compress v1.17.9 // indirect github.com/lestrrat-go/strftime v1.0.6 // indirect github.com/lufia/plan9stats v0.0.0-20240513124658-fba389f38bae // indirect github.com/mailru/easyjson v0.7.7 // indirect @@ -104,15 +104,15 @@ require ( github.com/ulikunitz/xz v0.5.12 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect go4.org v0.0.0-20230225012048-214862532bf5 // indirect - golang.org/x/net v0.25.0 // indirect + golang.org/x/net v0.26.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/tools v0.21.0 // indirect + golang.org/x/tools v0.22.0 // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect howett.net/plist v1.0.1 // indirect modernc.org/gc/v3 v3.0.0-20240304020402-f0dba7c97c2b // indirect - modernc.org/libc v1.50.9 // indirect + modernc.org/libc v1.53.3 // indirect modernc.org/mathutil v1.6.0 // indirect modernc.org/memory v1.8.0 // indirect modernc.org/strutil v1.2.0 // indirect diff --git a/go.sum b/go.sum index 5e2d69181..6b4cf0ec5 100644 --- a/go.sum +++ b/go.sum @@ -108,8 +108,6 @@ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5a github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= @@ -132,12 +130,12 @@ github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/gorilla/rpc v1.2.1 h1:yC+LMV5esttgpVvNORL/xX4jvTTEUE30UZhZ5JF7K9k= github.com/gorilla/rpc v1.2.1/go.mod h1:uNpOihAlF5xRFLuTYhfR0yfCTm0WTQSQttkMSptRfGk= -github.com/gorilla/schema v1.2.1 h1:tjDxcmdb+siIqkTNoV+qRH2mjYdr2hHe5MKXbp61ziM= -github.com/gorilla/schema v1.2.1/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM= +github.com/gorilla/schema v1.4.0 h1:l2N+lRTJtev9SUhBtj6NmSxd/6+8LhvN0kV+H2Y8R9k= +github.com/gorilla/schema v1.4.0/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM= github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA= github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo= -github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= -github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= +github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b h1:wDUNC2eKiL35DbLvsDhiblTUXHxcOPwQSCzi7xpQUN4= github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b/go.mod h1:VzxiSdG6j1pi7rwGm/xYI5RbtpBgM8sARDXlvEvxlu0= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -162,8 +160,8 @@ github.com/jackpal/gateway v1.0.15 h1:yb4Gltgr8ApHWWnSyybnDL1vURbqw7ooo7IIL5VZSe github.com/jackpal/gateway v1.0.15/go.mod h1:dbyEDcDhHUh9EmjB9ung81elMUZfG0SoNc2TfTbcj4c= github.com/jaypipes/ghw v0.12.0 h1:xU2/MDJfWmBhJnujHY9qwXQLs3DBsf0/Xa9vECY0Tho= github.com/jaypipes/ghw v0.12.0/go.mod h1:jeJGbkRB2lL3/gxYzNYzEDETV1ZJ56OKr+CSeSEym+g= -github.com/jaypipes/pcidb v1.0.0 h1:vtZIfkiCUE42oYbJS0TAq9XSfSmcsgo9IdxSm9qzYU8= -github.com/jaypipes/pcidb v1.0.0/go.mod h1:TnYUvqhPBzCKnH34KrIX22kAeEbDCSRJ9cqLRCuNDfk= +github.com/jaypipes/pcidb v1.0.1 h1:WB2zh27T3nwg8AE8ei81sNRb9yWBii3JGNJtT7K9Oic= +github.com/jaypipes/pcidb v1.0.1/go.mod h1:6xYUz/yYEyOkIkUt2t2J2folIuZ4Yg6uByCGFXMCeE4= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= @@ -177,8 +175,8 @@ github.com/kevinburke/go-bindata/v4 v4.0.2 h1:6qQI0nNTL27wM1En8zQHGBEPp3ETzgFU6h github.com/kevinburke/go-bindata/v4 v4.0.2/go.mod h1:M/CkBqw2qCZ1Ztv5JyKgocGYWyUkYlDqkqXS1ktLe5c= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU= -github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= +github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -194,7 +192,6 @@ github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc/go.mod h1:kopu github.com/lestrrat-go/strftime v1.0.4/go.mod h1:E1nN3pCbtMSu1yjSVeyuRFVm/U0xoR76fd03sz+Qz4g= github.com/lestrrat-go/strftime v1.0.6 h1:CFGsDEt1pOpFNU+TJB0nhz9jl+K0hZSLE205AhTIGQQ= github.com/lestrrat-go/strftime v1.0.6/go.mod h1:f7jQKgV5nnJpYgdEasS+/y7EsTb8ykN2z68n3TtcTaw= -github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/lufia/plan9stats v0.0.0-20240513124658-fba389f38bae h1:dIZY4ULFcto4tAFlj1FYZl8ztUZ13bdq+PLY+NOfbyI= github.com/lufia/plan9stats v0.0.0-20240513124658-fba389f38bae/go.mod h1:ilwx/Dta8jXAgpFYFvSWEMwxmbWXyiUHkd5FwyKhb5k= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= @@ -220,7 +217,6 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU= github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -232,8 +228,8 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk= -github.com/shirou/gopsutil/v3 v3.24.4 h1:dEHgzZXt4LMNm+oYELpzl9YCqV65Yr/6SfrvgRBtXeU= -github.com/shirou/gopsutil/v3 v3.24.4/go.mod h1:lTd2mdiOspcqLgAnr9/nGi71NkeMpWKdmhuxm9GusH8= +github.com/shirou/gopsutil/v3 v3.24.5 h1:i0t8kL+kQTvpAYToeuiVk3TgDeKOFioZO3Ztz/iZ9pI= +github.com/shirou/gopsutil/v3 v3.24.5/go.mod h1:bsoOS1aStSs9ErQ1WWfxllSeS1K5D+U30r2NfcubMVk= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= @@ -261,10 +257,8 @@ github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af/go.mod h1:4F09kP5F+a github.com/tevino/abool v0.0.0-20220530134649-2bfc934cb23c/go.mod h1:qc66Pna1RiIsPa7O4Egxxs9OqkuxDX55zznh9K07Tzg= github.com/tevino/abool v1.2.0 h1:heAkClL8H6w+mK5md9dzsuohKeXHUpY7Vw0ZCKW+huA= github.com/tevino/abool v1.2.0/go.mod h1:qc66Pna1RiIsPa7O4Egxxs9OqkuxDX55zznh9K07Tzg= -github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= github.com/tklauser/go-sysconf v0.3.14 h1:g5vzr9iPFFz24v2KZXs/pvpvh8/V9Fw6vQK5ZZb78yU= github.com/tklauser/go-sysconf v0.3.14/go.mod h1:1ym4lWMLUOhuBOPGtRcJm7tEGX4SCYNEEEtghGG/8uY= -github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/tklauser/numcpus v0.8.0 h1:Mx4Wwe/FjZLeQsK/6kt2EOepwwSl7SmJrK5bV/dXYgY= github.com/tklauser/numcpus v0.8.0/go.mod h1:ZJZlAY+dmR4eut8epnzf0u/VwodKmryxR8txiloSqBE= github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8= @@ -286,8 +280,8 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= -golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= +golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= +golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -315,8 +309,8 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0= +golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -335,8 +329,8 @@ golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLd golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= -golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= +golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= +golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -378,11 +372,8 @@ golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= -golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= @@ -393,8 +384,8 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= -golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= @@ -425,8 +416,8 @@ golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw= -golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= +golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA= +golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -509,18 +500,18 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= howett.net/plist v1.0.1 h1:37GdZ8tP09Q35o9ych3ehygcsL+HqKSwzctveSlarvM= howett.net/plist v1.0.1/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g= -modernc.org/cc/v4 v4.21.2 h1:dycHFB/jDc3IyacKipCNSDrjIC0Lm1hyoWOZTRR20Lk= -modernc.org/cc/v4 v4.21.2/go.mod h1:HM7VJTZbUCR3rV8EYBi9wxnJ0ZBRiGE5OeGXNA0IsLQ= -modernc.org/ccgo/v4 v4.17.8 h1:yyWBf2ipA0Y9GGz/MmCmi3EFpKgeS7ICrAFes+suEbs= -modernc.org/ccgo/v4 v4.17.8/go.mod h1:buJnJ6Fn0tyAdP/dqePbrrvLyr6qslFfTbFrCuaYvtA= +modernc.org/cc/v4 v4.21.3 h1:2mhBdWKtivdFlLR1ecKXTljPG1mfvbByX7QKztAIJl8= +modernc.org/cc/v4 v4.21.3/go.mod h1:HM7VJTZbUCR3rV8EYBi9wxnJ0ZBRiGE5OeGXNA0IsLQ= +modernc.org/ccgo/v4 v4.18.1 h1:1zF5kPBFq/ZVTulBOKgQPQITdOzzyBUfC51gVYP62E4= +modernc.org/ccgo/v4 v4.18.1/go.mod h1:ao1fAxf9a2KEOL15WY8+yP3wnpaOpP/QuyFOZ9HJolM= modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE= modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ= modernc.org/gc/v2 v2.4.1 h1:9cNzOqPyMJBvrUipmynX0ZohMhcxPtMccYgGOJdOiBw= modernc.org/gc/v2 v2.4.1/go.mod h1:wzN5dK1AzVGoH6XOzc3YZ+ey/jPgYHLuVckd62P0GYU= modernc.org/gc/v3 v3.0.0-20240304020402-f0dba7c97c2b h1:BnN1t+pb1cy61zbvSUV7SeI0PwosMhlAEi/vBY4qxp8= modernc.org/gc/v3 v3.0.0-20240304020402-f0dba7c97c2b/go.mod h1:Qz0X07sNOR1jWYCrJMEnbW/X55x206Q7Vt4mz6/wHp4= -modernc.org/libc v1.50.9 h1:hIWf1uz55lorXQhfoEoezdUHjxzuO6ceshET/yWjSjk= -modernc.org/libc v1.50.9/go.mod h1:15P6ublJ9FJR8YQCGy8DeQ2Uwur7iW9Hserr/T3OFZE= +modernc.org/libc v1.53.3 h1:9O0aSLZuHPgp49we24NoFFteRgXNLGBAQ3TODrW3XLg= +modernc.org/libc v1.53.3/go.mod h1:kb+Erju4FfHNE59xd2fNpv5CBeAeej6fHbx8p8xaiyI= modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E= @@ -529,8 +520,8 @@ modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4= modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= modernc.org/sortutil v1.2.0 h1:jQiD3PfS2REGJNzNCMMaLSp/wdMNieTbKX920Cqdgqc= modernc.org/sortutil v1.2.0/go.mod h1:TKU2s7kJMf1AE84OoiGppNHJwvB753OYfNl2WRb++Ss= -modernc.org/sqlite v1.29.10 h1:3u93dz83myFnMilBGCOLbr+HjklS6+5rJLx4q86RDAg= -modernc.org/sqlite v1.29.10/go.mod h1:ItX2a1OVGgNsFh6Dv60JQvGfJfTPHPVpV6DF59akYOA= +modernc.org/sqlite v1.30.1 h1:YFhPVfu2iIgUf9kuA1CR7iiHdcEEsI2i+yjRYHscyxk= +modernc.org/sqlite v1.30.1/go.mod h1:DUmsiWQDaAvU4abhc/N+djlom/L2o8f7gZ95RCvyoLU= modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA= modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0= modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= From c52a4a749f82c248d0e808b6c98759de441575bb Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sat, 22 Jun 2024 18:39:23 -0700 Subject: [PATCH 035/192] fix auto update on windows --- pkg/client/client_windows.go | 20 +++++++++----------- pkg/update/update.go | 6 ++---- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/pkg/client/client_windows.go b/pkg/client/client_windows.go index 5ff007342..3a0cb7f4a 100644 --- a/pkg/client/client_windows.go +++ b/pkg/client/client_windows.go @@ -93,23 +93,20 @@ func (c *Client) startAutoUpdater(ctx context.Context, dur time.Duration) { func (c *Client) checkAndUpdate(ctx context.Context, how string) error { var ( - data *update.Update - err error where = "GitHub" + cmd = update.CheckGitHub + chk = version.Version ) if c.Config.UnstableCh { - c.Debugf("[cron requested] Checking Unstable website for Update.") - - data, err = update.CheckUnstable(ctx, mnd.Title, version.Version) where = "Unstable website" - } else { - c.Debugf("[cron requested] Checking GitHub for Update.") - - data, err = update.CheckGitHub(ctx, mnd.UserRepo, version.Version) + cmd = update.CheckUnstable + chk = version.Revision } - if err != nil { + c.Debugf("[cron requested] Checking %s for Update.", where) + + if data, err := cmd(ctx, mnd.UserRepo, chk); err != nil { return fmt.Errorf("checking %s for update: %w", where, err) } else if !data.Outdate { return nil @@ -121,7 +118,8 @@ func (c *Client) checkAndUpdate(ctx context.Context, how string) error { } func (c *Client) updateNow(ctx context.Context, u *update.Update, msg string) error { - c.Printf("[UPDATE] Downloading and installing update! %s => %s: %s", u.Version, u.Current, u.CurrURL) + c.Printf("[UPDATE] Downloading and installing update! %s-%s => %s: %s", + version.Version, version.Revision, u.Current, u.CurrURL) cmd := &update.Command{ URL: u.CurrURL, diff --git a/pkg/update/update.go b/pkg/update/update.go index 3f25633ba..0778e3668 100644 --- a/pkg/update/update.go +++ b/pkg/update/update.go @@ -25,11 +25,9 @@ import ( ) // SleepTime is how long we wait after updating before exiting. -const SleepTime = 5 * time.Second +const SleepTime = 10 * time.Minute -const ( - downloadTimeout = 5 * time.Minute -) +const downloadTimeout = 5 * time.Minute // Command is the input data to perform an in-place update. type Command struct { From bcfddd50dfb1dd74b5bc0eafc9a517e08c631716 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sat, 22 Jun 2024 20:29:44 -0700 Subject: [PATCH 036/192] make smart data work on macos --- pkg/snapshot/diskusage.go | 6 +++++ pkg/snapshot/smartctl.go | 48 ++++++++++++++++----------------------- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/pkg/snapshot/diskusage.go b/pkg/snapshot/diskusage.go index e6c460e06..6b13291a4 100644 --- a/pkg/snapshot/diskusage.go +++ b/pkg/snapshot/diskusage.go @@ -36,6 +36,12 @@ func (s *Snapshot) getDisksUsage(ctx context.Context, run bool, allDrives bool) continue } + if usage.Fstype == "tmpfs" || // skip tmpfs volumes + (slices.Contains(partitions[idx].Opts, "ro") && slices.Contains(partitions[idx].Opts, "nodev")) || // skip read only volumes with no device. + (runtime.GOOS == "darwin" && slices.Contains(partitions[idx].Opts, "nobrowse")) { // skip hidden volumes on macos. + continue + } + if usage.Total == 0 || ((runtime.GOOS == "darwin" || strings.HasSuffix(runtime.GOOS, "bsd")) && !strings.HasPrefix(partitions[idx].Device, "/dev/")) { diff --git a/pkg/snapshot/smartctl.go b/pkg/snapshot/smartctl.go index ca02db6ec..cc532f988 100644 --- a/pkg/snapshot/smartctl.go +++ b/pkg/snapshot/smartctl.go @@ -4,14 +4,13 @@ import ( "bufio" "context" "fmt" - "path" "runtime" + "slices" "strconv" "strings" "sync" "github.com/Notifiarr/notifiarr/pkg/mnd" - "github.com/jaypipes/ghw" "github.com/shirou/gopsutil/v3/disk" ) @@ -38,7 +37,7 @@ func (s *Snapshot) getDriveData(ctx context.Context, run bool, useSudo bool) (er case "linux": err = getSmartDisks(ctx, useSudo, disks) case "darwin": - err = getBlocks(disks) + err = getParts(ctx, disks) default: err = getParts(ctx, disks) } @@ -87,40 +86,31 @@ func getSmartDisks(ctx context.Context, useSudo bool, disks map[string]string) e return runCommand(cmd, waitg) } -// works well on mac and linux, probably windows too. -func getBlocks(disks map[string]string) error { - block, err := ghw.Block() - if err != nil { - return fmt.Errorf("unable to get block devices: %w", err) - } - - have := make(map[string]struct{}) - for _, dev := range block.Disks { - if _, ok := have[dev.BusPath]; ok { - continue - } - - have[dev.BusPath] = struct{}{} - - if runtime.GOOS != mnd.Windows { - disks[path.Join("/dev", dev.Name)] = "" - } else { - disks[dev.Name] = "" - } - } - - return nil -} - // use this for everything else.... func getParts(ctx context.Context, disks map[string]string) error { + const macDiskPrefix = "/dev/disk" + partitions, err := disk.PartitionsWithContext(ctx, false) if err != nil { return fmt.Errorf("unable to get partitions: %w", err) } for _, part := range partitions { - disks[part.Device] = "" + switch runtime.GOOS { + case "darwin": + if !strings.HasPrefix(part.Device, macDiskPrefix) || slices.Contains(part.Opts, "nobrowse") { + continue + } + + stop := strings.Index(strings.TrimPrefix(part.Device, macDiskPrefix), "s") + if stop > 0 { + part.Device = part.Device[:stop+len(macDiskPrefix)] + } + + fallthrough + default: + disks[part.Device] = "" + } } return nil From 5be8f32d4478736c18b725635785f8e600869837 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sat, 22 Jun 2024 23:24:58 -0700 Subject: [PATCH 037/192] fix some dates --- LICENSE | 2 +- init/macos/Notifiarr.app/Contents/Info.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index 174127f09..3f0c5b2d8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020-2023 Go Lift - Building Strong Go Tools +Copyright (c) 2020-2024 Go Lift - Building Strong Go Tools Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/init/macos/Notifiarr.app/Contents/Info.plist b/init/macos/Notifiarr.app/Contents/Info.plist index 0fd04c24e..3f4bb6d63 100644 --- a/init/macos/Notifiarr.app/Contents/Info.plist +++ b/init/macos/Notifiarr.app/Contents/Info.plist @@ -17,7 +17,7 @@ CFBundleShortVersionString {{VERSION}} NSHumanReadableCopyright - © 2023 Go Lift (https://golift.io) + © 2024 Go Lift (https://golift.io) NSPrincipalClass NSApplication LSApplicationCategoryType From 9fcf4b86ec88280d3bf4147e7d67df2472eafd76 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sat, 22 Jun 2024 23:43:13 -0700 Subject: [PATCH 038/192] clean up and lint --- pkg/mnd/constants.go | 1 + pkg/snapshot/diskusage.go | 11 +++++++---- pkg/snapshot/smartctl.go | 35 ++++++++--------------------------- pkg/update/unstable.go | 2 +- 4 files changed, 17 insertions(+), 32 deletions(-) diff --git a/pkg/mnd/constants.go b/pkg/mnd/constants.go index a2dbd3438..84153bf92 100644 --- a/pkg/mnd/constants.go +++ b/pkg/mnd/constants.go @@ -37,6 +37,7 @@ const ( IsLinux = runtime.GOOS == "linux" IsWindows = runtime.GOOS == Windows IsFreeBSD = runtime.GOOS == "freebsd" + IsDarwin = runtime.GOOS == "darwin" ) // Application Defaults. diff --git a/pkg/snapshot/diskusage.go b/pkg/snapshot/diskusage.go index 6b13291a4..d13394e75 100644 --- a/pkg/snapshot/diskusage.go +++ b/pkg/snapshot/diskusage.go @@ -36,14 +36,17 @@ func (s *Snapshot) getDisksUsage(ctx context.Context, run bool, allDrives bool) continue } - if usage.Fstype == "tmpfs" || // skip tmpfs volumes - (slices.Contains(partitions[idx].Opts, "ro") && slices.Contains(partitions[idx].Opts, "nodev")) || // skip read only volumes with no device. - (runtime.GOOS == "darwin" && slices.Contains(partitions[idx].Opts, "nobrowse")) { // skip hidden volumes on macos. + // skip tmpfs volumes + if usage.Fstype == "tmpfs" || + // skip read only volumes with no device. + (slices.Contains(partitions[idx].Opts, "ro") && slices.Contains(partitions[idx].Opts, "nodev")) || + // skip hidden volumes on macos. + (mnd.IsDarwin && slices.Contains(partitions[idx].Opts, "nobrowse")) { continue } if usage.Total == 0 || - ((runtime.GOOS == "darwin" || strings.HasSuffix(runtime.GOOS, "bsd")) && + ((mnd.IsDarwin || strings.HasSuffix(runtime.GOOS, "bsd")) && !strings.HasPrefix(partitions[idx].Device, "/dev/")) { continue } diff --git a/pkg/snapshot/smartctl.go b/pkg/snapshot/smartctl.go index cc532f988..2813ae8ba 100644 --- a/pkg/snapshot/smartctl.go +++ b/pkg/snapshot/smartctl.go @@ -4,7 +4,6 @@ import ( "bufio" "context" "fmt" - "runtime" "slices" "strconv" "strings" @@ -22,28 +21,13 @@ func (s *Snapshot) getDriveData(ctx context.Context, run bool, useSudo bool) (er return nil } - var ( - disks = make(map[string]string) - err error - ) - - switch runtime.GOOS { - case mnd.Windows: - if err := getParts(ctx, disks); err != nil { + disks := make(map[string]string) + if err := getParts(ctx, disks); err != nil { + errs = append(errs, err) + // parts failed, so try smart. + if err := getSmartDisks(ctx, useSudo, disks); err != nil { errs = append(errs, err) } - - fallthrough - case "linux": - err = getSmartDisks(ctx, useSudo, disks) - case "darwin": - err = getParts(ctx, disks) - default: - err = getParts(ctx, disks) - } - - if err != nil { - errs = append(errs, err) } if len(disks) == 0 { @@ -96,8 +80,7 @@ func getParts(ctx context.Context, disks map[string]string) error { } for _, part := range partitions { - switch runtime.GOOS { - case "darwin": + if mnd.IsDarwin { if !strings.HasPrefix(part.Device, macDiskPrefix) || slices.Contains(part.Opts, "nobrowse") { continue } @@ -106,11 +89,9 @@ func getParts(ctx context.Context, disks map[string]string) error { if stop > 0 { part.Device = part.Device[:stop+len(macDiskPrefix)] } - - fallthrough - default: - disks[part.Device] = "" } + + disks[part.Device] = "" } return nil diff --git a/pkg/update/unstable.go b/pkg/update/unstable.go index a10bb78a6..c0b54c222 100644 --- a/pkg/update/unstable.go +++ b/pkg/update/unstable.go @@ -30,7 +30,7 @@ func CheckUnstable(ctx context.Context, app string, revision string) (*Update, e app = strings.ToLower(app) uri := fmt.Sprintf("%s/%s/%s.%s.exe.zip", unstableURL, app, app, runtime.GOARCH) - if runtime.GOOS == "darwin" { + if mnd.IsDarwin { uri = fmt.Sprintf("%s/%s/%s.dmg", unstableURL, app, app) } else if !mnd.IsWindows { uri = fmt.Sprintf("%s/%s/%s.%s.%s.gz", unstableURL, app, app, runtime.GOARCH, runtime.GOOS) From e43148ef1a5969c336a33cac53781f043d325322 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 23 Jun 2024 15:09:32 -0700 Subject: [PATCH 039/192] fix auto update selector --- pkg/bindata/templates/config.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/bindata/templates/config.html b/pkg/bindata/templates/config.html index 2edec8294..0c91a0f9a 100644 --- a/pkg/bindata/templates/config.html +++ b/pkg/bindata/templates/config.html @@ -117,7 +117,7 @@

    General

    - {{- if eq .Version.os "windows" }} + {{- if (eq .Version.os "windows") }} {{- end}} From 60957066a4eb5da4cc011627d8508a9b89c3d50f Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 23 Jun 2024 15:26:21 -0700 Subject: [PATCH 040/192] fix another update bug --- pkg/client/client_windows.go | 5 ++++- pkg/update/update.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/client/client_windows.go b/pkg/client/client_windows.go index 3a0cb7f4a..997210b8e 100644 --- a/pkg/client/client_windows.go +++ b/pkg/client/client_windows.go @@ -17,6 +17,9 @@ import ( "golift.io/version" ) +// WaitTime is how long we wait, after startup, before doing an update check. +const WaitTime = 10 * time.Minute + // This is the pop-up a user sees when they click update in the menu. func (c *Client) upgradeWindows(ctx context.Context, update *update.Update) { yes, _ := ui.Question(mnd.Title, "An Update is available! Upgrade Now?\n\n"+ @@ -77,7 +80,7 @@ func (c *Client) startAutoUpdater(ctx context.Context, dur time.Duration) { c.Print(pfx+"Auto-updater started. Check interval:", durafmt.Parse(dur).String()) - time.Sleep(update.SleepTime) + time.Sleep(WaitTime) // Check for update on startup. if err := c.checkAndUpdate(ctx, "startup check"); err != nil { c.Errorf("Startup-Update Failed: %v", err) diff --git a/pkg/update/update.go b/pkg/update/update.go index 0778e3668..3aa4a2552 100644 --- a/pkg/update/update.go +++ b/pkg/update/update.go @@ -25,7 +25,7 @@ import ( ) // SleepTime is how long we wait after updating before exiting. -const SleepTime = 10 * time.Minute +const SleepTime = 4 * time.Second const downloadTimeout = 5 * time.Minute From 3f32116a4fab91d2cb9da548db671e4aa93509af Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 23 Jun 2024 15:38:43 -0700 Subject: [PATCH 041/192] allow deluge to have no password --- pkg/apps/integrations.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/apps/integrations.go b/pkg/apps/integrations.go index 57672d838..e1682036b 100644 --- a/pkg/apps/integrations.go +++ b/pkg/apps/integrations.go @@ -95,8 +95,8 @@ type DelugeConfig struct { func (a *Apps) setupDeluge() error { for idx, app := range a.Deluge { - if app == nil || app.Config == nil || app.URL == "" || app.Password == "" { - return fmt.Errorf("%w: missing url or password: Deluge config %d", ErrInvalidApp, idx+1) + if app == nil || app.Config == nil || app.URL == "" { + return fmt.Errorf("%w: missing url: Deluge config %d", ErrInvalidApp, idx+1) } else if !strings.HasPrefix(app.Config.URL, "http://") && !strings.HasPrefix(app.Config.URL, "https://") { return fmt.Errorf("%w: URL must begin with http:// or https://: Deluge config %d", ErrInvalidApp, idx+1) } @@ -134,7 +134,7 @@ func (c *DelugeConfig) setup(maxBody int, logger mnd.Logger) error { // Enabled returns true if the instance is enabled and usable. func (c *DelugeConfig) Enabled() bool { - return c != nil && c.Config != nil && c.URL != "" && c.Password != "" && c.Timeout.Duration >= 0 + return c != nil && c.Config != nil && c.URL != "" && c.Timeout.Duration >= 0 } type SabNZBConfig struct { From 340a24b770489a36fc710e76ff957838d1dae00e Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 23 Jun 2024 16:11:58 -0700 Subject: [PATCH 042/192] better tooltip --- pkg/client/client_windows.go | 2 +- pkg/client/start.go | 2 +- pkg/client/tray.go | 3 +-- pkg/client/tray_commands.go | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/pkg/client/client_windows.go b/pkg/client/client_windows.go index 997210b8e..1b1e48634 100644 --- a/pkg/client/client_windows.go +++ b/pkg/client/client_windows.go @@ -78,9 +78,9 @@ func (c *Client) startAutoUpdater(ctx context.Context, dur time.Duration) { pfx = "Unstable Channel " } + time.Sleep(WaitTime) c.Print(pfx+"Auto-updater started. Check interval:", durafmt.Parse(dur).String()) - time.Sleep(WaitTime) // Check for update on startup. if err := c.checkAndUpdate(ctx, "startup check"); err != nil { c.Errorf("Startup-Update Failed: %v", err) diff --git a/pkg/client/start.go b/pkg/client/start.go index bb4db5522..c77d92eae 100644 --- a/pkg/client/start.go +++ b/pkg/client/start.go @@ -98,7 +98,7 @@ func Start() error { //nolint:forbidigo,wrapcheck switch { case client.Flags.LongVerReq: // print version and exit. - _, err := fmt.Println(version.Print(client.Flags.Name())) + _, err := fmt.Println(SystrayTooltip(client.Flags.Name())) return err case client.Flags.VerReq: // print version and exit. _, err := fmt.Println(client.Flags.Name() + " " + version.Version + "-" + version.Revision) diff --git a/pkg/client/tray.go b/pkg/client/tray.go index a9ed5d28a..b09849736 100644 --- a/pkg/client/tray.go +++ b/pkg/client/tray.go @@ -18,7 +18,6 @@ import ( "github.com/Notifiarr/notifiarr/pkg/website/clientinfo" "github.com/energye/systray" "golift.io/starr" - "golift.io/version" ) /* This file handles the OS GUI elements. */ @@ -37,7 +36,7 @@ func (c *Client) startTray(ctx context.Context, cancel context.CancelFunc, clien b, _ := bindata.Asset(ui.SystrayIcon) systray.SetTemplateIcon(b, b) - systray.SetTooltip(version.Print(c.Flags.Name())) + systray.SetTooltip(SystrayTooltip(c.Flags.Name())) // systray.SetOnClick(c.showMenu) // buggy systray.SetOnRClick(c.showMenu) systray.SetOnDClick(func(_ systray.IMenu) { c.openGUI() }) diff --git a/pkg/client/tray_commands.go b/pkg/client/tray_commands.go index 933b22203..b3b93bcf9 100644 --- a/pkg/client/tray_commands.go +++ b/pkg/client/tray_commands.go @@ -3,8 +3,10 @@ package client import ( + "bytes" "context" "fmt" + "html/template" "runtime" "strings" @@ -235,3 +237,36 @@ func (c *Client) updatePassword(ctx context.Context) { c.Errorf("Creating Toast Notification: %v", err) } } + +// versionInfoTmpl contains the template used by systray tooltip. +const versionInfoTmpl = ` +{{.program}} v{{.version}}-{{.revision}} [{{.branch}}] + build user: {{.buildUser}} + build date: {{.buildDate}} + go version: {{.goVersion}} + platform: {{.platform}} + started: {{.started}} +` + +// Print returns version information. +func SystrayTooltip(program string) string { + m := map[string]string{ + "started": version.Started.String(), + "program": program, + "version": version.Version, + "revision": version.Revision, + "branch": version.Branch, + "buildUser": version.BuildUser, + "buildDate": version.BuildDate, + "goVersion": version.GoVersion, + "platform": runtime.GOOS + "/" + runtime.GOARCH, + } + t := template.Must(template.New("version").Parse(versionInfoTmpl)) + + var buf bytes.Buffer + if err := t.ExecuteTemplate(&buf, "version", m); err != nil { + panic(err) + } + + return strings.TrimSpace(buf.String()) +} From 6da17fefbcededf3d6d5f314112abc12badae0f7 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 23 Jun 2024 17:06:48 -0700 Subject: [PATCH 043/192] get all the disks on linux --- pkg/snapshot/smartctl.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/snapshot/smartctl.go b/pkg/snapshot/smartctl.go index 2813ae8ba..664d16d7d 100644 --- a/pkg/snapshot/smartctl.go +++ b/pkg/snapshot/smartctl.go @@ -22,9 +22,14 @@ func (s *Snapshot) getDriveData(ctx context.Context, run bool, useSudo bool) (er } disks := make(map[string]string) - if err := getParts(ctx, disks); err != nil { + + err := getParts(ctx, disks) + if err != nil { errs = append(errs, err) - // parts failed, so try smart. + } + + if err != nil || mnd.IsLinux { + // We also do this because getParts doesn't always return (all the) disk drives. if err := getSmartDisks(ctx, useSudo, disks); err != nil { errs = append(errs, err) } From a58288f80d93bf9fc1364f545aec8d9392d6804f Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 23 Jun 2024 17:15:13 -0700 Subject: [PATCH 044/192] fix missing func call --- pkg/client/start.go | 2 +- pkg/client/tray.go | 2 +- pkg/client/tray_commands.go | 22 +++++++++------------- pkg/mnd/functions.go | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 15 deletions(-) diff --git a/pkg/client/start.go b/pkg/client/start.go index c77d92eae..cdb4819f2 100644 --- a/pkg/client/start.go +++ b/pkg/client/start.go @@ -98,7 +98,7 @@ func Start() error { //nolint:forbidigo,wrapcheck switch { case client.Flags.LongVerReq: // print version and exit. - _, err := fmt.Println(SystrayTooltip(client.Flags.Name())) + _, err := fmt.Println(mnd.PrintVersionInfo(client.Flags.Name())) return err case client.Flags.VerReq: // print version and exit. _, err := fmt.Println(client.Flags.Name() + " " + version.Version + "-" + version.Revision) diff --git a/pkg/client/tray.go b/pkg/client/tray.go index b09849736..17ef090ff 100644 --- a/pkg/client/tray.go +++ b/pkg/client/tray.go @@ -36,7 +36,7 @@ func (c *Client) startTray(ctx context.Context, cancel context.CancelFunc, clien b, _ := bindata.Asset(ui.SystrayIcon) systray.SetTemplateIcon(b, b) - systray.SetTooltip(SystrayTooltip(c.Flags.Name())) + systray.SetTooltip(mnd.PrintVersionInfo(c.Flags.Name())) // systray.SetOnClick(c.showMenu) // buggy systray.SetOnRClick(c.showMenu) systray.SetOnDClick(func(_ systray.IMenu) { c.openGUI() }) diff --git a/pkg/client/tray_commands.go b/pkg/client/tray_commands.go index b3b93bcf9..780f368f8 100644 --- a/pkg/client/tray_commands.go +++ b/pkg/client/tray_commands.go @@ -238,18 +238,8 @@ func (c *Client) updatePassword(ctx context.Context) { } } -// versionInfoTmpl contains the template used by systray tooltip. -const versionInfoTmpl = ` -{{.program}} v{{.version}}-{{.revision}} [{{.branch}}] - build user: {{.buildUser}} - build date: {{.buildDate}} - go version: {{.goVersion}} - platform: {{.platform}} - started: {{.started}} -` - -// Print returns version information. -func SystrayTooltip(program string) string { +// PrintVersionInfo returns version information. +func PrintVersionInfo(program string) string { m := map[string]string{ "started": version.Started.String(), "program": program, @@ -261,7 +251,13 @@ func SystrayTooltip(program string) string { "goVersion": version.GoVersion, "platform": runtime.GOOS + "/" + runtime.GOARCH, } - t := template.Must(template.New("version").Parse(versionInfoTmpl)) + t := template.Must(template.New("version").Parse( + `{{.program}} v{{.version}}-{{.revision}} [{{.branch}}] + build user: {{.buildUser}} + build date: {{.buildDate}} + go version: {{.goVersion}} + platform: {{.platform}} + started: {{.started}}` + "\n")) var buf bytes.Buffer if err := t.ExecuteTemplate(&buf, "version", m); err != nil { diff --git a/pkg/mnd/functions.go b/pkg/mnd/functions.go index d51671d39..5d0807156 100644 --- a/pkg/mnd/functions.go +++ b/pkg/mnd/functions.go @@ -2,10 +2,15 @@ package mnd import ( + "bytes" "fmt" + "html/template" + "runtime" + "strings" "time" "github.com/hako/durafmt" + "golift.io/version" ) // FormatBytes converts a byte counter into a pretty UI string. @@ -49,3 +54,32 @@ func FormatBytes(size interface{}) string { //nolint:cyclop func DurationAgo(when time.Time) string { return " (" + durafmt.Parse(time.Since(when).Round(time.Hour)).String() + " ago)" } + +// PrintVersionInfo returns version information. +func PrintVersionInfo(program string) string { + m := map[string]string{ + "started": version.Started.String(), + "program": program, + "version": version.Version, + "revision": version.Revision, + "branch": version.Branch, + "buildUser": version.BuildUser, + "buildDate": version.BuildDate, + "goVersion": version.GoVersion, + "platform": runtime.GOOS + "/" + runtime.GOARCH, + } + t := template.Must(template.New("version").Parse( + `{{.program}} v{{.version}}-{{.revision}} [{{.branch}}] + build user: {{.buildUser}} + build date: {{.buildDate}} + go version: {{.goVersion}} + platform: {{.platform}} + started: {{.started}}` + "\n")) + + var buf bytes.Buffer + if err := t.ExecuteTemplate(&buf, "version", m); err != nil { + panic(err) + } + + return strings.TrimSpace(buf.String()) +} From 60406225a517c75f5a567a5a99b8e83f3ac72a6c Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 23 Jun 2024 17:36:03 -0700 Subject: [PATCH 045/192] fix ssl save bug --- pkg/client/tray_commands.go | 31 ------------------------------- pkg/configfile/template.go | 2 +- 2 files changed, 1 insertion(+), 32 deletions(-) diff --git a/pkg/client/tray_commands.go b/pkg/client/tray_commands.go index 780f368f8..933b22203 100644 --- a/pkg/client/tray_commands.go +++ b/pkg/client/tray_commands.go @@ -3,10 +3,8 @@ package client import ( - "bytes" "context" "fmt" - "html/template" "runtime" "strings" @@ -237,32 +235,3 @@ func (c *Client) updatePassword(ctx context.Context) { c.Errorf("Creating Toast Notification: %v", err) } } - -// PrintVersionInfo returns version information. -func PrintVersionInfo(program string) string { - m := map[string]string{ - "started": version.Started.String(), - "program": program, - "version": version.Version, - "revision": version.Revision, - "branch": version.Branch, - "buildUser": version.BuildUser, - "buildDate": version.BuildDate, - "goVersion": version.GoVersion, - "platform": runtime.GOOS + "/" + runtime.GOARCH, - } - t := template.Must(template.New("version").Parse( - `{{.program}} v{{.version}}-{{.revision}} [{{.branch}}] - build user: {{.buildUser}} - build date: {{.buildDate}} - go version: {{.goVersion}} - platform: {{.platform}} - started: {{.started}}` + "\n")) - - var buf bytes.Buffer - if err := t.ExecuteTemplate(&buf, "version", m); err != nil { - panic(err) - } - - return strings.TrimSpace(buf.String()) -} diff --git a/pkg/configfile/template.go b/pkg/configfile/template.go index 668c65cd5..6d893c984 100644 --- a/pkg/configfile/template.go +++ b/pkg/configfile/template.go @@ -111,7 +111,7 @@ urlbase = '''{{.URLBase}}''' ## Uncomment both lines and add valid file paths. Make sure this app can read them. ## {{if .SSLKeyFile}}ssl_key_file = '''{{.SSLKeyFile}}'''{{else}}#ssl_key_file = '/path/to/cert.key'{{end}} -{{if .SSLCrtFile}}ssl_cert_file = '''{{.SSLCrtFile}}''{{else}}#ssl_cert_file = '/path/to/cert.key'{{end}} +{{if .SSLCrtFile}}ssl_cert_file = '''{{.SSLCrtFile}}'''{{else}}#ssl_cert_file = '/path/to/cert.key'{{end}} ## If you set these, logs will be written to these files. ## If blank on windows or macOS, log file paths are chosen for you. From eb97ca6e96958b542884281064e6be1f203a8e98 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 23 Jun 2024 17:54:28 -0700 Subject: [PATCH 046/192] bust cf cache --- pkg/update/unstable.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/update/unstable.go b/pkg/update/unstable.go index c0b54c222..38cf461e1 100644 --- a/pkg/update/unstable.go +++ b/pkg/update/unstable.go @@ -58,8 +58,10 @@ func GetUnstable(ctx context.Context, uri string) (*UnstableFile, error) { ctx, cancel := context.WithTimeout(ctx, timeout) defer cancel() - release := UnstableFile{File: uri} - uri += ".txt" + // we use stamp to bust the cloudflare cache. + stamp := "?stamp=" + time.Now().UTC().Format("2006-01-02-15") + release := UnstableFile{File: uri + stamp} + uri += ".txt" + stamp req, err := http.NewRequestWithContext(ctx, http.MethodGet, uri, nil) if err != nil { From 1af5c3bf3485491d52685b1db5098feddd120a11 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 23 Jun 2024 18:10:40 -0700 Subject: [PATCH 047/192] use smart on windows too --- pkg/snapshot/smartctl.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/snapshot/smartctl.go b/pkg/snapshot/smartctl.go index 664d16d7d..06cd58da6 100644 --- a/pkg/snapshot/smartctl.go +++ b/pkg/snapshot/smartctl.go @@ -28,7 +28,7 @@ func (s *Snapshot) getDriveData(ctx context.Context, run bool, useSudo bool) (er errs = append(errs, err) } - if err != nil || mnd.IsLinux { + if !mnd.IsDarwin { // We also do this because getParts doesn't always return (all the) disk drives. if err := getSmartDisks(ctx, useSudo, disks); err != nil { errs = append(errs, err) From 56585294e21fbe243cb16e81fafeccc82951ded7 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 23 Jun 2024 18:41:10 -0700 Subject: [PATCH 048/192] fixes --- pkg/client/client_windows.go | 20 ++++++++++---------- pkg/client/tray_commands.go | 2 +- pkg/snapshot/smartctl.go | 31 +++++++++++++++++++++++++++++++ pkg/update/unstable.go | 2 -- 4 files changed, 42 insertions(+), 13 deletions(-) diff --git a/pkg/client/client_windows.go b/pkg/client/client_windows.go index 1b1e48634..cfa2ff4d3 100644 --- a/pkg/client/client_windows.go +++ b/pkg/client/client_windows.go @@ -96,21 +96,21 @@ func (c *Client) startAutoUpdater(ctx context.Context, dur time.Duration) { func (c *Client) checkAndUpdate(ctx context.Context, how string) error { var ( - where = "GitHub" - cmd = update.CheckGitHub - chk = version.Version + data *update.Update + err error ) + //nolint:wsl if c.Config.UnstableCh { - where = "Unstable website" - cmd = update.CheckUnstable - chk = version.Revision + c.Debugf("[cron requested] Checking Unstable website for Update.") + data, err = update.CheckUnstable(ctx, mnd.DefaultName, version.Revision) + } else { + c.Debugf("[cron requested] Checking GitHub for Update.") + data, err = update.CheckGitHub(ctx, mnd.UserRepo, version.Version) } - c.Debugf("[cron requested] Checking %s for Update.", where) - - if data, err := cmd(ctx, mnd.UserRepo, chk); err != nil { - return fmt.Errorf("checking %s for update: %w", where, err) + if err != nil { + return fmt.Errorf("checking for update: %w", err) } else if !data.Outdate { return nil } else if err = c.updateNow(ctx, data, how); err != nil { diff --git a/pkg/client/tray_commands.go b/pkg/client/tray_commands.go index 933b22203..d59cc1388 100644 --- a/pkg/client/tray_commands.go +++ b/pkg/client/tray_commands.go @@ -59,7 +59,7 @@ func (c *Client) checkForUpdate(ctx context.Context, unstable bool) { if unstable { c.Print("[user requested] Unstable Update Check") - data, err = update.CheckUnstable(ctx, mnd.Title, version.Revision) + data, err = update.CheckUnstable(ctx, mnd.DefaultName, version.Revision) where = "Unstable website" } else { c.Print("[user requested] GitHub Update Check") diff --git a/pkg/snapshot/smartctl.go b/pkg/snapshot/smartctl.go index 06cd58da6..54add1b87 100644 --- a/pkg/snapshot/smartctl.go +++ b/pkg/snapshot/smartctl.go @@ -4,12 +4,15 @@ import ( "bufio" "context" "fmt" + "path" + "runtime" "slices" "strconv" "strings" "sync" "github.com/Notifiarr/notifiarr/pkg/mnd" + "github.com/jaypipes/ghw" "github.com/shirou/gopsutil/v3/disk" ) @@ -33,6 +36,10 @@ func (s *Snapshot) getDriveData(ctx context.Context, run bool, useSudo bool) (er if err := getSmartDisks(ctx, useSudo, disks); err != nil { errs = append(errs, err) } + + if err := getBlocks(disks); err != nil { + errs = append(errs, err) + } } if len(disks) == 0 { @@ -160,3 +167,27 @@ func (s *Snapshot) scanSmartctl(stdout *bufio.Scanner, name string, waitg *sync. } waitg.Done() } + +func getBlocks(disks map[string]string) error { + block, err := ghw.Block() + if err != nil { + return fmt.Errorf("unable to get block devices: %w", err) + } + + have := make(map[string]struct{}) + for _, dev := range block.Disks { + if _, ok := have[dev.BusPath]; ok { + continue + } + + have[dev.BusPath] = struct{}{} + + if runtime.GOOS != mnd.Windows { + disks[path.Join("/dev", dev.Name)] = "" + } else { + disks[dev.Name] = "" + } + } + + return nil +} diff --git a/pkg/update/unstable.go b/pkg/update/unstable.go index 38cf461e1..b2ed2d0f1 100644 --- a/pkg/update/unstable.go +++ b/pkg/update/unstable.go @@ -7,7 +7,6 @@ import ( "net/http" "runtime" "strconv" - "strings" "time" "github.com/Notifiarr/notifiarr/pkg/mnd" @@ -27,7 +26,6 @@ const unstableURL = "https://unstable.golift.io" // CheckUnstable checks if the provided app has an updated version on GitHub. // Pass in revision only, no version. func CheckUnstable(ctx context.Context, app string, revision string) (*Update, error) { - app = strings.ToLower(app) uri := fmt.Sprintf("%s/%s/%s.%s.exe.zip", unstableURL, app, app, runtime.GOARCH) if mnd.IsDarwin { From 177df2d6b563ccf35462f8320d52c7978ec03152 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 23 Jun 2024 18:59:35 -0700 Subject: [PATCH 049/192] add debug log --- pkg/snapshot/smartctl.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/snapshot/smartctl.go b/pkg/snapshot/smartctl.go index 54add1b87..7cc446279 100644 --- a/pkg/snapshot/smartctl.go +++ b/pkg/snapshot/smartctl.go @@ -4,6 +4,7 @@ import ( "bufio" "context" "fmt" + "log" "path" "runtime" "slices" @@ -30,18 +31,23 @@ func (s *Snapshot) getDriveData(ctx context.Context, run bool, useSudo bool) (er if err != nil { errs = append(errs, err) } + log.Println("DEBUG got parts", disks) if !mnd.IsDarwin { // We also do this because getParts doesn't always return (all the) disk drives. + log.Println("DEBUG getting smart disks", disks) if err := getSmartDisks(ctx, useSudo, disks); err != nil { errs = append(errs, err) } + log.Println("DEBUG getting blocks", disks) if err := getBlocks(disks); err != nil { errs = append(errs, err) } } + log.Println("DEBUG disks", disks) + if len(disks) == 0 { return append(errs, ErrNoDisks) } From 00b0ee63bd496542e718e055d25627a37e080098 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 23 Jun 2024 19:19:50 -0700 Subject: [PATCH 050/192] fix debug --- pkg/client/html_templates.go | 2 +- pkg/snapshot/smartctl.go | 12 +++++++----- pkg/snapshot/snapshot.go | 7 ++++--- pkg/triggers/snapcron/snapcron.go | 2 +- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/pkg/client/html_templates.go b/pkg/client/html_templates.go index e15dbc710..3deacbf02 100644 --- a/pkg/client/html_templates.go +++ b/pkg/client/html_templates.go @@ -705,7 +705,7 @@ func (c *Client) getDisks(ctx context.Context) map[string]*snapshot.Partition { UseSudo: c.Config.Snapshot.UseSudo, // Raid: c.Config.Snapshot.Raid, } - snapshot, _, _ := snapcnfg.GetSnapshot(ctx) + snapshot, _, _ := snapcnfg.GetSnapshot(ctx, c.Debugf) for k, v := range snapshot.DiskUsage { output[k] = v diff --git a/pkg/snapshot/smartctl.go b/pkg/snapshot/smartctl.go index 7cc446279..bb735676d 100644 --- a/pkg/snapshot/smartctl.go +++ b/pkg/snapshot/smartctl.go @@ -4,7 +4,6 @@ import ( "bufio" "context" "fmt" - "log" "path" "runtime" "slices" @@ -31,22 +30,25 @@ func (s *Snapshot) getDriveData(ctx context.Context, run bool, useSudo bool) (er if err != nil { errs = append(errs, err) } - log.Println("DEBUG got parts", disks) + + s.Debug("snapshot: got parts: %v", disks) if !mnd.IsDarwin { // We also do this because getParts doesn't always return (all the) disk drives. - log.Println("DEBUG getting smart disks", disks) + s.Debug("snapshot: getting smart disks %v", disks) + if err := getSmartDisks(ctx, useSudo, disks); err != nil { errs = append(errs, err) } - log.Println("DEBUG getting blocks", disks) + s.Debug("snapshot: getting blocks %v", disks) + if err := getBlocks(disks); err != nil { errs = append(errs, err) } } - log.Println("DEBUG disks", disks) + s.Debug("snapshot: disks %v", disks) if len(disks) == 0 { return append(errs, ErrNoDisks) diff --git a/pkg/snapshot/snapshot.go b/pkg/snapshot/snapshot.go index 5b082e162..afda73940 100644 --- a/pkg/snapshot/snapshot.go +++ b/pkg/snapshot/snapshot.go @@ -71,7 +71,8 @@ var ( // Snapshot is the output data sent to Notifiarr. type Snapshot struct { - Version string `json:"version"` + Debug func(string, ...any) `json:"-"` + Version string `json:"version"` System struct { *host.InfoStat Username string `json:"username"` @@ -143,11 +144,11 @@ func (c *Config) Validate() { } // GetSnapshot returns a system snapshot based on requested data in the config. -func (c *Config) GetSnapshot(ctx context.Context) (*Snapshot, []error, []error) { +func (c *Config) GetSnapshot(ctx context.Context, debugf func(string, ...any)) (*Snapshot, []error, []error) { ctx, cancel := context.WithTimeout(ctx, c.Timeout.Duration) defer cancel() - snap := &Snapshot{Version: version.Version + "-" + version.Revision} + snap := &Snapshot{Version: version.Version + "-" + version.Revision, Debug: debugf} errs, debug := c.getSnapshot(ctx, snap) return snap, errs, debug diff --git a/pkg/triggers/snapcron/snapcron.go b/pkg/triggers/snapcron/snapcron.go index b66199955..343bed4fb 100644 --- a/pkg/triggers/snapcron/snapcron.go +++ b/pkg/triggers/snapcron/snapcron.go @@ -94,7 +94,7 @@ func (c *cmd) printLog() { } func (c *cmd) sendSnapshot(ctx context.Context, input *common.ActionInput) { - snapshot, errs, debug := c.Snapshot.GetSnapshot(ctx) + snapshot, errs, debug := c.Snapshot.GetSnapshot(ctx, c.Debugf) for _, err := range errs { if err != nil { c.ErrorfNoShare("[%s requested] Snapshot: %v", input.Type, err) From e1e89cb64d58153a96ec005b6091ecc5b365ec64 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 23 Jun 2024 20:11:09 -0700 Subject: [PATCH 051/192] more disk debug --- pkg/snapshot/smartctl.go | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/pkg/snapshot/smartctl.go b/pkg/snapshot/smartctl.go index bb735676d..7d5c1d8f8 100644 --- a/pkg/snapshot/smartctl.go +++ b/pkg/snapshot/smartctl.go @@ -21,34 +21,35 @@ var ErrNoDisks = fmt.Errorf("no disks found") func (s *Snapshot) getDriveData(ctx context.Context, run bool, useSudo bool) (errs []error) { if !run { + s.Debug("Snapshot: skipping drive data") return nil } disks := make(map[string]string) - err := getParts(ctx, disks) + err := s.getParts(ctx, disks) if err != nil { errs = append(errs, err) } - s.Debug("snapshot: got parts: %v", disks) + s.Debug("Snapshot: got parts: %v", disks) if !mnd.IsDarwin { // We also do this because getParts doesn't always return (all the) disk drives. - s.Debug("snapshot: getting smart disks %v", disks) + s.Debug("Snapshot: getting smart disks %v", disks) - if err := getSmartDisks(ctx, useSudo, disks); err != nil { + if err := s.getSmartDisks(ctx, useSudo, disks); err != nil { errs = append(errs, err) } - s.Debug("snapshot: getting blocks %v", disks) + s.Debug("Snapshot: getting blocks %v", disks) - if err := getBlocks(disks); err != nil { + if err := s.getBlocks(disks); err != nil { errs = append(errs, err) } } - s.Debug("snapshot: disks %v", disks) + s.Debug("Snapshot: disks %v", disks) if len(disks) == 0 { return append(errs, ErrNoDisks) @@ -65,7 +66,7 @@ func (s *Snapshot) getDriveData(ctx context.Context, run bool, useSudo bool) (er return errs } -func getSmartDisks(ctx context.Context, useSudo bool, disks map[string]string) error { +func (s *Snapshot) getSmartDisks(ctx context.Context, useSudo bool, disks map[string]string) error { cmd, stdout, waitg, err := readyCommand(ctx, useSudo, "smartctl", "--scan-open") if err != nil { return err @@ -74,6 +75,8 @@ func getSmartDisks(ctx context.Context, useSudo bool, disks map[string]string) e go func() { for stdout.Scan() { fields := strings.Fields(stdout.Text()) + s.Debug("Snapshot: scan-open %v", fields) + if len(fields) < 3 || fields[0] == "#" { continue } @@ -91,7 +94,7 @@ func getSmartDisks(ctx context.Context, useSudo bool, disks map[string]string) e } // use this for everything else.... -func getParts(ctx context.Context, disks map[string]string) error { +func (s *Snapshot) getParts(ctx context.Context, disks map[string]string) error { const macDiskPrefix = "/dev/disk" partitions, err := disk.PartitionsWithContext(ctx, false) @@ -100,6 +103,8 @@ func getParts(ctx context.Context, disks map[string]string) error { } for _, part := range partitions { + s.Debug("Snapshot: partition: %v", part) + if mnd.IsDarwin { if !strings.HasPrefix(part.Device, macDiskPrefix) || slices.Contains(part.Opts, "nobrowse") { continue @@ -176,7 +181,7 @@ func (s *Snapshot) scanSmartctl(stdout *bufio.Scanner, name string, waitg *sync. waitg.Done() } -func getBlocks(disks map[string]string) error { +func (s *Snapshot) getBlocks(disks map[string]string) error { block, err := ghw.Block() if err != nil { return fmt.Errorf("unable to get block devices: %w", err) @@ -184,6 +189,8 @@ func getBlocks(disks map[string]string) error { have := make(map[string]struct{}) for _, dev := range block.Disks { + s.Debug("Snapshot: block dev: %v", dev) + if _, ok := have[dev.BusPath]; ok { continue } From 982fe1754604785a0b6471f6ab5d45dad0740bbd Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 23 Jun 2024 20:34:54 -0700 Subject: [PATCH 052/192] do not dedup devices on unknown buspath --- pkg/snapshot/smartctl.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/snapshot/smartctl.go b/pkg/snapshot/smartctl.go index 7d5c1d8f8..5e50d872b 100644 --- a/pkg/snapshot/smartctl.go +++ b/pkg/snapshot/smartctl.go @@ -191,7 +191,7 @@ func (s *Snapshot) getBlocks(disks map[string]string) error { for _, dev := range block.Disks { s.Debug("Snapshot: block dev: %v", dev) - if _, ok := have[dev.BusPath]; ok { + if _, ok := have[dev.BusPath]; ok && strings.ToLower(dev.BusPath) != "unknown" { continue } From 6906bf3217c6998ed3bb7a976b9613736c7d1f85 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 23 Jun 2024 20:44:49 -0700 Subject: [PATCH 053/192] fix hard coded wrong command for nvme on syno --- pkg/snapshot/smartctl.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/snapshot/smartctl.go b/pkg/snapshot/smartctl.go index 5e50d872b..1fa3fc9c2 100644 --- a/pkg/snapshot/smartctl.go +++ b/pkg/snapshot/smartctl.go @@ -131,7 +131,7 @@ func (s *Snapshot) getDiskData(ctx context.Context, name, dev string, useSudo bo strings.HasPrefix(name, "/dev/zram") || strings.HasPrefix(name, "/dev/synoboot") || strings.HasPrefix(name, "/dev/nbd") || strings.HasPrefix(name, "/dev/vda"): return nil - case mnd.IsSynology: + case mnd.IsSynology && !strings.EqualFold(dev, "nvme"): args = []string{"-d", "sat", "-AH", name} case dev != "" && strings.Contains(name, ","): args = []string{"-d", name, "-AH", dev} @@ -188,6 +188,7 @@ func (s *Snapshot) getBlocks(disks map[string]string) error { } have := make(map[string]struct{}) + for _, dev := range block.Disks { s.Debug("Snapshot: block dev: %v", dev) From 45a285912b80562a72e1e06ca9463cf472b1e5d8 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Tue, 25 Jun 2024 01:46:22 -0700 Subject: [PATCH 054/192] get parts only if blocks failed --- pkg/snapshot/smartctl.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/pkg/snapshot/smartctl.go b/pkg/snapshot/smartctl.go index 1fa3fc9c2..84fc5ff31 100644 --- a/pkg/snapshot/smartctl.go +++ b/pkg/snapshot/smartctl.go @@ -21,18 +21,20 @@ var ErrNoDisks = fmt.Errorf("no disks found") func (s *Snapshot) getDriveData(ctx context.Context, run bool, useSudo bool) (errs []error) { if !run { - s.Debug("Snapshot: skipping drive data") return nil } disks := make(map[string]string) - err := s.getParts(ctx, disks) - if err != nil { + if err := s.getBlocks(disks); err != nil { errs = append(errs, err) - } - s.Debug("Snapshot: got parts: %v", disks) + s.Debug("Snapshot: getting parts: %v", disks) + + if err := s.getParts(ctx, disks); err != nil { + errs = append(errs, err) + } + } if !mnd.IsDarwin { // We also do this because getParts doesn't always return (all the) disk drives. @@ -41,12 +43,6 @@ func (s *Snapshot) getDriveData(ctx context.Context, run bool, useSudo bool) (er if err := s.getSmartDisks(ctx, useSudo, disks); err != nil { errs = append(errs, err) } - - s.Debug("Snapshot: getting blocks %v", disks) - - if err := s.getBlocks(disks); err != nil { - errs = append(errs, err) - } } s.Debug("Snapshot: disks %v", disks) From b888504ae9cf41a708c3b5701c83eaa57c58e79b Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Thu, 27 Jun 2024 11:16:02 -0700 Subject: [PATCH 055/192] add syno unstable script --- userscripts/install-synology.sh | 3 ++- userscripts/unstable-syno.sh | 48 +++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 userscripts/unstable-syno.sh diff --git a/userscripts/install-synology.sh b/userscripts/install-synology.sh index c89129df9..6cb3ad079 100644 --- a/userscripts/install-synology.sh +++ b/userscripts/install-synology.sh @@ -1,6 +1,7 @@ #!/bin/bash # -# This is a quick and dirty script to install the latest notifiarr on Synology. +# Use this script to install Notifiarr client on your Synology NAS. +# Can also be used to keep the application up to date, see crontab instructions below. # # Use it like this, pick curl or wget: (sudo is not optional for Synology) # ---- diff --git a/userscripts/unstable-syno.sh b/userscripts/unstable-syno.sh new file mode 100644 index 000000000..638c5efa4 --- /dev/null +++ b/userscripts/unstable-syno.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +#################################################################################################### +# Use this script to keep your Synology up to date with unstable releases. # +# Please only use this script if you're an active Notifiarr tester or on the support team. # +# Regular users (non-testers) should use the install-synology.sh script also found in this folder. # +#################################################################################################### + +set -e + +# This is where the log file goes, and where temporary downloads are stored. +# It must exist, and be writable by the user running this script. +WORKDIR="/tmp" +# Unstable website URL. This redirects to glift.io/notifiarr/. +UNSTABLE="https://unstable.notifiarr.app/" +# File to download/check for updates. Do not include the .gz or .txt suffixes. +FILE="notifiarr.amd64.linux" +# Location for script output. +LOG_FILE="${WORKDIR}/update-log-notifiarr.txt" + +#################################################################################################### + +LATEST="notifiarr $(wget -qO- ${UNSTABLE}${FILE}.gz.txt | jq -r '"\(.version)-\(.revision)"')" +INSTALLED=$(/usr/bin/notifiarr -v) +TIMESTAMP() { date "+%Y-%m-%d %H:%M:%S" ;} + +echo "`TIMESTAMP` latest: ${LATEST}, installed: ${INSTALLED}" >> "${LOG_FILE}" + +# Check if current equals unstable. +if [ "$LATEST" = "$INSTALLED" ]; then + echo "`TIMESTAMP` Current, exiting. ${LATEST} == ${INSTALLED}" >> "${LOG_FILE}" + exit 0 +fi + +echo "`TIMESTAMP` Updating to ${LATEST} from ${INSTALLED}" >> "${LOG_FILE}" + +# Download current unstable binary. +wget -qO "${WORKDIR}/${FILE}.gz" ${UNSTABLE}${FILE}.gz >> "${LOG_FILE}" 2>&1 + +# Decompress and make executable. +gunzip -f "${WORKDIR}/${FILE}.gz" >> "${LOG_FILE}" 2>&1 +chmod 0755 "${WORKDIR}/${FILE}" >> "${LOG_FILE}" 2>&1 + +# Stop app, move binary into place, start app. +# sudo is only needed if this is not running as root. +sudo systemctl stop notifiarr >> "${LOG_FILE}" 2>&1 +sudo mv -f "${WORKDIR}/${FILE}" /usr/bin/notifiarr >> "${LOG_FILE}" 2>&1 +sudo systemctl start notifiarr >> "${LOG_FILE}" 2>&1 \ No newline at end of file From 74906fefa4a4e085575be4cad8f5577e4d5616ad Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Thu, 27 Jun 2024 11:18:53 -0700 Subject: [PATCH 056/192] fix example path --- userscripts/unstable-syno.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/userscripts/unstable-syno.sh b/userscripts/unstable-syno.sh index 638c5efa4..97943359d 100644 --- a/userscripts/unstable-syno.sh +++ b/userscripts/unstable-syno.sh @@ -10,7 +10,7 @@ set -e # This is where the log file goes, and where temporary downloads are stored. # It must exist, and be writable by the user running this script. -WORKDIR="/tmp" +WORKDIR="/volume1/homes/notifiarr/" # Unstable website URL. This redirects to glift.io/notifiarr/. UNSTABLE="https://unstable.notifiarr.app/" # File to download/check for updates. Do not include the .gz or .txt suffixes. From d10dba45495e068dd6f511637270665420c7d413 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Thu, 27 Jun 2024 11:19:41 -0700 Subject: [PATCH 057/192] move slash --- userscripts/unstable-syno.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/userscripts/unstable-syno.sh b/userscripts/unstable-syno.sh index 97943359d..3b80bd0bc 100644 --- a/userscripts/unstable-syno.sh +++ b/userscripts/unstable-syno.sh @@ -12,7 +12,7 @@ set -e # It must exist, and be writable by the user running this script. WORKDIR="/volume1/homes/notifiarr/" # Unstable website URL. This redirects to glift.io/notifiarr/. -UNSTABLE="https://unstable.notifiarr.app/" +UNSTABLE="https://unstable.notifiarr.app" # File to download/check for updates. Do not include the .gz or .txt suffixes. FILE="notifiarr.amd64.linux" # Location for script output. @@ -20,7 +20,7 @@ LOG_FILE="${WORKDIR}/update-log-notifiarr.txt" #################################################################################################### -LATEST="notifiarr $(wget -qO- ${UNSTABLE}${FILE}.gz.txt | jq -r '"\(.version)-\(.revision)"')" +LATEST="notifiarr $(wget -qO- ${UNSTABLE}/${FILE}.gz.txt | jq -r '"\(.version)-\(.revision)"')" INSTALLED=$(/usr/bin/notifiarr -v) TIMESTAMP() { date "+%Y-%m-%d %H:%M:%S" ;} @@ -35,7 +35,7 @@ fi echo "`TIMESTAMP` Updating to ${LATEST} from ${INSTALLED}" >> "${LOG_FILE}" # Download current unstable binary. -wget -qO "${WORKDIR}/${FILE}.gz" ${UNSTABLE}${FILE}.gz >> "${LOG_FILE}" 2>&1 +wget -qO "${WORKDIR}/${FILE}.gz" ${UNSTABLE}/${FILE}.gz >> "${LOG_FILE}" 2>&1 # Decompress and make executable. gunzip -f "${WORKDIR}/${FILE}.gz" >> "${LOG_FILE}" 2>&1 From e5a1007ec8a65708dba597a0389f6dbe73260d8e Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Thu, 27 Jun 2024 11:33:30 -0700 Subject: [PATCH 058/192] newline at end --- userscripts/unstable-syno.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/userscripts/unstable-syno.sh b/userscripts/unstable-syno.sh index 3b80bd0bc..3abb2abd5 100644 --- a/userscripts/unstable-syno.sh +++ b/userscripts/unstable-syno.sh @@ -45,4 +45,4 @@ chmod 0755 "${WORKDIR}/${FILE}" >> "${LOG_FILE}" 2>&1 # sudo is only needed if this is not running as root. sudo systemctl stop notifiarr >> "${LOG_FILE}" 2>&1 sudo mv -f "${WORKDIR}/${FILE}" /usr/bin/notifiarr >> "${LOG_FILE}" 2>&1 -sudo systemctl start notifiarr >> "${LOG_FILE}" 2>&1 \ No newline at end of file +sudo systemctl start notifiarr >> "${LOG_FILE}" 2>&1 From e98ee270afeadb8fc2d626b4245db37cc1b26be3 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Thu, 27 Jun 2024 11:34:24 -0700 Subject: [PATCH 059/192] fix typo --- userscripts/unstable-syno.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/userscripts/unstable-syno.sh b/userscripts/unstable-syno.sh index 3abb2abd5..67dbf8db5 100644 --- a/userscripts/unstable-syno.sh +++ b/userscripts/unstable-syno.sh @@ -11,7 +11,7 @@ set -e # This is where the log file goes, and where temporary downloads are stored. # It must exist, and be writable by the user running this script. WORKDIR="/volume1/homes/notifiarr/" -# Unstable website URL. This redirects to glift.io/notifiarr/. +# Unstable website URL. This redirects to golift.io/notifiarr/. UNSTABLE="https://unstable.notifiarr.app" # File to download/check for updates. Do not include the .gz or .txt suffixes. FILE="notifiarr.amd64.linux" From 4bbe8a0e0f73401c60513cfc70c4f820d5c5432e Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Thu, 27 Jun 2024 11:45:30 -0700 Subject: [PATCH 060/192] another slash --- userscripts/unstable-syno.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/userscripts/unstable-syno.sh b/userscripts/unstable-syno.sh index 67dbf8db5..1a2c52782 100644 --- a/userscripts/unstable-syno.sh +++ b/userscripts/unstable-syno.sh @@ -10,7 +10,7 @@ set -e # This is where the log file goes, and where temporary downloads are stored. # It must exist, and be writable by the user running this script. -WORKDIR="/volume1/homes/notifiarr/" +WORKDIR="/volume1/homes/notifiarr" # Unstable website URL. This redirects to golift.io/notifiarr/. UNSTABLE="https://unstable.notifiarr.app" # File to download/check for updates. Do not include the .gz or .txt suffixes. From 09a990fae05e2e774a9fe093a514e5eb8b37b39a Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Thu, 27 Jun 2024 12:59:41 -0700 Subject: [PATCH 061/192] update logs --- pkg/snapshot/smartctl.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/snapshot/smartctl.go b/pkg/snapshot/smartctl.go index 84fc5ff31..342c5954a 100644 --- a/pkg/snapshot/smartctl.go +++ b/pkg/snapshot/smartctl.go @@ -29,7 +29,7 @@ func (s *Snapshot) getDriveData(ctx context.Context, run bool, useSudo bool) (er if err := s.getBlocks(disks); err != nil { errs = append(errs, err) - s.Debug("Snapshot: getting parts: %v", disks) + s.Debug("Snapshot: got blocks, %v", disks) if err := s.getParts(ctx, disks); err != nil { errs = append(errs, err) @@ -38,14 +38,14 @@ func (s *Snapshot) getDriveData(ctx context.Context, run bool, useSudo bool) (er if !mnd.IsDarwin { // We also do this because getParts doesn't always return (all the) disk drives. - s.Debug("Snapshot: getting smart disks %v", disks) + s.Debug("Snapshot: getting smart disks, %v", disks) if err := s.getSmartDisks(ctx, useSudo, disks); err != nil { errs = append(errs, err) } } - s.Debug("Snapshot: disks %v", disks) + s.Debug("Snapshot: got disks: %v", disks) if len(disks) == 0 { return append(errs, ErrNoDisks) @@ -63,7 +63,7 @@ func (s *Snapshot) getDriveData(ctx context.Context, run bool, useSudo bool) (er } func (s *Snapshot) getSmartDisks(ctx context.Context, useSudo bool, disks map[string]string) error { - cmd, stdout, waitg, err := readyCommand(ctx, useSudo, "smartctl", "--scan-open") + cmd, stdout, waitg, err := readyCommand(ctx, useSudo, "smartctl", "--scan") if err != nil { return err } @@ -71,7 +71,7 @@ func (s *Snapshot) getSmartDisks(ctx context.Context, useSudo bool, disks map[st go func() { for stdout.Scan() { fields := strings.Fields(stdout.Text()) - s.Debug("Snapshot: scan-open %v", fields) + s.Debug("Snapshot: smartctl scan %v", fields) if len(fields) < 3 || fields[0] == "#" { continue From 43624d254c6294e988623502adf49ecbbae99f51 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Fri, 28 Jun 2024 10:57:03 -0700 Subject: [PATCH 062/192] dedup disks, put back --scan-open --- pkg/snapshot/smartctl.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/pkg/snapshot/smartctl.go b/pkg/snapshot/smartctl.go index 342c5954a..618581625 100644 --- a/pkg/snapshot/smartctl.go +++ b/pkg/snapshot/smartctl.go @@ -55,15 +55,29 @@ func (s *Snapshot) getDriveData(ctx context.Context, run bool, useSudo bool) (er s.DriveTemps = make(map[string]int) s.DiskHealth = make(map[string]string) - for name, dev := range disks { + for name, dev := range s.dedupDisks(disks) { errs = append(errs, s.getDiskData(ctx, name, dev, useSudo)) } return errs } +// dedupDisks was written to turn nvme0, nvme0n1s0, nvme0n1s1 into just nvme0. +func (s *Snapshot) dedupDisks(disks map[string]string) map[string]string { + for name, dev1 := range disks { + for name2, dev2 := range disks { + if dev1 != dev2 && strings.HasPrefix(name, name2) { + delete(disks, name) + break + } + } + } + + return disks +} + func (s *Snapshot) getSmartDisks(ctx context.Context, useSudo bool, disks map[string]string) error { - cmd, stdout, waitg, err := readyCommand(ctx, useSudo, "smartctl", "--scan") + cmd, stdout, waitg, err := readyCommand(ctx, useSudo, "smartctl", "--scan-open") if err != nil { return err } @@ -77,6 +91,9 @@ func (s *Snapshot) getSmartDisks(ctx context.Context, useSudo bool, disks map[st continue } + // The fields for dev and name get swapped in a specific case where the name has a comma. + // That's because the number after the comma designates the drive, but all the drives + // are connected to the same device bus. This happens with raid cards. if strings.Contains(fields[2], ",") { disks[fields[2]] = fields[0] } else { From 15a76ee07b21ecb9155e31a1c4ddd24a1c93f72e Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Fri, 28 Jun 2024 11:43:44 -0700 Subject: [PATCH 063/192] fix auto updater again --- pkg/update/unstable.go | 1 + pkg/update/update.go | 25 +++++++++++++------------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/pkg/update/unstable.go b/pkg/update/unstable.go index b2ed2d0f1..4316c986c 100644 --- a/pkg/update/unstable.go +++ b/pkg/update/unstable.go @@ -57,6 +57,7 @@ func GetUnstable(ctx context.Context, uri string) (*UnstableFile, error) { defer cancel() // we use stamp to bust the cloudflare cache. + // If you remove or rename `stamp` then also update decompressFile(). stamp := "?stamp=" + time.Now().UTC().Format("2006-01-02-15") release := UnstableFile{File: uri + stamp} uri += ".txt" + stamp diff --git a/pkg/update/update.go b/pkg/update/update.go index 3aa4a2552..5fb0601c4 100644 --- a/pkg/update/update.go +++ b/pkg/update/update.go @@ -39,13 +39,14 @@ type Command struct { // Restart is meant to be called from a special flag that reloads the app after an upgrade. func Restart(u *Command) error { - fmt.Printf("Sleeping %v before restarting.", SleepTime) //nolint:forbidigo + // We sleep for a few seconds so the original app has time to exit. time.Sleep(SleepTime) if err := exec.Command(u.Path, u.Args...).Start(); err != nil { //nolint:gosec return fmt.Errorf("executing command %w", err) } + // A small pause to give the new app time to fork. time.Sleep(time.Second) return nil @@ -63,7 +64,7 @@ var ( // Triggers another invocation of the app that sleeps 5 seconds then restarts. // The running app must exit after this returns! // The restart command can trigger the above Restart() procedure. -// And that prcoedure relaunches the app; this allows "in-place" upgrades. +// And that procedure relaunches the app; this allows "in-place" upgrades. // This also makes sure the new file works before this app exits. // This is not required though, and you can totally upgrade "a different app". func Now(ctx context.Context, u *Command) (string, error) { @@ -88,10 +89,10 @@ func NowWithContext(ctx context.Context, update *Command) (string, error) { return backupFile, err } - update.Printf("[Update] Triggering Restart: %s %s", update.Path, strings.Join(update.Args, " ")) + update.Printf("[UPDATE] Triggering Restart: %s %s", update.Path, strings.Join(update.Args, " ")) if err := exec.Command(update.Path, update.Args...).Start(); err != nil { //nolint:gosec - return backupFile, fmt.Errorf("executing restart command %w", err) + return backupFile, fmt.Errorf("executing restart command: %w", err) } return backupFile, nil @@ -119,19 +120,19 @@ func (u *Command) replaceFile(ctx context.Context) (string, error) { backupFile := strings.TrimSuffix(u.Path, ".exe") backupFile += ".backup." + time.Now().Format("060102T150405") + suff - u.Printf("[Update] Renaming %s => %s", u.Path, backupFile) + u.Printf("[UPDATE] Renaming %s => %s", u.Path, backupFile) if err := os.Rename(u.Path, backupFile); err != nil { return backupFile, fmt.Errorf("renaming original file: %w", err) } - u.Printf("[Update] Renaming %s => %s", tempFile, u.Path) + u.Printf("[UPDATE] Renaming %s => %s", tempFile, u.Path) if err := os.Rename(tempFile, u.Path); err != nil { return backupFile, fmt.Errorf("renaming downloaded file: %w", err) } /* // Hack used for testing. - u.Printf("[Update] Renaming [HACK] %s => %s", backupFile, u.Path) + u.Printf("[UPDATE] Renaming [HACK] %s => %s", backupFile, u.Path) if err := os.Rename(backupFile, u.Path); err != nil { return backupFile, fmt.Errorf("renaming downloaded file %w", err) @@ -147,7 +148,7 @@ func (u *Command) writeFile(ctx context.Context, folderPath string) (string, err } defer tempFile.Close() - u.Printf("[Update] Primed Temp File: %s", tempFile.Name()) + u.Printf("[UPDATE] Primed Temp File: %s", tempFile.Name()) req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.URL, nil) if err != nil { @@ -165,17 +166,17 @@ func (u *Command) writeFile(ctx context.Context, folderPath string) (string, err func (u *Command) decompressFile(tempFile *os.File, resp io.Reader, size int64) error { switch { - case strings.HasSuffix(u.URL, ".zip"): + case strings.Contains(u.URL, ".zip?stamp"): if body, err := io.ReadAll(resp); err != nil { return fmt.Errorf("reading file from URL: %w", err) } else if err := u.writeZipFile(tempFile, body, size); err != nil { return err } - case strings.HasSuffix(u.URL, ".gz"): + case strings.Contains(u.URL, ".gz?stamp"): if err := u.writeGZipFile(tempFile, resp); err != nil { return err } - case strings.HasSuffix(u.URL, ".bz2"): + case strings.Contains(u.URL, ".bz2?stamp"): if _, err := io.Copy(tempFile, bzip2.NewReader(resp)); err != nil { return fmt.Errorf("bzunzipping temporary file: %w", err) } @@ -230,7 +231,7 @@ func (u *Command) writeZipFile(tempFile *os.File, body []byte, size int64) error } } - u.Println("[Update] exe file not found in zip file") + u.Println("[UPDATE] exe file not found in zip file") return nil } From b2c4d239709cbbff6a2c0d3885c432819f5a709c Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Fri, 28 Jun 2024 12:15:40 -0700 Subject: [PATCH 064/192] html escape service checks --- pkg/services/checks.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/pkg/services/checks.go b/pkg/services/checks.go index dfcb70848..fde81c969 100644 --- a/pkg/services/checks.go +++ b/pkg/services/checks.go @@ -4,6 +4,7 @@ import ( "context" "crypto/tls" "fmt" + "html" "io" "net" "net/http" @@ -19,6 +20,7 @@ import ( const ( sslstring = "SSL" // used for checking HTTPS certs expectdelim = "," // extra (split) delimiter + maxOutput = 170 // maximum length of output. ) type result struct { @@ -149,8 +151,6 @@ func (s *Service) update(res *result) bool { return true } -const maxBody = 150 - // checkHTTPReq builds the client and request for the http service check. func (s *Service) checkHTTPReq(ctx context.Context) (*http.Client, *http.Request, error) { // Allow adding headers by appending them after a pipe symbol. @@ -222,13 +222,20 @@ func (s *Service) checkHTTP(ctx context.Context) *result { } } - bodyStr := string(body) - if len(bodyStr) > maxBody { - bodyStr = bodyStr[:maxBody] + // Reduce the size of the string before processing it to speed things up on large body outputs. + if len(res.output) > maxOutput+maxOutput { + res.output = res.output[:maxOutput+maxOutput] } res.state = StateCritical - res.output = resp.Status + ": " + strings.TrimSpace(RemoveSecrets(s.Value, bodyStr)) + res.output = resp.Status + ": " + strings.TrimSpace( + html.EscapeString(strings.Join(strings.Fields(RemoveSecrets(s.Value, string(body))), " "))) + + // Reduce the string to the final max length. + // We do it this way so all secrets are properly escaped before string splitting. + if len(res.output) > maxOutput { + res.output = res.output[:maxOutput] + } return res } From 3120a55611f07bb10a74984c0dca7abbae5fda6e Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sat, 29 Jun 2024 17:26:26 -0700 Subject: [PATCH 065/192] update deps --- .github/workflows/ghcr.yml | 2 +- go.mod | 6 ++--- go.sum | 16 ++++++------- pkg/client/handlers_gui.go | 2 +- pkg/client/html_templates.go | 2 +- pkg/configfile/config.go | 2 +- pkg/services/check_proc.go | 2 +- pkg/snapshot/diskio.go | 2 +- pkg/snapshot/diskusage.go | 2 +- pkg/snapshot/smartctl.go | 2 +- pkg/snapshot/snapshot.go | 8 +++---- pkg/snapshot/synology.go | 2 +- pkg/snapshot/system.go | 10 ++++---- pkg/snapshot/temperatures.go | 40 +++++++++++++------------------ pkg/snapshot/users_others.go | 2 +- pkg/website/clientinfo/appinfo.go | 2 +- pkg/website/hostinfo.go | 2 +- pkg/website/server.go | 2 +- 18 files changed, 49 insertions(+), 57 deletions(-) diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml index 5f814a142..49814ef33 100644 --- a/.github/workflows/ghcr.yml +++ b/.github/workflows/ghcr.yml @@ -72,7 +72,7 @@ jobs: # Build and push Docker image with Buildx # https://github.com/docker/build-push-action - name: Build and push ${{ matrix.docker.name }} Docker image - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: platforms: |- linux/amd64 diff --git a/go.mod b/go.mod index 8202655a7..2b7f9bc9b 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/go-ping/ping v1.1.0 github.com/go-sql-driver/mysql v1.8.1 github.com/gorilla/mux v1.8.1 - github.com/gorilla/schema v1.4.0 + github.com/gorilla/schema v1.4.1 github.com/gorilla/securecookie v1.1.2 github.com/gorilla/websocket v1.5.3 github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b @@ -29,7 +29,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 github.com/mrobinsn/go-rtorrent v1.8.0 github.com/nxadm/tail v1.4.11 - github.com/shirou/gopsutil/v3 v3.24.5 + github.com/shirou/gopsutil/v4 v4.24.5 github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace github.com/stretchr/testify v1.9.0 github.com/swaggo/swag v1.16.3 @@ -112,7 +112,7 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect howett.net/plist v1.0.1 // indirect modernc.org/gc/v3 v3.0.0-20240304020402-f0dba7c97c2b // indirect - modernc.org/libc v1.53.3 // indirect + modernc.org/libc v1.53.4 // indirect modernc.org/mathutil v1.6.0 // indirect modernc.org/memory v1.8.0 // indirect modernc.org/strutil v1.2.0 // indirect diff --git a/go.sum b/go.sum index 6b4cf0ec5..228d6f798 100644 --- a/go.sum +++ b/go.sum @@ -130,8 +130,8 @@ github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/gorilla/rpc v1.2.1 h1:yC+LMV5esttgpVvNORL/xX4jvTTEUE30UZhZ5JF7K9k= github.com/gorilla/rpc v1.2.1/go.mod h1:uNpOihAlF5xRFLuTYhfR0yfCTm0WTQSQttkMSptRfGk= -github.com/gorilla/schema v1.4.0 h1:l2N+lRTJtev9SUhBtj6NmSxd/6+8LhvN0kV+H2Y8R9k= -github.com/gorilla/schema v1.4.0/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM= +github.com/gorilla/schema v1.4.1 h1:jUg5hUjCSDZpNGLuXQOgIWGdlgrIdYvgQ0wZtdK1M3E= +github.com/gorilla/schema v1.4.1/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM= github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA= github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo= github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= @@ -228,8 +228,8 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk= -github.com/shirou/gopsutil/v3 v3.24.5 h1:i0t8kL+kQTvpAYToeuiVk3TgDeKOFioZO3Ztz/iZ9pI= -github.com/shirou/gopsutil/v3 v3.24.5/go.mod h1:bsoOS1aStSs9ErQ1WWfxllSeS1K5D+U30r2NfcubMVk= +github.com/shirou/gopsutil/v4 v4.24.5 h1:gGsArG5K6vmsh5hcFOHaPm87UD003CaDMkAOweSQjhM= +github.com/shirou/gopsutil/v4 v4.24.5/go.mod h1:aoebb2vxetJ/yIDZISmduFvVNPHqXQ9SEJwRXxkf0RA= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= @@ -502,16 +502,16 @@ howett.net/plist v1.0.1 h1:37GdZ8tP09Q35o9ych3ehygcsL+HqKSwzctveSlarvM= howett.net/plist v1.0.1/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g= modernc.org/cc/v4 v4.21.3 h1:2mhBdWKtivdFlLR1ecKXTljPG1mfvbByX7QKztAIJl8= modernc.org/cc/v4 v4.21.3/go.mod h1:HM7VJTZbUCR3rV8EYBi9wxnJ0ZBRiGE5OeGXNA0IsLQ= -modernc.org/ccgo/v4 v4.18.1 h1:1zF5kPBFq/ZVTulBOKgQPQITdOzzyBUfC51gVYP62E4= -modernc.org/ccgo/v4 v4.18.1/go.mod h1:ao1fAxf9a2KEOL15WY8+yP3wnpaOpP/QuyFOZ9HJolM= +modernc.org/ccgo/v4 v4.18.2 h1:PUQPShG4HwghpOekNujL0sFavdkRvmxzTbI4rGJ5mg0= +modernc.org/ccgo/v4 v4.18.2/go.mod h1:ao1fAxf9a2KEOL15WY8+yP3wnpaOpP/QuyFOZ9HJolM= modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE= modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ= modernc.org/gc/v2 v2.4.1 h1:9cNzOqPyMJBvrUipmynX0ZohMhcxPtMccYgGOJdOiBw= modernc.org/gc/v2 v2.4.1/go.mod h1:wzN5dK1AzVGoH6XOzc3YZ+ey/jPgYHLuVckd62P0GYU= modernc.org/gc/v3 v3.0.0-20240304020402-f0dba7c97c2b h1:BnN1t+pb1cy61zbvSUV7SeI0PwosMhlAEi/vBY4qxp8= modernc.org/gc/v3 v3.0.0-20240304020402-f0dba7c97c2b/go.mod h1:Qz0X07sNOR1jWYCrJMEnbW/X55x206Q7Vt4mz6/wHp4= -modernc.org/libc v1.53.3 h1:9O0aSLZuHPgp49we24NoFFteRgXNLGBAQ3TODrW3XLg= -modernc.org/libc v1.53.3/go.mod h1:kb+Erju4FfHNE59xd2fNpv5CBeAeej6fHbx8p8xaiyI= +modernc.org/libc v1.53.4 h1:YAgFS7tGIFBfqje2UOqiXtIwuDUCF8AUonYw0seup34= +modernc.org/libc v1.53.4/go.mod h1:aGsLofnkcct8lTJnKQnCqJO37ERAXSHamSuWLFoF2Cw= modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E= diff --git a/pkg/client/handlers_gui.go b/pkg/client/handlers_gui.go index 6eb814099..5ef7c63d1 100644 --- a/pkg/client/handlers_gui.go +++ b/pkg/client/handlers_gui.go @@ -30,7 +30,7 @@ import ( "github.com/Notifiarr/notifiarr/pkg/website" "github.com/gorilla/mux" "github.com/gorilla/schema" - "github.com/shirou/gopsutil/v3/disk" + "github.com/shirou/gopsutil/v4/disk" "github.com/swaggo/swag" "golift.io/version" ) diff --git a/pkg/client/html_templates.go b/pkg/client/html_templates.go index 3deacbf02..9ad8996d3 100644 --- a/pkg/client/html_templates.go +++ b/pkg/client/html_templates.go @@ -29,7 +29,7 @@ import ( "github.com/hako/durafmt" "github.com/jackpal/gateway" "github.com/mitchellh/go-homedir" - "github.com/shirou/gopsutil/v3/host" + "github.com/shirou/gopsutil/v4/host" "golang.org/x/text/cases" "golang.org/x/text/language" "golift.io/cnfg" diff --git a/pkg/configfile/config.go b/pkg/configfile/config.go index 55d5cd567..02f3f7655 100644 --- a/pkg/configfile/config.go +++ b/pkg/configfile/config.go @@ -31,7 +31,7 @@ import ( "github.com/Notifiarr/notifiarr/pkg/website/clientinfo" "github.com/dsnet/compress/bzip2" homedir "github.com/mitchellh/go-homedir" - "github.com/shirou/gopsutil/v3/host" + "github.com/shirou/gopsutil/v4/host" "golift.io/cnfg" "golift.io/cnfgfile" ) diff --git a/pkg/services/check_proc.go b/pkg/services/check_proc.go index 604e9e413..409df9e0b 100644 --- a/pkg/services/check_proc.go +++ b/pkg/services/check_proc.go @@ -10,7 +10,7 @@ import ( "github.com/Notifiarr/notifiarr/pkg/mnd" "github.com/hako/durafmt" - "github.com/shirou/gopsutil/v3/process" + "github.com/shirou/gopsutil/v4/process" ) // ProcInfo is derived from a pid. diff --git a/pkg/snapshot/diskio.go b/pkg/snapshot/diskio.go index 2e98ac99f..4863186a2 100644 --- a/pkg/snapshot/diskio.go +++ b/pkg/snapshot/diskio.go @@ -15,7 +15,7 @@ import ( "sync" "github.com/Notifiarr/notifiarr/pkg/mnd" - "github.com/shirou/gopsutil/v3/disk" + "github.com/shirou/gopsutil/v4/disk" ) /* This files has procedures to structure data from iotop and iostat. */ diff --git a/pkg/snapshot/diskusage.go b/pkg/snapshot/diskusage.go index d13394e75..0c3dae8d8 100644 --- a/pkg/snapshot/diskusage.go +++ b/pkg/snapshot/diskusage.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/Notifiarr/notifiarr/pkg/mnd" - "github.com/shirou/gopsutil/v3/disk" + "github.com/shirou/gopsutil/v4/disk" ) func (s *Snapshot) getDisksUsage(ctx context.Context, run bool, allDrives bool) []error { //nolint:cyclop diff --git a/pkg/snapshot/smartctl.go b/pkg/snapshot/smartctl.go index 618581625..267850e3e 100644 --- a/pkg/snapshot/smartctl.go +++ b/pkg/snapshot/smartctl.go @@ -13,7 +13,7 @@ import ( "github.com/Notifiarr/notifiarr/pkg/mnd" "github.com/jaypipes/ghw" - "github.com/shirou/gopsutil/v3/disk" + "github.com/shirou/gopsutil/v4/disk" ) // ErrNoDisks is returned when no disks are found. diff --git a/pkg/snapshot/snapshot.go b/pkg/snapshot/snapshot.go index afda73940..2f66af37f 100644 --- a/pkg/snapshot/snapshot.go +++ b/pkg/snapshot/snapshot.go @@ -16,10 +16,10 @@ import ( "time" "github.com/Notifiarr/notifiarr/pkg/mnd" - "github.com/shirou/gopsutil/v3/cpu" - "github.com/shirou/gopsutil/v3/disk" - "github.com/shirou/gopsutil/v3/host" - "github.com/shirou/gopsutil/v3/load" + "github.com/shirou/gopsutil/v4/cpu" + "github.com/shirou/gopsutil/v4/disk" + "github.com/shirou/gopsutil/v4/host" + "github.com/shirou/gopsutil/v4/load" "golift.io/cnfg" "golift.io/version" ) diff --git a/pkg/snapshot/synology.go b/pkg/snapshot/synology.go index 15573008c..2bc114709 100644 --- a/pkg/snapshot/synology.go +++ b/pkg/snapshot/synology.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/Notifiarr/notifiarr/pkg/mnd" - "github.com/shirou/gopsutil/v3/host" + "github.com/shirou/gopsutil/v4/host" ) var ErrNotSynology = fmt.Errorf("the running host is not a Synology") diff --git a/pkg/snapshot/system.go b/pkg/snapshot/system.go index 2cb1aa6b7..5934459c8 100644 --- a/pkg/snapshot/system.go +++ b/pkg/snapshot/system.go @@ -10,11 +10,11 @@ import ( "strconv" "time" - "github.com/shirou/gopsutil/v3/cpu" - "github.com/shirou/gopsutil/v3/host" - "github.com/shirou/gopsutil/v3/load" - "github.com/shirou/gopsutil/v3/mem" - "github.com/shirou/gopsutil/v3/process" + "github.com/shirou/gopsutil/v4/cpu" + "github.com/shirou/gopsutil/v4/host" + "github.com/shirou/gopsutil/v4/load" + "github.com/shirou/gopsutil/v4/mem" + "github.com/shirou/gopsutil/v4/process" ) // Processes allows us to sort a process list. diff --git a/pkg/snapshot/temperatures.go b/pkg/snapshot/temperatures.go index 5b1a81e6f..c3c864214 100644 --- a/pkg/snapshot/temperatures.go +++ b/pkg/snapshot/temperatures.go @@ -2,15 +2,17 @@ package snapshot import ( "context" + "errors" "fmt" + "strings" - "github.com/shirou/gopsutil/v3/host" + "github.com/shirou/gopsutil/v4/sensors" ) func (s *Snapshot) getSystemTemps(ctx context.Context) error { s.System.Temps = make(map[string]float64) - temps, err := host.SensorsTemperaturesWithContext(ctx) + temps, err := sensors.TemperaturesWithContext(ctx) for _, t := range temps { if t.Temperature > 0 { @@ -18,30 +20,20 @@ func (s *Snapshot) getSystemTemps(ctx context.Context) error { } } - /* - https://github.com/shirou/gopsutil/issues/1377 - ^^ see this for why this code is now commented out. - - if err == nil { - return nil - } - - var warns *host.Warnings - if !errors.As(err, &warns) { - return fmt.Errorf("unable to get sensor temperatures: %w", err) - } - - errs := make([]string, len(warns.List)) - for i, w := range warns.List { - errs[i] = fmt.Sprintf("warning %v: %v", i+1, w) - } + if err == nil { + return nil + } - return fmt.Errorf("getting sensor temperatures: %w: %s", err, strings.Join(errs, ", ")) - */ + var warns *sensors.Warnings + if !errors.As(err, &warns) { + return fmt.Errorf("unable to get sensor temperatures: %w", err) + } - if err != nil { - return fmt.Errorf("warning getting sensor temperatures: %w", err) + errs := make([]string, len(warns.List)) + for i, w := range warns.List { + errs[i] = fmt.Sprintf("warning %v: %v", i+1, w) } - return nil + return fmt.Errorf("getting sensor temperatures: %w: %s", err, strings.Join(errs, ", ")) + } diff --git a/pkg/snapshot/users_others.go b/pkg/snapshot/users_others.go index ee38473b3..81b3f26c4 100644 --- a/pkg/snapshot/users_others.go +++ b/pkg/snapshot/users_others.go @@ -6,7 +6,7 @@ import ( "context" "fmt" - "github.com/shirou/gopsutil/v3/host" + "github.com/shirou/gopsutil/v4/host" ) // GetUsers collects logged in users. diff --git a/pkg/website/clientinfo/appinfo.go b/pkg/website/clientinfo/appinfo.go index 1dc710e08..e9f84bb48 100644 --- a/pkg/website/clientinfo/appinfo.go +++ b/pkg/website/clientinfo/appinfo.go @@ -15,7 +15,7 @@ import ( "github.com/Notifiarr/notifiarr/pkg/triggers/data" "github.com/Notifiarr/notifiarr/pkg/ui" "github.com/Notifiarr/notifiarr/pkg/website" - "github.com/shirou/gopsutil/v3/host" + "github.com/shirou/gopsutil/v4/host" "golift.io/version" ) diff --git a/pkg/website/hostinfo.go b/pkg/website/hostinfo.go index cf587ca3d..b645c9801 100644 --- a/pkg/website/hostinfo.go +++ b/pkg/website/hostinfo.go @@ -8,7 +8,7 @@ import ( "github.com/Notifiarr/notifiarr/pkg/mnd" "github.com/Notifiarr/notifiarr/pkg/snapshot" - "github.com/shirou/gopsutil/v3/host" + "github.com/shirou/gopsutil/v4/host" ) // hostInfoNoError will return nil if there is an error, otherwise a copy of the host info. diff --git a/pkg/website/server.go b/pkg/website/server.go index 2a54cbaf9..35f57c1c5 100644 --- a/pkg/website/server.go +++ b/pkg/website/server.go @@ -10,7 +10,7 @@ import ( "github.com/Notifiarr/notifiarr/pkg/apps" "github.com/Notifiarr/notifiarr/pkg/mnd" - "github.com/shirou/gopsutil/v3/host" + "github.com/shirou/gopsutil/v4/host" "golift.io/cnfg" ) From 0e5cd5a81772810c23aff32c0ff7d9460896fbc0 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sat, 29 Jun 2024 17:29:20 -0700 Subject: [PATCH 066/192] add comment --- pkg/snapshot/temperatures.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/snapshot/temperatures.go b/pkg/snapshot/temperatures.go index c3c864214..5a55232ac 100644 --- a/pkg/snapshot/temperatures.go +++ b/pkg/snapshot/temperatures.go @@ -24,6 +24,7 @@ func (s *Snapshot) getSystemTemps(ctx context.Context) error { return nil } + // Unmarshal the error for more info. var warns *sensors.Warnings if !errors.As(err, &warns) { return fmt.Errorf("unable to get sensor temperatures: %w", err) @@ -35,5 +36,4 @@ func (s *Snapshot) getSystemTemps(ctx context.Context) error { } return fmt.Errorf("getting sensor temperatures: %w: %s", err, strings.Join(errs, ", ")) - } From ce250eb33a51e407f6aea09ee4cabaa1de57d917 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 30 Jun 2024 11:29:55 -0700 Subject: [PATCH 067/192] update psutil lib --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2b7f9bc9b..ad7b6933e 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 github.com/mrobinsn/go-rtorrent v1.8.0 github.com/nxadm/tail v1.4.11 - github.com/shirou/gopsutil/v4 v4.24.5 + github.com/shirou/gopsutil/v4 v4.24.6-0.20240625095728-865b8c3f58d6 github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace github.com/stretchr/testify v1.9.0 github.com/swaggo/swag v1.16.3 diff --git a/go.sum b/go.sum index 228d6f798..01664c5a7 100644 --- a/go.sum +++ b/go.sum @@ -228,8 +228,8 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk= -github.com/shirou/gopsutil/v4 v4.24.5 h1:gGsArG5K6vmsh5hcFOHaPm87UD003CaDMkAOweSQjhM= -github.com/shirou/gopsutil/v4 v4.24.5/go.mod h1:aoebb2vxetJ/yIDZISmduFvVNPHqXQ9SEJwRXxkf0RA= +github.com/shirou/gopsutil/v4 v4.24.6-0.20240625095728-865b8c3f58d6 h1:onLMu4GbkyGnQVOCJS0Jl0MftM/22vqdBzm/f1TZxEo= +github.com/shirou/gopsutil/v4 v4.24.6-0.20240625095728-865b8c3f58d6/go.mod h1:aoebb2vxetJ/yIDZISmduFvVNPHqXQ9SEJwRXxkf0RA= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= From 9867058b9ad5514f05dc8fc56d3cba9ca1c824d4 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 30 Jun 2024 12:15:25 -0700 Subject: [PATCH 068/192] fix lib --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2b7f9bc9b..ad7b6933e 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 github.com/mrobinsn/go-rtorrent v1.8.0 github.com/nxadm/tail v1.4.11 - github.com/shirou/gopsutil/v4 v4.24.5 + github.com/shirou/gopsutil/v4 v4.24.6-0.20240625095728-865b8c3f58d6 github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace github.com/stretchr/testify v1.9.0 github.com/swaggo/swag v1.16.3 diff --git a/go.sum b/go.sum index 228d6f798..01664c5a7 100644 --- a/go.sum +++ b/go.sum @@ -228,8 +228,8 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk= -github.com/shirou/gopsutil/v4 v4.24.5 h1:gGsArG5K6vmsh5hcFOHaPm87UD003CaDMkAOweSQjhM= -github.com/shirou/gopsutil/v4 v4.24.5/go.mod h1:aoebb2vxetJ/yIDZISmduFvVNPHqXQ9SEJwRXxkf0RA= +github.com/shirou/gopsutil/v4 v4.24.6-0.20240625095728-865b8c3f58d6 h1:onLMu4GbkyGnQVOCJS0Jl0MftM/22vqdBzm/f1TZxEo= +github.com/shirou/gopsutil/v4 v4.24.6-0.20240625095728-865b8c3f58d6/go.mod h1:aoebb2vxetJ/yIDZISmduFvVNPHqXQ9SEJwRXxkf0RA= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= From 954a08a13a3e3e77581439576b32c95b2c4a3038 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 01:33:23 +0000 Subject: [PATCH 069/192] Update golift.io/cnfgfile digest to 48378d0 --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index ad7b6933e..e28c030f9 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,7 @@ require ( golang.org/x/time v0.5.0 golift.io/cache v0.0.2 golift.io/cnfg v0.2.3 - golift.io/cnfgfile v0.0.0-20230531075023-f880041cc0a0 + golift.io/cnfgfile v0.0.0-20240704165116-48378d0c6c38 golift.io/datacounter v1.0.4 golift.io/deluge v0.10.1 golift.io/mulery v0.0.8 diff --git a/go.sum b/go.sum index 01664c5a7..b2c14b00b 100644 --- a/go.sum +++ b/go.sum @@ -428,6 +428,8 @@ golift.io/cnfg v0.2.3 h1:cQsC4JS20njJyu5drtGefNmgN7M4HrLaRDNBPLit3pQ= golift.io/cnfg v0.2.3/go.mod h1:T4t8MFa8aZilCdIk1qQrN4mOGaFVPZ/qHQBBMbCIZJ0= golift.io/cnfgfile v0.0.0-20230531075023-f880041cc0a0 h1:u14MTHfTGx7kLX2b3wFbaESrIm3YqL//HM92XA6wzH4= golift.io/cnfgfile v0.0.0-20230531075023-f880041cc0a0/go.mod h1:dVC3N+72/nHNlBv3cwXb4FQTxMAor+JlNClAldwACkY= +golift.io/cnfgfile v0.0.0-20240704165116-48378d0c6c38 h1:euXQUUWtsi2M+Bf6Do4+yG3YrVj88WyN0WJdv/abeW0= +golift.io/cnfgfile v0.0.0-20240704165116-48378d0c6c38/go.mod h1:zHm9o8SkZ6Mm5DfGahsrEJPsogyR0qItP59s5lJ98/I= golift.io/datacounter v1.0.4 h1:b2gLQCs8WYRtKjOMG0qM82rF1o0+oKUXB9QH7kjmxZ4= golift.io/datacounter v1.0.4/go.mod h1:79Yf1ucynYvZzVS/hpfrAFt6y/w82FMlOJgh+MBaZvs= golift.io/deluge v0.10.1 h1:wu1GzXsDYzWGnRl4mNEd2IeY0O7+jhYJ4IKBPfDEanM= From 284b14c04db429289ae387aaa182428976550afe Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 01:33:52 +0000 Subject: [PATCH 070/192] Update module golang.org/x/mod to v0.19.0 --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index ad7b6933e..b8db8fa6b 100644 --- a/go.mod +++ b/go.mod @@ -34,7 +34,7 @@ require ( github.com/stretchr/testify v1.9.0 github.com/swaggo/swag v1.16.3 golang.org/x/crypto v0.24.0 - golang.org/x/mod v0.18.0 + golang.org/x/mod v0.19.0 golang.org/x/sys v0.21.0 golang.org/x/text v0.16.0 golang.org/x/time v0.5.0 diff --git a/go.sum b/go.sum index 01664c5a7..fc7decdf1 100644 --- a/go.sum +++ b/go.sum @@ -311,6 +311,8 @@ golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0= golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= +golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= From 6ed8c3df64ded5c2cd3f414012dac007da648691 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Mon, 8 Jul 2024 15:02:05 -0700 Subject: [PATCH 071/192] unescape html output for human view --- pkg/client/instance_tests.go | 16 ++++++++-------- pkg/services/check_ping.go | 8 ++++---- pkg/services/check_proc.go | 12 ++++++------ pkg/services/checks.go | 32 ++++++++++++++++---------------- pkg/services/config.go | 25 +++++++++++++++++++++++-- 5 files changed, 57 insertions(+), 36 deletions(-) diff --git a/pkg/client/instance_tests.go b/pkg/client/instance_tests.go index 3bddd0efa..4abd11983 100644 --- a/pkg/client/instance_tests.go +++ b/pkg/client/instance_tests.go @@ -342,10 +342,10 @@ func testTCP(ctx context.Context, svc *services.Service) (string, int) { res := svc.CheckOnly(ctx) if res.State != services.StateOK { - return res.State.String() + " " + res.Output, http.StatusBadGateway + return res.State.String() + " " + res.Output.String(), http.StatusBadGateway } - return "TCP Port is OPEN and reachable: " + res.Output, http.StatusOK + return "TCP Port is OPEN and reachable: " + res.Output.String(), http.StatusOK } func testHTTP(ctx context.Context, svc *services.Service) (string, int) { @@ -355,11 +355,11 @@ func testHTTP(ctx context.Context, svc *services.Service) (string, int) { res := svc.CheckOnly(ctx) if res.State != services.StateOK { - return res.State.String() + " " + res.Output, http.StatusBadGateway + return res.State.String() + " " + res.Output.String(), http.StatusBadGateway } // add test - return "HTTP Response Code Acceptable! " + res.Output, http.StatusOK + return "HTTP Response Code Acceptable! " + res.Output.String(), http.StatusOK } func testProcess(ctx context.Context, svc *services.Service) (string, int) { @@ -369,10 +369,10 @@ func testProcess(ctx context.Context, svc *services.Service) (string, int) { res := svc.CheckOnly(ctx) if res.State != services.StateOK { - return res.State.String() + " " + res.Output, http.StatusBadGateway + return res.State.String() + " " + res.Output.String(), http.StatusBadGateway } - return "Process Tested OK: " + res.Output, http.StatusOK + return "Process Tested OK: " + res.Output.String(), http.StatusOK } func testPing(ctx context.Context, svc *services.Service) (string, int) { @@ -382,10 +382,10 @@ func testPing(ctx context.Context, svc *services.Service) (string, int) { res := svc.CheckOnly(ctx) if res.State != services.StateOK { - return res.State.String() + " " + res.Output, http.StatusBadGateway + return res.State.String() + " " + res.Output.String(), http.StatusBadGateway } - return "Ping Tested OK: " + res.Output, http.StatusOK + return "Ping Tested OK: " + res.Output.String(), http.StatusOK } func testPlex(ctx context.Context, app *apps.PlexConfig) (string, int) { diff --git a/pkg/services/check_ping.go b/pkg/services/check_ping.go index 9a28a4e94..28bca85c6 100644 --- a/pkg/services/check_ping.go +++ b/pkg/services/check_ping.go @@ -77,7 +77,7 @@ func (s *Service) checkPING() *result { if err != nil { return &result{ state: StateUnknown, - output: "invalid ping value: " + err.Error(), + output: &Output{str: "invalid ping value: " + err.Error()}, } } @@ -89,7 +89,7 @@ func (s *Service) checkPING() *result { if err = pinger.Run(); err != nil { // blocks. return &result{ state: StateCritical, - output: "error pinging service: " + err.Error(), + output: &Output{str: "error pinging service: " + err.Error()}, } } @@ -105,8 +105,8 @@ func (s *Service) checkPING() *result { return &result{ state: state, - output: fmt.Sprintf("(%s) pkts sent:%d, rcvd:%d, loss:%.01f, max:%s, avg:%s", + output: &Output{str: fmt.Sprintf("(%s) pkts sent:%d, rcvd:%d, loss:%.01f, max:%s, avg:%s", msg, stats.PacketsSent, stats.PacketsRecv, stats.PacketLoss, - stats.MaxRtt.Round(time.Millisecond), stats.AvgRtt.Round(time.Millisecond)), + stats.MaxRtt.Round(time.Millisecond), stats.AvgRtt.Round(time.Millisecond))}, } } diff --git a/pkg/services/check_proc.go b/pkg/services/check_proc.go index 409df9e0b..d1038f17d 100644 --- a/pkg/services/check_proc.go +++ b/pkg/services/check_proc.go @@ -74,7 +74,7 @@ func (s *Service) checkProccess(ctx context.Context) *result { if err != nil { return &result{ state: StateUnknown, - output: "process list error: " + err.Error(), + output: &Output{str: "process list error: " + err.Error()}, } } @@ -106,8 +106,8 @@ func (s *Service) getProcessResults(ctx context.Context, processes []*process.Pr if !procinfo.Created.IsZero() && s.svc.proc.restarts && time.Since(procinfo.Created) < s.Interval.Duration { return &result{ state: StateCritical, - output: fmt.Sprintf("%s: process restarted since last check, age: %v, pid: %d, proc: %s", - s.Value, time.Since(procinfo.Created), proc.Pid, procinfo.CmdLine), + output: &Output{str: fmt.Sprintf("%s: process restarted since last check, age: %v, pid: %d, proc: %s", + s.Value, time.Since(procinfo.Created), proc.Pid, procinfo.CmdLine)}, } } } @@ -128,17 +128,17 @@ func (s *Service) checkProcessCounts(pids []int32, ages []time.Time) *result { case count < s.svc.proc.countMin: // not enough running! return &result{ state: StateCritical, - output: fmt.Sprintf("%s: found %d processes; %s%s%s%s", s.Value, count, min, max, age, pid), + output: &Output{str: fmt.Sprintf("%s: found %d processes; %s%s%s%s", s.Value, count, min, max, age, pid)}, } case s.svc.proc.running && count > 0: // running but should not be! return &result{ state: StateCritical, - output: fmt.Sprintf("%s: found %d processes; expected: 0%s%s", s.Value, count, age, pid), + output: &Output{str: fmt.Sprintf("%s: found %d processes; expected: 0%s%s", s.Value, count, age, pid)}, } default: // running within thresholds! return &result{ state: StateOK, - output: fmt.Sprintf("%s: found %d processes; %s%s%s%s", s.Value, count, min, max, age, pid), + output: &Output{str: fmt.Sprintf("%s: found %d processes; %s%s%s%s", s.Value, count, min, max, age, pid)}, } } } diff --git a/pkg/services/checks.go b/pkg/services/checks.go index fde81c969..a1f6f651d 100644 --- a/pkg/services/checks.go +++ b/pkg/services/checks.go @@ -24,7 +24,7 @@ const ( ) type result struct { - output string + output *Output state CheckState } @@ -185,7 +185,7 @@ func (s *Service) checkHTTPReq(ctx context.Context) (*http.Client, *http.Request func (s *Service) checkHTTP(ctx context.Context) *result { res := &result{ state: StateUnknown, - output: "unknown", + output: &Output{str: "unknown"}, } ctx, cancel := context.WithTimeout(ctx, s.Timeout.Duration) @@ -193,7 +193,7 @@ func (s *Service) checkHTTP(ctx context.Context) *result { client, req, err := s.checkHTTPReq(ctx) if err != nil { - res.output = "creating request: " + RemoveSecrets(s.Value, err.Error()) + res.output = &Output{str: "creating request: " + RemoveSecrets(s.Value, err.Error())} return res } @@ -202,39 +202,39 @@ func (s *Service) checkHTTP(ctx context.Context) *result { resp, err := client.Do(req) if err != nil { - res.output = "making request: " + RemoveSecrets(s.Value, err.Error()) + res.output = &Output{str: "making request: " + RemoveSecrets(s.Value, err.Error())} return res } defer resp.Body.Close() body, err := io.ReadAll(resp.Body) if err != nil { - res.output = "reading body: " + RemoveSecrets(s.Value, err.Error()) + res.output = &Output{str: "reading body: " + RemoveSecrets(s.Value, err.Error())} return res } for _, code := range strings.Split(s.Expect, expectdelim) { if strconv.Itoa(resp.StatusCode) == strings.TrimSpace(code) { res.state = StateOK - res.output = resp.Status + res.output = &Output{str: resp.Status} return res } } // Reduce the size of the string before processing it to speed things up on large body outputs. - if len(res.output) > maxOutput+maxOutput { - res.output = res.output[:maxOutput+maxOutput] + if len(res.output.str) > maxOutput+maxOutput { + res.output.str = res.output.str[:maxOutput+maxOutput] } res.state = StateCritical - res.output = resp.Status + ": " + strings.TrimSpace( - html.EscapeString(strings.Join(strings.Fields(RemoveSecrets(s.Value, string(body))), " "))) + res.output = &Output{esc: true, str: resp.Status + ": " + strings.TrimSpace( + html.EscapeString(strings.Join(strings.Fields(RemoveSecrets(s.Value, string(body))), " ")))} // Reduce the string to the final max length. // We do it this way so all secrets are properly escaped before string splitting. - if len(res.output) > maxOutput { - res.output = res.output[:maxOutput] + if len(res.output.str) > maxOutput { + res.output.str = res.output.str[:maxOutput] } return res @@ -259,21 +259,21 @@ func RemoveSecrets(appURL, message string) string { func (s *Service) checkTCP() *result { res := &result{ state: StateUnknown, - output: "unknown", + output: &Output{str: "unknown"}, } switch conn, err := net.DialTimeout("tcp", s.Value, s.Timeout.Duration); { case err != nil: res.state = StateCritical - res.output = "connection error: " + err.Error() + res.output = &Output{str: "connection error: " + err.Error()} case conn == nil: res.state = StateUnknown - res.output = "connection failed, no specific error" + res.output = &Output{str: "connection failed, no specific error"} default: conn.Close() res.state = StateOK - res.output = "connected to port " + strings.Split(s.Value, ":")[1] + " OK" + res.output = &Output{str: "connected to port " + strings.Split(s.Value, ":")[1] + " OK"} } return res diff --git a/pkg/services/config.go b/pkg/services/config.go index a4a2f965c..8c6ddc4bf 100644 --- a/pkg/services/config.go +++ b/pkg/services/config.go @@ -2,6 +2,7 @@ package services import ( "fmt" + "html" "sync" "time" @@ -87,7 +88,7 @@ type Results struct { type CheckResult struct { Name string `json:"name"` // "Radarr" State CheckState `json:"state"` // 0 = OK, 1 = Warn, 2 = Crit, 3 = Unknown - Output string `json:"output"` // metadata message + Output *Output `json:"output"` // metadata message must never be nil. Type CheckType `json:"type"` // http, tcp, ping Time time.Time `json:"time"` // when it was checked, rounded to Microseconds Since time.Time `json:"since"` // how long it has been in this state, rounded to Microseconds @@ -112,7 +113,7 @@ type Service struct { } type service struct { - Output string `json:"output"` + Output *Output `json:"output"` State CheckState `json:"state"` Since time.Time `json:"since"` LastCheck time.Time `json:"lastCheck"` @@ -121,3 +122,23 @@ type service struct { ping *pingExpect // only used for icmp/udp ping checks. sync.RWMutex `json:"-"` } + +type Output struct { + str string // output string + esc bool // html escaped? +} + +func (o *Output) String() string { + switch { + case o == nil: + return "" + case o.esc: + return html.UnescapeString(o.str) + default: + return o.str + } +} + +func (o *Output) MarshalJSON() ([]byte, error) { + return []byte(`"` + o.String() + `"`), nil +} From 6b0b4bdbae516a9018824b5d96d130e7f0e6c407 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Mon, 8 Jul 2024 15:17:33 -0700 Subject: [PATCH 072/192] do not unescape when sending --- pkg/services/config.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/services/config.go b/pkg/services/config.go index 8c6ddc4bf..125532220 100644 --- a/pkg/services/config.go +++ b/pkg/services/config.go @@ -1,6 +1,7 @@ package services import ( + "encoding/json" "fmt" "html" "sync" @@ -140,5 +141,5 @@ func (o *Output) String() string { } func (o *Output) MarshalJSON() ([]byte, error) { - return []byte(`"` + o.String() + `"`), nil + return json.Marshal(o.str) // do not unescape it. } From 90ae1a7a5cabfb8ecfac15377e0246759f41193d Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Mon, 8 Jul 2024 15:28:51 -0700 Subject: [PATCH 073/192] update deps, fix bug, fix lint --- go.mod | 12 ++++++------ go.sum | 36 ++++++++++++++++-------------------- pkg/client/instance_tests.go | 3 ++- pkg/services/config.go | 2 +- 4 files changed, 25 insertions(+), 28 deletions(-) diff --git a/go.mod b/go.mod index f507f761e..e6fbc78a5 100644 --- a/go.mod +++ b/go.mod @@ -29,13 +29,13 @@ require ( github.com/mitchellh/go-homedir v1.1.0 github.com/mrobinsn/go-rtorrent v1.8.0 github.com/nxadm/tail v1.4.11 - github.com/shirou/gopsutil/v4 v4.24.6-0.20240625095728-865b8c3f58d6 + github.com/shirou/gopsutil/v4 v4.24.6 github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace github.com/stretchr/testify v1.9.0 github.com/swaggo/swag v1.16.3 - golang.org/x/crypto v0.24.0 + golang.org/x/crypto v0.25.0 golang.org/x/mod v0.19.0 - golang.org/x/sys v0.21.0 + golang.org/x/sys v0.22.0 golang.org/x/text v0.16.0 golang.org/x/time v0.5.0 golift.io/cache v0.0.2 @@ -104,15 +104,15 @@ require ( github.com/ulikunitz/xz v0.5.12 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect go4.org v0.0.0-20230225012048-214862532bf5 // indirect - golang.org/x/net v0.26.0 // indirect + golang.org/x/net v0.27.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/tools v0.22.0 // indirect + golang.org/x/tools v0.23.0 // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect howett.net/plist v1.0.1 // indirect modernc.org/gc/v3 v3.0.0-20240304020402-f0dba7c97c2b // indirect - modernc.org/libc v1.53.4 // indirect + modernc.org/libc v1.54.3 // indirect modernc.org/mathutil v1.6.0 // indirect modernc.org/memory v1.8.0 // indirect modernc.org/strutil v1.2.0 // indirect diff --git a/go.sum b/go.sum index 7ad2e3c90..087294b30 100644 --- a/go.sum +++ b/go.sum @@ -228,8 +228,8 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk= -github.com/shirou/gopsutil/v4 v4.24.6-0.20240625095728-865b8c3f58d6 h1:onLMu4GbkyGnQVOCJS0Jl0MftM/22vqdBzm/f1TZxEo= -github.com/shirou/gopsutil/v4 v4.24.6-0.20240625095728-865b8c3f58d6/go.mod h1:aoebb2vxetJ/yIDZISmduFvVNPHqXQ9SEJwRXxkf0RA= +github.com/shirou/gopsutil/v4 v4.24.6 h1:9qqCSYF2pgOU+t+NgJtp7Co5+5mHF/HyKBUckySQL64= +github.com/shirou/gopsutil/v4 v4.24.6/go.mod h1:aoebb2vxetJ/yIDZISmduFvVNPHqXQ9SEJwRXxkf0RA= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= @@ -280,8 +280,8 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= -golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -309,8 +309,6 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0= -golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -331,8 +329,8 @@ golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLd golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= -golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= +golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -374,8 +372,8 @@ golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= @@ -418,8 +416,8 @@ golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA= -golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c= +golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg= +golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -428,8 +426,6 @@ golift.io/cache v0.0.2 h1:759rPK+EOy6UX7HkqsesOToSQ3CWN4UN3b5BiehfpeY= golift.io/cache v0.0.2/go.mod h1:wT61rGyiP50Rg243x5UF8dWBEKSr1RpB0GpgIF5kOGE= golift.io/cnfg v0.2.3 h1:cQsC4JS20njJyu5drtGefNmgN7M4HrLaRDNBPLit3pQ= golift.io/cnfg v0.2.3/go.mod h1:T4t8MFa8aZilCdIk1qQrN4mOGaFVPZ/qHQBBMbCIZJ0= -golift.io/cnfgfile v0.0.0-20230531075023-f880041cc0a0 h1:u14MTHfTGx7kLX2b3wFbaESrIm3YqL//HM92XA6wzH4= -golift.io/cnfgfile v0.0.0-20230531075023-f880041cc0a0/go.mod h1:dVC3N+72/nHNlBv3cwXb4FQTxMAor+JlNClAldwACkY= golift.io/cnfgfile v0.0.0-20240704165116-48378d0c6c38 h1:euXQUUWtsi2M+Bf6Do4+yG3YrVj88WyN0WJdv/abeW0= golift.io/cnfgfile v0.0.0-20240704165116-48378d0c6c38/go.mod h1:zHm9o8SkZ6Mm5DfGahsrEJPsogyR0qItP59s5lJ98/I= golift.io/datacounter v1.0.4 h1:b2gLQCs8WYRtKjOMG0qM82rF1o0+oKUXB9QH7kjmxZ4= @@ -504,18 +500,18 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= howett.net/plist v1.0.1 h1:37GdZ8tP09Q35o9ych3ehygcsL+HqKSwzctveSlarvM= howett.net/plist v1.0.1/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g= -modernc.org/cc/v4 v4.21.3 h1:2mhBdWKtivdFlLR1ecKXTljPG1mfvbByX7QKztAIJl8= -modernc.org/cc/v4 v4.21.3/go.mod h1:HM7VJTZbUCR3rV8EYBi9wxnJ0ZBRiGE5OeGXNA0IsLQ= -modernc.org/ccgo/v4 v4.18.2 h1:PUQPShG4HwghpOekNujL0sFavdkRvmxzTbI4rGJ5mg0= -modernc.org/ccgo/v4 v4.18.2/go.mod h1:ao1fAxf9a2KEOL15WY8+yP3wnpaOpP/QuyFOZ9HJolM= +modernc.org/cc/v4 v4.21.4 h1:3Be/Rdo1fpr8GrQ7IVw9OHtplU4gWbb+wNgeoBMmGLQ= +modernc.org/cc/v4 v4.21.4/go.mod h1:HM7VJTZbUCR3rV8EYBi9wxnJ0ZBRiGE5OeGXNA0IsLQ= +modernc.org/ccgo/v4 v4.19.0 h1:f9K5VdC0nVhHKTFMvhjtZ8TbRgFQbASvE5yO1zs8eC0= +modernc.org/ccgo/v4 v4.19.0/go.mod h1:CfpAl+673iXNwMG/aqcQn+vDcu4Es/YLya7+9RHjTa4= modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE= modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ= modernc.org/gc/v2 v2.4.1 h1:9cNzOqPyMJBvrUipmynX0ZohMhcxPtMccYgGOJdOiBw= modernc.org/gc/v2 v2.4.1/go.mod h1:wzN5dK1AzVGoH6XOzc3YZ+ey/jPgYHLuVckd62P0GYU= modernc.org/gc/v3 v3.0.0-20240304020402-f0dba7c97c2b h1:BnN1t+pb1cy61zbvSUV7SeI0PwosMhlAEi/vBY4qxp8= modernc.org/gc/v3 v3.0.0-20240304020402-f0dba7c97c2b/go.mod h1:Qz0X07sNOR1jWYCrJMEnbW/X55x206Q7Vt4mz6/wHp4= -modernc.org/libc v1.53.4 h1:YAgFS7tGIFBfqje2UOqiXtIwuDUCF8AUonYw0seup34= -modernc.org/libc v1.53.4/go.mod h1:aGsLofnkcct8lTJnKQnCqJO37ERAXSHamSuWLFoF2Cw= +modernc.org/libc v1.54.3 h1:pcPjjPJUHBRIJka4/R6AJ9FvxxuGRy0097QPjSMOdJs= +modernc.org/libc v1.54.3/go.mod h1:s3b2r/5Fre7gAEhWiMf+X1czfZ9KYx2rz4BBsnUf16E= modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E= diff --git a/pkg/client/instance_tests.go b/pkg/client/instance_tests.go index 4abd11983..be9400f6d 100644 --- a/pkg/client/instance_tests.go +++ b/pkg/client/instance_tests.go @@ -3,6 +3,7 @@ package client import ( "context" "fmt" + "html" "net/http" "net/url" "os" @@ -143,7 +144,7 @@ func (c *Client) testInstance(response http.ResponseWriter, request *http.Reques reply, code = testTautulli(request.Context(), config.Apps.Tautulli) } - http.Error(response, reply, code) + http.Error(response, html.EscapeString(reply), code) } func testDeluge(ctx context.Context, config *deluge.Config) (string, int) { diff --git a/pkg/services/config.go b/pkg/services/config.go index 125532220..2f3ba0d0f 100644 --- a/pkg/services/config.go +++ b/pkg/services/config.go @@ -141,5 +141,5 @@ func (o *Output) String() string { } func (o *Output) MarshalJSON() ([]byte, error) { - return json.Marshal(o.str) // do not unescape it. + return json.Marshal(o.str) //nolint:wrapcheck // do not unescape it. } From 19dfdd5ca38c34627c800705c305693cad10cb22 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Mon, 8 Jul 2024 16:14:56 -0700 Subject: [PATCH 074/192] update lint --- .github/workflows/codetests.yml | 4 ++-- .golangci.yml | 12 ++---------- pkg/apps/apppkg/plex/sessions.go | 2 +- pkg/apps/apppkg/sabnzbd/sabnzbd.go | 4 ++-- pkg/apps/setup.go | 2 +- pkg/client/handlers.go | 4 ++-- pkg/client/handlers_gui.go | 4 ++-- pkg/client/handlers_websocket.go | 2 +- pkg/client/html_templates.go | 14 +++++++------- pkg/client/start.go | 2 +- pkg/client/tunnel.go | 6 +++--- pkg/configfile/config.go | 19 +++++++++++++++---- pkg/configfile/password.go | 4 ++-- pkg/logs/logs.go | 2 +- pkg/mnd/functions.go | 2 +- pkg/mnd/metrics.go | 2 +- pkg/mnd/variables.go | 6 ++++-- pkg/services/check_ping.go | 2 +- pkg/services/check_proc_pre.go | 2 +- pkg/services/checks.go | 4 ++-- pkg/services/services.go | 2 +- pkg/snapshot/diskio.go | 8 ++++---- pkg/snapshot/helpers_windows.go | 2 +- pkg/snapshot/ipmi.go | 2 +- pkg/snapshot/memory_linux.go | 2 +- pkg/snapshot/nvidia.go | 2 +- pkg/snapshot/raid.go | 2 +- pkg/snapshot/smartctl.go | 2 +- pkg/snapshot/synology.go | 2 +- pkg/snapshot/system.go | 2 +- pkg/triggers/dashboard/lidarr.go | 2 +- pkg/triggers/dashboard/sonarr.go | 2 +- pkg/triggers/handler.go | 2 +- pkg/triggers/plexcron/plexcron.go | 2 +- pkg/update/unstable.go | 2 +- pkg/website/website.go | 6 +++--- 36 files changed, 73 insertions(+), 68 deletions(-) diff --git a/.github/workflows/codetests.yml b/.github/workflows/codetests.yml index 1554ec9c2..827a8a945 100644 --- a/.github/workflows/codetests.yml +++ b/.github/workflows/codetests.yml @@ -50,7 +50,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v6 with: - version: 'v1.57' + version: v1.59 golangci-linux: # description: "Runs golangci-lint on linux against linux and windows." @@ -71,7 +71,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v6 with: - version: 'v1.57' + version: v1.59 homebrew-test: # description: "Installs dependencies on macOS and runs `make install` to mimic a homebrew install." diff --git a/.golangci.yml b/.golangci.yml index cda25e69f..42335bc67 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -11,16 +11,8 @@ linters: enable-all: true disable: # deprecated - - maligned - - scopelint - - interfacer - - golint - - exhaustivestruct - - nosnakecase - - structcheck - - deadcode - - varcheck - - ifshort + - gomnd + - execinquery # unused - exhaustruct - exhaustive diff --git a/pkg/apps/apppkg/plex/sessions.go b/pkg/apps/apppkg/plex/sessions.go index 5aad013fb..e34f3102a 100644 --- a/pkg/apps/apppkg/plex/sessions.go +++ b/pkg/apps/apppkg/plex/sessions.go @@ -137,7 +137,7 @@ func GetMediaTranscode(mediaList []*Media) []string { if stream.Decision == "transcode" { videoMsg += fmt.Sprintf(" → %s (%s)", media.VideoResolution, strings.ToUpper(stream.Codec)) } - } else if stream.StreamType == 2 { //nolint:gomnd + } else if stream.StreamType == 2 { //nolint:mnd audioMsg = stream.DisplayTitle if stream.Decision == "transcode" { audioMsg += " → " + strings.ToUpper(stream.Codec) diff --git a/pkg/apps/apppkg/sabnzbd/sabnzbd.go b/pkg/apps/apppkg/sabnzbd/sabnzbd.go index fee32a530..8f2b7da3b 100644 --- a/pkg/apps/apppkg/sabnzbd/sabnzbd.go +++ b/pkg/apps/apppkg/sabnzbd/sabnzbd.go @@ -262,7 +262,7 @@ func (s *SabNZBDate) UnmarshalJSON(b []byte) (err error) { s.String = strings.Trim(string(b), `"`) if s.String == "unknown" { - s.Time = time.Now().Add(time.Hour * 24 * 366) //nolint:gomnd + s.Time = time.Now().Add(time.Hour * 24 * 366) //nolint:mnd return nil } @@ -284,7 +284,7 @@ func (s *SabNZBSize) UnmarshalJSON(b []byte) (err error) { return fmt.Errorf("could not convert to number: %s: %w", split[0], err) } - if len(split) < 2 { //nolint:gomnd + if len(split) < 2 { //nolint:mnd s.Bytes = int64(bytes) return nil } diff --git a/pkg/apps/setup.go b/pkg/apps/setup.go index 0bf8d27cd..712eec0cf 100644 --- a/pkg/apps/setup.go +++ b/pkg/apps/setup.go @@ -140,7 +140,7 @@ func (a *Apps) Setup() error { //nolint:cyclop func (a *Apps) InitHandlers() { a.keys = make(map[string]struct{}) for _, key := range append(a.ExKeys, a.APIKey) { - if len(key) > 3 { //nolint:gomnd + if len(key) > 3 { //nolint:mnd a.keys[key] = struct{}{} } } diff --git a/pkg/client/handlers.go b/pkg/client/handlers.go index 42c4d1ceb..3fefcc68c 100644 --- a/pkg/client/handlers.go +++ b/pkg/client/handlers.go @@ -180,7 +180,7 @@ func (c *Client) stripSecrets(next http.Handler) http.Handler { } // save into a request header for the logger. - r.Header.Set("X-Redacted-URI", uri) + r.Header.Set("X-Redacted-Uri", uri) next.ServeHTTP(w, r) }) } @@ -188,7 +188,7 @@ func (c *Client) stripSecrets(next http.Handler) http.Handler { func (c *Client) addUsernameHeader(next http.Handler) http.Handler { return http.HandlerFunc(func(response http.ResponseWriter, req *http.Request) { if username, _ := c.getUserName(req); username != "" { - req.Header.Set("X-NotiClient-Username", username) + req.Header.Set("X-Noticlient-Username", username) } next.ServeHTTP(response, req) diff --git a/pkg/client/handlers_gui.go b/pkg/client/handlers_gui.go index 5ef7c63d1..2713220b7 100644 --- a/pkg/client/handlers_gui.go +++ b/pkg/client/handlers_gui.go @@ -775,7 +775,7 @@ func (c *Client) validateNewServiceConfig(config *configfile.Config) error { } func (c *Client) indexPage(ctx context.Context, response http.ResponseWriter, request *http.Request, msg string) { - response.Header().Add("content-type", "text/html") + response.Header().Add("Content-Type", "text/html") user, _ := c.getUserName(request) if request.Method != http.MethodGet || (user == "" && c.webauth) { @@ -856,7 +856,7 @@ func (c *Client) handleInternalAsset(response http.ResponseWriter, request *http } mime := mime.TypeByExtension(path.Ext(request.URL.Path)) - response.Header().Set("content-type", mime) + response.Header().Set("Content-Type", mime) if _, err = response.Write(data); err != nil { c.Errorf("Writing HTTP Response: %v", err) diff --git a/pkg/client/handlers_websocket.go b/pkg/client/handlers_websocket.go index 7335a82b7..3df7f120b 100644 --- a/pkg/client/handlers_websocket.go +++ b/pkg/client/handlers_websocket.go @@ -86,7 +86,7 @@ func (c *Client) handleWebSockets(response http.ResponseWriter, request *http.Re func (c *Client) webSocketWriter(socket *websocket.Conn, fileTail *tail.Tail) { var ( lastError = "" - pingTicker = time.NewTicker(29 * time.Second) //nolint:gomnd + pingTicker = time.NewTicker(29 * time.Second) //nolint:mnd writeWait = 10 * time.Second ) diff --git a/pkg/client/html_templates.go b/pkg/client/html_templates.go index 9ad8996d3..5eb194f50 100644 --- a/pkg/client/html_templates.go +++ b/pkg/client/html_templates.go @@ -154,7 +154,7 @@ func (c *Client) getFuncMap() template.FuncMap { //nolint:funlen,cyclop "locked": func(env string) bool { return c.Flags.ConfigFile == "" || os.Getenv(env) != "" }, "contains": strings.Contains, "since": since, - "percent": func(i, j float64) int64 { return int64(i / j * 100) }, //nolint:gomnd + "percent": func(i, j float64) int64 { return int64(i / j * 100) }, //nolint:mnd "min": func(s string) string { for _, pieces := range strings.Split(s, ",") { if split := strings.Split(pieces, ":"); len(split) >= 2 && split[0] == "count" { @@ -326,7 +326,7 @@ func since(t time.Time) string { } return strings.ReplaceAll(durafmt.Parse(time.Since(t).Round(time.Second)). - LimitFirstN(3). //nolint:gomnd + LimitFirstN(3). //nolint:mnd Format(durafmt.Units{ Year: durafmt.Unit{Singular: "y", Plural: "y"}, Week: durafmt.Unit{Singular: "w", Plural: "w"}, @@ -484,7 +484,7 @@ func environ() map[string]string { out := make(map[string]string) for _, v := range os.Environ() { - if s := strings.SplitN(v, "=", 2); len(s) == 2 && s[0] != "" { //nolint:gomnd + if s := strings.SplitN(v, "=", 2); len(s) == 2 && s[0] != "" { //nolint:mnd out[s[0]] = s[1] } } @@ -612,7 +612,7 @@ func readFileTail(fileHandle *os.File, fileSize int64, count, skip int) ([]byte, // This is a magic number. // We assume 150 characters per line to optimize the buffer. - output.Grow(count * 150) //nolint:gomnd + output.Grow(count * 150) //nolint:mnd for { location-- // read 1 byte @@ -624,7 +624,7 @@ func readFileTail(fileHandle *os.File, fileSize int64, count, skip int) ([]byte, return nil, fmt.Errorf("reading open file: %w", err) } - if location != -1 && (char[0] == 10) { //nolint:gomnd + if location != -1 && (char[0] == 10) { //nolint:mnd found++ // we found a line } @@ -654,7 +654,7 @@ func readFileHead(fileHandle *os.File, fileSize int64, count, skip int) ([]byte, // This is a magic number. // We assume 150 characters per line to optimize the buffer. - output.Grow(count * 150) //nolint:gomnd + output.Grow(count * 150) //nolint:mnd for ; ; location++ { if _, err := fileHandle.Seek(location, io.SeekStart); err != nil { @@ -665,7 +665,7 @@ func readFileHead(fileHandle *os.File, fileSize int64, count, skip int) ([]byte, return nil, fmt.Errorf("reading open file: %w", err) } - if char[0] == 10 { //nolint:gomnd + if char[0] == 10 { //nolint:mnd found++ // we have a line if found <= skip { diff --git a/pkg/client/start.go b/pkg/client/start.go index cdb4819f2..98b170db7 100644 --- a/pkg/client/start.go +++ b/pkg/client/start.go @@ -283,7 +283,7 @@ func (c *Client) Exit(ctx context.Context, cancel context.CancelFunc) error { defer func() { defer c.CapturePanic() cancel() - //nolint:gomnd + //nolint:mnd c.Print(" ❌ Good bye! Uptime:", durafmt.Parse(time.Since(version.Started).Round(time.Second)).LimitFirstN(3)) }() diff --git a/pkg/client/tunnel.go b/pkg/client/tunnel.go index ab17f29aa..c5af93adc 100644 --- a/pkg/client/tunnel.go +++ b/pkg/client/tunnel.go @@ -82,7 +82,7 @@ func (c *Client) makeTunnel(ctx context.Context, ci *clientinfo.ClientInfo) { remWs, _ := apachelog.New(`%{X-Forwarded-For}i %{X-User-ID}i env:%{X-User-Environment}i %t "%r" %>s %b ` + `"%{X-Client-ID}i" "%{User-agent}i" %{X-Request-Time}i %{ms}Tms`) - //nolint:gomnd // just attempting a tiny bit of splay. + //nolint:mnd // just attempting a tiny bit of splay. c.tunnel = mulery.NewClient(&mulery.Config{ Name: hostname, ID: c.Config.HostID, @@ -103,7 +103,7 @@ func (c *Client) makeTunnel(ctx context.Context, ci *clientinfo.ClientInfo) { }) } -//nolint:gomnd // arbitrary failover time frames. +//nolint:mnd // arbitrary failover time frames. func (c *Client) roundRobinConfig(ci *clientinfo.ClientInfo) *mulery.RoundRobinConfig { interval := 10 * time.Minute if ci.IsSub() { @@ -239,7 +239,7 @@ func (c *Client) pingTunnels(response http.ResponseWriter, request *http.Request for idx, tunnel := range ci.User.Mulery { wait.Add(1) - time.Sleep(70 * time.Millisecond) //nolint:gomnd + time.Sleep(70 * time.Millisecond) //nolint:mnd go c.pingTunnel(request.Context(), idx, tunnel.Socket, inCh) } diff --git a/pkg/configfile/config.go b/pkg/configfile/config.go index 02f3f7655..fb1841ec1 100644 --- a/pkg/configfile/config.go +++ b/pkg/configfile/config.go @@ -16,6 +16,7 @@ import ( "path" "path/filepath" "strings" + "time" "github.com/BurntSushi/toml" "github.com/Notifiarr/notifiarr/pkg/apps" @@ -30,6 +31,7 @@ import ( "github.com/Notifiarr/notifiarr/pkg/website" "github.com/Notifiarr/notifiarr/pkg/website/clientinfo" "github.com/dsnet/compress/bzip2" + "github.com/hako/durafmt" homedir "github.com/mitchellh/go-homedir" "github.com/shirou/gopsutil/v4/host" "golift.io/cnfg" @@ -139,6 +141,10 @@ func (c *Config) Get(flag *Flags, logger *logs.Logger) (*website.Server, *trigge return nil, nil, fmt.Errorf("environment variables: %w", err) } + if _, err := cnfgfile.Parse(c, nil); err != nil { + return nil, nil, fmt.Errorf("filepath variables: %w", err) + } + if err := c.setupPassword(); err != nil { return nil, nil, err } @@ -225,15 +231,19 @@ func (c *Config) setup(logger *logs.Logger) *triggers.Actions { // FindAndReturn return a config file. Write one if requested. func (c *Config) FindAndReturn(ctx context.Context, configFile string, write bool) (string, string, string) { - var confFile string + var ( + confFile string + stat os.FileInfo + ) defaultConfigFile, configFileList := defaultLocactions() for _, fileName := range append([]string{configFile}, configFileList...) { - if d, err := homedir.Expand(fileName); err == nil { + d, err := homedir.Expand(fileName) + if err == nil { fileName = d } - if _, err := os.Stat(fileName); err == nil { + if stat, err = os.Stat(fileName); err == nil { confFile = fileName break } // else { log.Printf("rip: %v", err) } @@ -241,7 +251,8 @@ func (c *Config) FindAndReturn(ctx context.Context, configFile string, write boo if configFile = ""; confFile != "" { configFile, _ = filepath.Abs(confFile) - return configFile, "", MsgConfigFound + configFile + return configFile, "", MsgConfigFound + configFile + ", age: " + durafmt.Parse(time.Since(stat.ModTime())). + LimitFirstN(3).Format(mnd.DurafmtUnits) //nolint:mnd } if defaultConfigFile != "" && write { diff --git a/pkg/configfile/password.go b/pkg/configfile/password.go index a6d68e5a6..71845b005 100644 --- a/pkg/configfile/password.go +++ b/pkg/configfile/password.go @@ -131,9 +131,9 @@ func (p CryptPass) IsCrypted() bool { return strings.HasPrefix(p.Val(), authPassword) } -// GeneratePassword uses a word list to create a randmo password of two words and a number. +// GeneratePassword uses a word list to create a random password of two words and a number. // -//nolint:gosec,gomnd +//nolint:gosec,mnd func GeneratePassword() string { title := cases.Title(language.AmericanEnglish) pieces := make([]string, 4) diff --git a/pkg/logs/logs.go b/pkg/logs/logs.go index 83caf294e..6da7ee22e 100644 --- a/pkg/logs/logs.go +++ b/pkg/logs/logs.go @@ -235,7 +235,7 @@ func (l *Logger) writeMsg(msg string, log *log.Logger, name string, shared bool) // writeSplitMsg splits the message in half and attempts to write each half. // If the message is still too large, it'll be split again, and the process continues until it works. func (l *Logger) writeSplitMsg(msg string, log *log.Logger, name string) { - half := len(msg) / 2 //nolint:gomnd // split messages in half, recursively as needed. + half := len(msg) / 2 //nolint:mnd // split messages in half, recursively as needed. part1 := msg[:half] part2 := "...continuing: " + msg[half:] diff --git a/pkg/mnd/functions.go b/pkg/mnd/functions.go index 5d0807156..ac2b7956d 100644 --- a/pkg/mnd/functions.go +++ b/pkg/mnd/functions.go @@ -1,4 +1,4 @@ -//nolint:gomnd +//nolint:mnd package mnd import ( diff --git a/pkg/mnd/metrics.go b/pkg/mnd/metrics.go index 0cbaff0b9..1909dbd5f 100644 --- a/pkg/mnd/metrics.go +++ b/pkg/mnd/metrics.go @@ -77,7 +77,7 @@ func GetKeys(mapName *expvar.Map) map[string]interface{} { return output } -//nolint:gomnd +//nolint:mnd func GetSplitKeys(mapName *expvar.Map) map[string]map[string]interface{} { output := make(map[string]map[string]interface{}) diff --git a/pkg/mnd/variables.go b/pkg/mnd/variables.go index 7fc3f1a5c..13c9c020c 100644 --- a/pkg/mnd/variables.go +++ b/pkg/mnd/variables.go @@ -5,6 +5,7 @@ import ( "os" "strings" + "github.com/hako/durafmt" "golift.io/version" ) @@ -13,8 +14,9 @@ var ( // IsSynology tells us if this we're running on a Synology. IsSynology bool // IsDocker tells us if this is our Docker container. - IsDocker = os.Getpid() == 1 - IsUnstable = strings.HasPrefix(version.Branch, "unstable") + IsDocker = os.Getpid() == 1 + IsUnstable = strings.HasPrefix(version.Branch, "unstable") + DurafmtUnits, _ = durafmt.DefaultUnitsCoder.Decode("year,week,day,hour,min,sec,ms:ms,µs:µs") ) // ErrDisabledInstance is returned when a request for a disabled instance is performed. diff --git a/pkg/services/check_ping.go b/pkg/services/check_ping.go index 28bca85c6..cec4cb442 100644 --- a/pkg/services/check_ping.go +++ b/pkg/services/check_ping.go @@ -53,7 +53,7 @@ func (s *Service) fillPingExpect(icmp bool) (err error) { } splitStr := strings.Split(s.Expect, ":") - if len(splitStr) != 3 { //nolint:gomnd + if len(splitStr) != 3 { //nolint:mnd return ErrPingExpect } diff --git a/pkg/services/check_proc_pre.go b/pkg/services/check_proc_pre.go index 94d22b24f..eb9323ab7 100644 --- a/pkg/services/check_proc_pre.go +++ b/pkg/services/check_proc_pre.go @@ -85,7 +85,7 @@ func (s *Service) fillExpectCounts(str string) (err error) { } } - if len(countSplit) > 2 { //nolint:gomnd + if len(countSplit) > 2 { //nolint:mnd if s.svc.proc.countMax, err = strconv.Atoi(countSplit[2]); err != nil { return fmt.Errorf("invalid maximum count: %s: %w", countSplit[2], err) } diff --git a/pkg/services/checks.go b/pkg/services/checks.go index a1f6f651d..66ae38bd3 100644 --- a/pkg/services/checks.go +++ b/pkg/services/checks.go @@ -163,7 +163,7 @@ func (s *Service) checkHTTPReq(ctx context.Context) (*http.Client, *http.Request for _, val := range splitVal[1:] { // s.Value: http://url.com|header=value|another-header=val - if sv := strings.SplitN(val, ":", 2); len(sv) == 2 { //nolint:gomnd + if sv := strings.SplitN(val, ":", 2); len(sv) == 2 { //nolint:mnd req.Header.Add(sv[0], sv[1]) if strings.EqualFold(sv[0], "host") { @@ -242,7 +242,7 @@ func (s *Service) checkHTTP(ctx context.Context) *result { // RemoveSecrets removes secret token values in a message parsed from a url. func RemoveSecrets(appURL, message string) string { - url, err := url.Parse(strings.SplitN(appURL, "|", 2)[0]) //nolint:gomnd + url, err := url.Parse(strings.SplitN(appURL, "|", 2)[0]) //nolint:mnd if err != nil { return message } diff --git a/pkg/services/services.go b/pkg/services/services.go index bc643cc72..79367ecf7 100644 --- a/pkg/services/services.go +++ b/pkg/services/services.go @@ -180,7 +180,7 @@ func (c *Config) runServiceChecker() { //nolint:cyclop ticker = time.NewTicker(c.Interval.Duration) defer ticker.Stop() - second = time.NewTicker(10 * time.Second) //nolint:gomnd + second = time.NewTicker(10 * time.Second) //nolint:mnd defer second.Stop() c.runChecks(true) diff --git a/pkg/snapshot/diskio.go b/pkg/snapshot/diskio.go index 4863186a2..c57e6b730 100644 --- a/pkg/snapshot/diskio.go +++ b/pkg/snapshot/diskio.go @@ -130,13 +130,13 @@ func (s *Snapshot) scanIOTop(stdout *bufio.Scanner, wg *sync.WaitGroup) { case strings.Contains(text, "illegal option"): return // it's a bad command wrong OS. - case len(fields) < 10, fields[0] == "PID": //nolint:gomnd + case len(fields) < 10, fields[0] == "PID": //nolint:mnd // PID PRIO USER DISK READ DISK WRITE SWAPIN IO COMMAND // not enough fields, or header row. continue case fields[0] == "Total": // Total DISK READ: 0.00 K/s | Total DISK WRITE: 0.00 K/s - if nums := regex.FindAllString(text, 2); len(nums) == 2 { //nolint:gomnd + if nums := regex.FindAllString(text, 2); len(nums) == 2 { //nolint:mnd s.IOTop.TotalRead, _ = strconv.ParseFloat(nums[0], mnd.Bits64) s.IOTop.TotalWrite, _ = strconv.ParseFloat(nums[1], mnd.Bits64) s.IOTop.TotalRead *= mnd.Kilobyte // convert to bytes. @@ -144,13 +144,13 @@ func (s *Snapshot) scanIOTop(stdout *bufio.Scanner, wg *sync.WaitGroup) { } case fields[0] == "Current", fields[0] == "Actual": // Current DISK READ: 0.00 K/s | Current DISK WRITE: 0.00 K/s - if nums := regex.FindAllString(text, 2); len(nums) == 2 { //nolint:gomnd + if nums := regex.FindAllString(text, 2); len(nums) == 2 { //nolint:mnd s.IOTop.CurrRead, _ = strconv.ParseFloat(nums[0], mnd.Bits64) s.IOTop.CurrWrite, _ = strconv.ParseFloat(nums[1], mnd.Bits64) s.IOTop.CurrRead *= mnd.Kilobyte // convert to bytes. s.IOTop.CurrWrite *= mnd.Kilobyte // convert to bytes. } - case len(fields) >= 12: //nolint:gomnd + case len(fields) >= 12: //nolint:mnd // 780711 be/4 david 0.00 K/s 0.00 K/s 0.00 % 0.00 % pulseaudio --daemonize=no --log-target=journal proc := &IOTopProc{ // Pid: fields[0] diff --git a/pkg/snapshot/helpers_windows.go b/pkg/snapshot/helpers_windows.go index 464b8287f..88e52ef4b 100644 --- a/pkg/snapshot/helpers_windows.go +++ b/pkg/snapshot/helpers_windows.go @@ -6,5 +6,5 @@ import ( ) func sysCallSettings(cmd *exec.Cmd) { - cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true, CreationFlags: 0x08000000} //nolint:gomnd + cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true, CreationFlags: 0x08000000} //nolint:mnd } diff --git a/pkg/snapshot/ipmi.go b/pkg/snapshot/ipmi.go index 66c4a40ce..0e690a023 100644 --- a/pkg/snapshot/ipmi.go +++ b/pkg/snapshot/ipmi.go @@ -1,4 +1,4 @@ -//nolint:gomnd +//nolint:mnd package snapshot import ( diff --git a/pkg/snapshot/memory_linux.go b/pkg/snapshot/memory_linux.go index 3fe76393a..a7dc2d1b1 100644 --- a/pkg/snapshot/memory_linux.go +++ b/pkg/snapshot/memory_linux.go @@ -22,7 +22,7 @@ func (s *Snapshot) GetMemoryUsage(ctx context.Context) error { for scanner.Scan() { switch fields := strings.Fields(scanner.Text()); { - case len(fields) < 3: //nolint:gomnd + case len(fields) < 3: //nolint:mnd continue case strings.EqualFold(fields[0], "MemTotal:"): s.System.MemTotal, _ = strconv.ParseUint(fields[1], mnd.Base10, mnd.Bits64) diff --git a/pkg/snapshot/nvidia.go b/pkg/snapshot/nvidia.go index 87e3a6188..8bd3f5875 100644 --- a/pkg/snapshot/nvidia.go +++ b/pkg/snapshot/nvidia.go @@ -62,7 +62,7 @@ func (s *Snapshot) GetNvidia(ctx context.Context, config *NvidiaConfig) error { } else if cmdPath, err = exec.LookPath(nvidiaSMIname()); err != nil { // do not throw an error if nvidia-smi is missing. // return fmt.Errorf("nvidia-smi missing! %w", err) - return nil //nolint:nilerr + return nil } cmd := exec.CommandContext(ctx, cmdPath, "--format=csv,noheader", "--query-gpu="+ diff --git a/pkg/snapshot/raid.go b/pkg/snapshot/raid.go index a24b5562d..f2761b94f 100644 --- a/pkg/snapshot/raid.go +++ b/pkg/snapshot/raid.go @@ -128,7 +128,7 @@ func (s *Snapshot) scanMegaCLI(stdout *bufio.Scanner, waitg *sync.WaitGroup) { continue } - if split := strings.SplitN(strings.TrimSpace(text), ":", 2); len(split) == 2 && current != nil { //nolint:gomnd + if split := strings.SplitN(strings.TrimSpace(text), ":", 2); len(split) == 2 && current != nil { //nolint:mnd current.Data[strings.TrimSpace(split[0])] = strings.TrimSpace(split[1]) } } diff --git a/pkg/snapshot/smartctl.go b/pkg/snapshot/smartctl.go index 267850e3e..a4d45ba59 100644 --- a/pkg/snapshot/smartctl.go +++ b/pkg/snapshot/smartctl.go @@ -182,7 +182,7 @@ func (s *Snapshot) scanSmartctl(stdout *bufio.Scanner, name string, waitg *sync. case strings.Contains(text, "self-assessment ") || strings.Contains(text, "SMART Health Status:"): s.DiskHealth[name] = fields[len(fields)-1] - case len(fields) < 10: //nolint: gomnd + case len(fields) < 10: //nolint:mnd continue case strings.HasPrefix(fields[1], "Airflow_Temp") || strings.HasPrefix(fields[1], "Temperature_Cel"): diff --git a/pkg/snapshot/synology.go b/pkg/snapshot/synology.go index 2bc114709..315e72934 100644 --- a/pkg/snapshot/synology.go +++ b/pkg/snapshot/synology.go @@ -58,7 +58,7 @@ func GetSynology() (*Synology, error) { //nolint:cyclop } lsplit := strings.Split(line, "=") - if len(lsplit) < 2 { //nolint:gomnd + if len(lsplit) < 2 { //nolint:mnd continue } diff --git a/pkg/snapshot/system.go b/pkg/snapshot/system.go index 5934459c8..ee26781f0 100644 --- a/pkg/snapshot/system.go +++ b/pkg/snapshot/system.go @@ -106,7 +106,7 @@ func (s *Snapshot) GetProcesses(ctx context.Context, count int) error { _, _ = proc.PercentWithContext(ctx, 0) } - time.Sleep(4 * time.Second) //nolint:gomnd + time.Sleep(4 * time.Second) //nolint:mnd for idx, proc := range procs { s.Processes[idx].CPUPercent, _ = proc.PercentWithContext(ctx, 0) diff --git a/pkg/triggers/dashboard/lidarr.go b/pkg/triggers/dashboard/lidarr.go index 2e32734c1..01a8e5755 100644 --- a/pkg/triggers/dashboard/lidarr.go +++ b/pkg/triggers/dashboard/lidarr.go @@ -91,7 +91,7 @@ func (c *Cmd) getLidarrState(ctx context.Context, instance int, app *apps.Lidarr func (c *Cmd) getLidarrHistory(ctx context.Context, app *apps.LidarrConfig) ([]*Sortable, error) { history, err := app.GetHistoryPageContext(ctx, &starr.PageReq{ Page: 1, - PageSize: showLatest + 20, //nolint:gomnd // grab extra in case some are tracks and not albums. + PageSize: showLatest + 20, //nolint:mnd // grab extra in case some are tracks and not albums. SortDir: starr.SortDescend, SortKey: "date", Filter: lidarr.FilterTrackFileImported, diff --git a/pkg/triggers/dashboard/sonarr.go b/pkg/triggers/dashboard/sonarr.go index 8b3718f8f..af2090619 100644 --- a/pkg/triggers/dashboard/sonarr.go +++ b/pkg/triggers/dashboard/sonarr.go @@ -83,7 +83,7 @@ func (c *Cmd) getSonarrState(ctx context.Context, instance int, app *apps.Sonarr func (c *Cmd) getSonarrHistory(app *apps.SonarrConfig) ([]*Sortable, error) { history, err := app.GetHistoryPage(&starr.PageReq{ Page: 1, - PageSize: showLatest + 5, //nolint:gomnd // grab extra in case there's an error. + PageSize: showLatest + 5, //nolint:mnd // grab extra in case there's an error. SortDir: starr.SortDescend, SortKey: "date", Filter: sonarr.FilterDownloadFolderImported, diff --git a/pkg/triggers/handler.go b/pkg/triggers/handler.go index 16dd25aa6..3fb4db8b3 100644 --- a/pkg/triggers/handler.go +++ b/pkg/triggers/handler.go @@ -427,7 +427,7 @@ func (a *Actions) backup(input *common.ActionInput, content string) (int, string func (a *Actions) handleConfigReload() (int, string) { go func() { // Until we have a way to reliably finish the tunnel requests, this is the best I got. - time.Sleep(200 * time.Millisecond) //nolint:gomnd + time.Sleep(200 * time.Millisecond) //nolint:mnd a.Timers.ReloadApp("HTTP Triggered Reload") }() diff --git a/pkg/triggers/plexcron/plexcron.go b/pkg/triggers/plexcron/plexcron.go index 40c717c5e..2c9f37202 100644 --- a/pkg/triggers/plexcron/plexcron.go +++ b/pkg/triggers/plexcron/plexcron.go @@ -124,7 +124,7 @@ func (c *cmd) sendWebhook(hook *plex.IncomingWebhook) { cancel() } - ctx, cancel := context.WithTimeout(ctx, 5*time.Second) //nolint:gomnd // wait max 5 seconds for system info. + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) //nolint:mnd // wait max 5 seconds for system info. defer cancel() c.SendData(&website.Request{ diff --git a/pkg/update/unstable.go b/pkg/update/unstable.go index 4316c986c..2c88540b4 100644 --- a/pkg/update/unstable.go +++ b/pkg/update/unstable.go @@ -77,7 +77,7 @@ func GetUnstable(ctx context.Context, uri string) (*UnstableFile, error) { return nil, fmt.Errorf("decoding %s response: %w", uri, err) } - release.Time, _ = time.Parse(time.RFC1123, resp.Header.Get("last-modified")) + release.Time, _ = time.Parse(time.RFC1123, resp.Header.Get("Last-Modified")) return &release, nil } diff --git a/pkg/website/website.go b/pkg/website/website.go index 2c18eba5f..aea71a281 100644 --- a/pkg/website/website.go +++ b/pkg/website/website.go @@ -73,7 +73,7 @@ func (s *Server) sendJSON(ctx context.Context, url string, data []byte, log bool } req.Header.Set("Content-Type", "application/json") - req.Header.Set("X-API-Key", s.Config.Apps.APIKey) + req.Header.Set("X-Api-Key", s.Config.Apps.APIKey) start := time.Now() @@ -127,7 +127,7 @@ func (s *Server) sendFile(ctx context.Context, uri string, file *UploadFile) (*R } req.Header.Set("Content-Type", contentType) - req.Header.Set("X-API-Key", s.Config.Apps.APIKey) + req.Header.Set("X-Api-Key", s.Config.Apps.APIKey) start := time.Now() msg := fmt.Sprintf("Upload %s, %d bytes", file.FileName, sent) @@ -212,7 +212,7 @@ func (h *httpClient) Do(req *http.Request) (*http.Response, error) { //nolint:cy } if resp.StatusCode < http.StatusInternalServerError && - (resp.StatusCode != http.StatusBadRequest || resp.Header.Get("content-type") != "text/html") { + (resp.StatusCode != http.StatusBadRequest || resp.Header.Get("Content-Type") != "text/html") { mnd.Website.Add(req.Method+mnd.BytesSent, resp.Request.ContentLength) return resp, nil } From 5f8a6270d5059d93b0a090fc9fb795223b5a119a Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Mon, 8 Jul 2024 17:09:51 -0700 Subject: [PATCH 075/192] add durafmt units --- pkg/client/client_windows.go | 3 ++- pkg/client/html_templates.go | 10 +--------- pkg/client/start.go | 2 +- pkg/mnd/functions.go | 2 +- pkg/mnd/variables.go | 1 + pkg/services/check_proc.go | 2 +- 6 files changed, 7 insertions(+), 13 deletions(-) diff --git a/pkg/client/client_windows.go b/pkg/client/client_windows.go index cfa2ff4d3..28d108779 100644 --- a/pkg/client/client_windows.go +++ b/pkg/client/client_windows.go @@ -79,7 +79,8 @@ func (c *Client) startAutoUpdater(ctx context.Context, dur time.Duration) { } time.Sleep(WaitTime) - c.Print(pfx+"Auto-updater started. Check interval:", durafmt.Parse(dur).String()) + c.Print(pfx+"Auto-updater started. Check interval:", + durafmt.Parse(dur).LimitFirstN(3).Format(mnd.DurafmtUnits)) //nolint:mnd // Check for update on startup. if err := c.checkAndUpdate(ctx, "startup check"); err != nil { diff --git a/pkg/client/html_templates.go b/pkg/client/html_templates.go index 5eb194f50..76fe04010 100644 --- a/pkg/client/html_templates.go +++ b/pkg/client/html_templates.go @@ -326,15 +326,7 @@ func since(t time.Time) string { } return strings.ReplaceAll(durafmt.Parse(time.Since(t).Round(time.Second)). - LimitFirstN(3). //nolint:mnd - Format(durafmt.Units{ - Year: durafmt.Unit{Singular: "y", Plural: "y"}, - Week: durafmt.Unit{Singular: "w", Plural: "w"}, - Day: durafmt.Unit{Singular: "d", Plural: "d"}, - Hour: durafmt.Unit{Singular: "h", Plural: "h"}, - Minute: durafmt.Unit{Singular: "m", Plural: "m"}, - Second: durafmt.Unit{Singular: "s", Plural: "s"}, - }), " ", "") + LimitFirstN(3).Format(mnd.DurafmtShort), " ", "") //nolint:mnd } // ParseGUITemplates parses the baked-in templates, and overrides them if a template directory is provided. diff --git a/pkg/client/start.go b/pkg/client/start.go index 98b170db7..4f4dd3111 100644 --- a/pkg/client/start.go +++ b/pkg/client/start.go @@ -284,7 +284,7 @@ func (c *Client) Exit(ctx context.Context, cancel context.CancelFunc) error { defer c.CapturePanic() cancel() //nolint:mnd - c.Print(" ❌ Good bye! Uptime:", durafmt.Parse(time.Since(version.Started).Round(time.Second)).LimitFirstN(3)) + c.Print(" ❌ Good bye! Uptime:", durafmt.Parse(time.Since(version.Started)).LimitFirstN(3).Format(mnd.DurafmtUnits)) }() c.StartWebServer(ctx) diff --git a/pkg/mnd/functions.go b/pkg/mnd/functions.go index ac2b7956d..c594b0c3b 100644 --- a/pkg/mnd/functions.go +++ b/pkg/mnd/functions.go @@ -52,7 +52,7 @@ func FormatBytes(size interface{}) string { //nolint:cyclop // DurationAgo returns an elapsed-time formatted for humans. // Print this after a date to show how long ago it was. func DurationAgo(when time.Time) string { - return " (" + durafmt.Parse(time.Since(when).Round(time.Hour)).String() + " ago)" + return " (" + durafmt.Parse(time.Since(when)).Format(DurafmtShort) + " ago)" } // PrintVersionInfo returns version information. diff --git a/pkg/mnd/variables.go b/pkg/mnd/variables.go index 13c9c020c..75f78d7f8 100644 --- a/pkg/mnd/variables.go +++ b/pkg/mnd/variables.go @@ -17,6 +17,7 @@ var ( IsDocker = os.Getpid() == 1 IsUnstable = strings.HasPrefix(version.Branch, "unstable") DurafmtUnits, _ = durafmt.DefaultUnitsCoder.Decode("year,week,day,hour,min,sec,ms:ms,µs:µs") + DurafmtShort, _ = durafmt.DefaultUnitsCoder.Decode("y:y,w:w,d:d,h:h,m:m,s:s,ms:ms,µs:µs") ) // ErrDisabledInstance is returned when a request for a disabled instance is performed. diff --git a/pkg/services/check_proc.go b/pkg/services/check_proc.go index d1038f17d..b669d6220 100644 --- a/pkg/services/check_proc.go +++ b/pkg/services/check_proc.go @@ -154,7 +154,7 @@ func (s *Service) getProcessStrings(pids []int32, ages []time.Time) (min, max, a } if len(ages) == 1 && !ages[0].IsZero() { - age = fmt.Sprintf(", age: %v", durafmt.ParseShort(time.Since(ages[0]).Round(time.Second))) + age = ", age: " + durafmt.Parse(time.Since(ages[0])).Format(mnd.DurafmtShort) } for _, activePid := range pids { From b05f8ff5d664703b21d02d7b085091692495895b Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Mon, 8 Jul 2024 17:27:38 -0700 Subject: [PATCH 076/192] more durafmt usage --- pkg/apps/api.go | 2 +- pkg/client/client_windows.go | 3 +-- pkg/client/html_templates.go | 5 ++--- pkg/client/start.go | 4 +--- pkg/client/tray_commands.go | 6 +++--- pkg/configfile/config.go | 5 +---- pkg/mnd/functions.go | 6 +++--- pkg/services/check_proc.go | 3 +-- pkg/update/unstable.go | 8 +++++--- 9 files changed, 18 insertions(+), 24 deletions(-) diff --git a/pkg/apps/api.go b/pkg/apps/api.go index ecae7ad72..6639beaad 100644 --- a/pkg/apps/api.go +++ b/pkg/apps/api.go @@ -116,7 +116,7 @@ func (a *Apps) handleAPI(app starr.App, api APIHandler) http.HandlerFunc { //nol // CheckAPIKey drops a 403 if the API key doesn't match, otherwise run next handler. func (a *Apps) CheckAPIKey(next http.Handler) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { //nolint:varnamelen - if _, ok := a.keys[r.Header.Get("X-API-Key")]; !ok { + if _, ok := a.keys[r.Header.Get("X-Api-Key")]; !ok { w.WriteHeader(http.StatusUnauthorized) return } diff --git a/pkg/client/client_windows.go b/pkg/client/client_windows.go index 28d108779..a9ed78005 100644 --- a/pkg/client/client_windows.go +++ b/pkg/client/client_windows.go @@ -79,8 +79,7 @@ func (c *Client) startAutoUpdater(ctx context.Context, dur time.Duration) { } time.Sleep(WaitTime) - c.Print(pfx+"Auto-updater started. Check interval:", - durafmt.Parse(dur).LimitFirstN(3).Format(mnd.DurafmtUnits)) //nolint:mnd + c.Print(pfx+"Auto-updater started. Check interval:", durafmt.Parse(dur.Round(time.Second)).LimitFirstN(3)) // Check for update on startup. if err := c.checkAndUpdate(ctx, "startup check"); err != nil { diff --git a/pkg/client/html_templates.go b/pkg/client/html_templates.go index 76fe04010..3a28e9fa6 100644 --- a/pkg/client/html_templates.go +++ b/pkg/client/html_templates.go @@ -324,9 +324,8 @@ func since(t time.Time) string { if t.IsZero() { return "N/A" } - - return strings.ReplaceAll(durafmt.Parse(time.Since(t).Round(time.Second)). - LimitFirstN(3).Format(mnd.DurafmtShort), " ", "") //nolint:mnd + //nolint:mnd + return strings.ReplaceAll(durafmt.Parse(time.Since(t)).LimitFirstN(3).Format(mnd.DurafmtShort), " ", "") } // ParseGUITemplates parses the baked-in templates, and overrides them if a template directory is provided. diff --git a/pkg/client/start.go b/pkg/client/start.go index 4f4dd3111..99c1c894b 100644 --- a/pkg/client/start.go +++ b/pkg/client/start.go @@ -27,7 +27,6 @@ import ( "github.com/Notifiarr/notifiarr/pkg/website" "github.com/Notifiarr/notifiarr/pkg/website/clientinfo" "github.com/gorilla/securecookie" - "github.com/hako/durafmt" flag "github.com/spf13/pflag" mulery "golift.io/mulery/client" "golift.io/version" @@ -283,8 +282,7 @@ func (c *Client) Exit(ctx context.Context, cancel context.CancelFunc) error { defer func() { defer c.CapturePanic() cancel() - //nolint:mnd - c.Print(" ❌ Good bye! Uptime:", durafmt.Parse(time.Since(version.Started)).LimitFirstN(3).Format(mnd.DurafmtUnits)) + c.Print(" ❌ Good bye! Exiting" + mnd.DurationAge(version.Started)) }() c.StartWebServer(ctx) diff --git a/pkg/client/tray_commands.go b/pkg/client/tray_commands.go index d59cc1388..274155a1e 100644 --- a/pkg/client/tray_commands.go +++ b/pkg/client/tray_commands.go @@ -59,7 +59,7 @@ func (c *Client) checkForUpdate(ctx context.Context, unstable bool) { if unstable { c.Print("[user requested] Unstable Update Check") - data, err = update.CheckUnstable(ctx, mnd.DefaultName, version.Revision) + data, err = update.CheckUnstable(ctx, mnd.Title, version.Revision) where = "Unstable website" } else { c.Print("[user requested] GitHub Update Check") @@ -77,7 +77,7 @@ func (c *Client) checkForUpdate(ctx context.Context, unstable bool) { c.downloadOther(data, unstable) default: _, _ = ui.Info(mnd.Title, "You're up to date! Version: "+data.Current+"\n"+ - "Updated: "+data.RelDate.Format("Jan 2, 2006")+mnd.DurationAgo(data.RelDate)) + "Updated: "+data.RelDate.Format("Jan 2, 2006")+mnd.DurationAge(data.RelDate)) } } @@ -91,7 +91,7 @@ func (c *Client) downloadOther(update *update.Update, unstable bool) { yes, _ := ui.Question(mnd.Title, msg+ "Your Version: "+version.Version+"-"+version.Revision+"\n"+ "New Version: "+update.Current+"\n"+ - "Date: "+update.RelDate.Format("Jan 2, 2006")+mnd.DurationAgo(update.RelDate), false) + "Date: "+update.RelDate.Format("Jan 2, 2006")+mnd.DurationAge(update.RelDate), false) if yes { _ = ui.OpenURL(update.CurrURL) } diff --git a/pkg/configfile/config.go b/pkg/configfile/config.go index fb1841ec1..d73ae4232 100644 --- a/pkg/configfile/config.go +++ b/pkg/configfile/config.go @@ -16,7 +16,6 @@ import ( "path" "path/filepath" "strings" - "time" "github.com/BurntSushi/toml" "github.com/Notifiarr/notifiarr/pkg/apps" @@ -31,7 +30,6 @@ import ( "github.com/Notifiarr/notifiarr/pkg/website" "github.com/Notifiarr/notifiarr/pkg/website/clientinfo" "github.com/dsnet/compress/bzip2" - "github.com/hako/durafmt" homedir "github.com/mitchellh/go-homedir" "github.com/shirou/gopsutil/v4/host" "golift.io/cnfg" @@ -251,8 +249,7 @@ func (c *Config) FindAndReturn(ctx context.Context, configFile string, write boo if configFile = ""; confFile != "" { configFile, _ = filepath.Abs(confFile) - return configFile, "", MsgConfigFound + configFile + ", age: " + durafmt.Parse(time.Since(stat.ModTime())). - LimitFirstN(3).Format(mnd.DurafmtUnits) //nolint:mnd + return configFile, "", MsgConfigFound + configFile + mnd.DurationAge(stat.ModTime()) } if defaultConfigFile != "" && write { diff --git a/pkg/mnd/functions.go b/pkg/mnd/functions.go index c594b0c3b..e7df86acb 100644 --- a/pkg/mnd/functions.go +++ b/pkg/mnd/functions.go @@ -49,10 +49,10 @@ func FormatBytes(size interface{}) string { //nolint:cyclop } } -// DurationAgo returns an elapsed-time formatted for humans. +// DurationAge returns an elapsed-time formatted for humans. // Print this after a date to show how long ago it was. -func DurationAgo(when time.Time) string { - return " (" + durafmt.Parse(time.Since(when)).Format(DurafmtShort) + " ago)" +func DurationAge(when time.Time) string { + return "; age: " + durafmt.Parse(time.Since(when)).LimitFirstN(3).Format(DurafmtUnits) //nolint:mnd } // PrintVersionInfo returns version information. diff --git a/pkg/services/check_proc.go b/pkg/services/check_proc.go index b669d6220..23c9559cd 100644 --- a/pkg/services/check_proc.go +++ b/pkg/services/check_proc.go @@ -9,7 +9,6 @@ import ( "time" "github.com/Notifiarr/notifiarr/pkg/mnd" - "github.com/hako/durafmt" "github.com/shirou/gopsutil/v4/process" ) @@ -154,7 +153,7 @@ func (s *Service) getProcessStrings(pids []int32, ages []time.Time) (min, max, a } if len(ages) == 1 && !ages[0].IsZero() { - age = ", age: " + durafmt.Parse(time.Since(ages[0])).Format(mnd.DurafmtShort) + age = mnd.DurationAge(ages[0]) } for _, activePid := range pids { diff --git a/pkg/update/unstable.go b/pkg/update/unstable.go index 2c88540b4..e27f1eaff 100644 --- a/pkg/update/unstable.go +++ b/pkg/update/unstable.go @@ -7,6 +7,7 @@ import ( "net/http" "runtime" "strconv" + "strings" "time" "github.com/Notifiarr/notifiarr/pkg/mnd" @@ -26,12 +27,13 @@ const unstableURL = "https://unstable.golift.io" // CheckUnstable checks if the provided app has an updated version on GitHub. // Pass in revision only, no version. func CheckUnstable(ctx context.Context, app string, revision string) (*Update, error) { - uri := fmt.Sprintf("%s/%s/%s.%s.exe.zip", unstableURL, app, app, runtime.GOARCH) + lower := strings.ToLower(app) + uri := fmt.Sprintf("%s/%s/%s.%s.exe.zip", unstableURL, lower, lower, runtime.GOARCH) if mnd.IsDarwin { - uri = fmt.Sprintf("%s/%s/%s.dmg", unstableURL, app, app) + uri = fmt.Sprintf("%s/%s/%s.dmg", unstableURL, lower, app) } else if !mnd.IsWindows { - uri = fmt.Sprintf("%s/%s/%s.%s.%s.gz", unstableURL, app, app, runtime.GOARCH, runtime.GOOS) + uri = fmt.Sprintf("%s/%s/%s.%s.%s.gz", unstableURL, lower, lower, runtime.GOARCH, runtime.GOOS) } release, err := GetUnstable(ctx, uri) From d948bd83418fd8b0e4454758d324c63ec8972174 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Mon, 8 Jul 2024 17:31:56 -0700 Subject: [PATCH 077/192] fixes --- pkg/client/client_windows.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/client/client_windows.go b/pkg/client/client_windows.go index a9ed78005..6d5c20cf8 100644 --- a/pkg/client/client_windows.go +++ b/pkg/client/client_windows.go @@ -25,7 +25,7 @@ func (c *Client) upgradeWindows(ctx context.Context, update *update.Update) { yes, _ := ui.Question(mnd.Title, "An Update is available! Upgrade Now?\n\n"+ "Your Version: "+version.Version+"-"+version.Revision+"\n"+ "New Version: "+update.Current+"\n"+ - "Date: "+update.RelDate.Format("Jan 2, 2006")+mnd.DurationAgo(update.RelDate), false) + "Date: "+update.RelDate.Format("Jan 2, 2006")+mnd.DurationAge(update.RelDate), false) if yes { if err := c.updateNow(ctx, update, "user requested"); err != nil { c.Errorf("Update Failed: %v", err) @@ -79,7 +79,7 @@ func (c *Client) startAutoUpdater(ctx context.Context, dur time.Duration) { } time.Sleep(WaitTime) - c.Print(pfx+"Auto-updater started. Check interval:", durafmt.Parse(dur.Round(time.Second)).LimitFirstN(3)) + c.Print(pfx+"Auto-updater started. Check interval:", durafmt.Parse(dur).LimitFirstN(3)) //nolint:mnd // Check for update on startup. if err := c.checkAndUpdate(ctx, "startup check"); err != nil { From 390e90c0cfcef5050aa6db3f1e36ffb18614600f Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Mon, 8 Jul 2024 18:29:31 -0700 Subject: [PATCH 078/192] more lint --- .golangci.yml | 9 +---- pkg/mnd/variables.go | 20 +++++---- pkg/snapshot/mysql.go | 94 +++++++++++++++++++++++-------------------- 3 files changed, 65 insertions(+), 58 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 42335bc67..450caef85 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -20,14 +20,9 @@ linters: - nlreturn - nonamedreturns - varnamelen - - godot + - godot # does not work with annotations. - perfsprint - # unneeded (broken because of generics) - - rowserrcheck - - wastedassign - - sqlclosecheck - #- revive # TODO: fix this one. - - musttag # broken in 1.52. + - musttag # broken in 1.59. - depguard - tagalign run: diff --git a/pkg/mnd/variables.go b/pkg/mnd/variables.go index 75f78d7f8..f9e02b714 100644 --- a/pkg/mnd/variables.go +++ b/pkg/mnd/variables.go @@ -1,7 +1,7 @@ package mnd import ( - "fmt" + "errors" "os" "strings" @@ -12,19 +12,23 @@ import ( //nolint:gochecknoglobals var ( // IsSynology tells us if this we're running on a Synology. - IsSynology bool - // IsDocker tells us if this is our Docker container. - IsDocker = os.Getpid() == 1 + IsSynology = isSynology() + // IsDocker tells us if this is a Docker container. + IsDocker = isDocker() IsUnstable = strings.HasPrefix(version.Branch, "unstable") DurafmtUnits, _ = durafmt.DefaultUnitsCoder.Decode("year,week,day,hour,min,sec,ms:ms,µs:µs") DurafmtShort, _ = durafmt.DefaultUnitsCoder.Decode("y:y,w:w,d:d,h:h,m:m,s:s,ms:ms,µs:µs") ) // ErrDisabledInstance is returned when a request for a disabled instance is performed. -var ErrDisabledInstance = fmt.Errorf("instance is administratively disabled") +var ErrDisabledInstance = errors.New("instance is administratively disabled") -//nolint:gochecknoinits -func init() { +func isSynology() bool { _, err := os.Stat(Synology) - IsSynology = err == nil + return err == nil +} + +func isDocker() bool { + _, err := os.Stat("/.dockerenv") + return os.Getpid() == 1 || err == nil } diff --git a/pkg/snapshot/mysql.go b/pkg/snapshot/mysql.go index 545ecd4c0..942ff23bc 100644 --- a/pkg/snapshot/mysql.go +++ b/pkg/snapshot/mysql.go @@ -128,11 +128,13 @@ func scanMySQLProcessList(ctx context.Context, dbase *sql.DB) (MySQLProcesses, e if err != nil { mnd.Apps.Add("MySQL&&Errors", 1) return nil, fmt.Errorf("getting processes: %w", err) - } else if err = rows.Err(); err != nil { + } + defer rows.Close() + + if err = rows.Err(); err != nil { mnd.Apps.Add("MySQL&&Errors", 1) return nil, fmt.Errorf("getting processes rows: %w", err) } - defer rows.Close() var list MySQLProcesses @@ -165,58 +167,64 @@ func scanMySQLProcessList(ctx context.Context, dbase *sql.DB) (MySQLProcesses, e } func scanMySQLStatus(ctx context.Context, dbase *sql.DB) (MySQLStatus, error) { - var ( - list = make(MySQLStatus) - likes = []string{ - "Aborted", - "Bytes", - "Connection", - "Created", - "Handler", - "Innodb", - "Key", - "Open", - "Q", - "Slow", - "Sort", - "Uptime", - "Table", - "Threads", + list := make(MySQLStatus) + + for _, name := range []string{ + "Aborted", + "Bytes", + "Connection", + "Created", + "Handler", + "Innodb", + "Key", + "Open", + "Q", + "Slow", + "Sort", + "Uptime", + "Table", + "Threads", + } { + if err := list.processStatus(ctx, dbase, name); err != nil { + return nil, err } - ) + } - for _, name := range likes { - mnd.Apps.Add("MySQL&&Global Status Queries", 1) + return list, nil +} - rows, err := dbase.QueryContext(ctx, "SHOW GLOBAL STATUS LIKE '"+name+"%'") //nolint:execinquery - if err != nil { - mnd.Apps.Add("MySQL&&Errors", 1) - return nil, fmt.Errorf("getting global status: %w", err) - } else if err = rows.Err(); err != nil { - mnd.Apps.Add("MySQL&&Errors", 1) - return nil, fmt.Errorf("getting global status rows: %w", err) - } +func (m MySQLStatus) processStatus(ctx context.Context, dbase *sql.DB, name string) error { + mnd.Apps.Add("MySQL&&Global Status Queries", 1) - for rows.Next() { - var vname, value string + rows, err := dbase.QueryContext(ctx, "SHOW GLOBAL STATUS LIKE '"+name+"%'") + if err != nil { + mnd.Apps.Add("MySQL&&Errors", 1) + return fmt.Errorf("getting global status: %w", err) + } + defer rows.Close() - if err := rows.Scan(&vname, &value); err != nil { - mnd.Apps.Add("MySQL&&Errors", 1) - return nil, fmt.Errorf("scanning global status rows: %w", err) - } + if err = rows.Err(); err != nil { + mnd.Apps.Add("MySQL&&Errors", 1) + return fmt.Errorf("getting global status rows: %w", err) + } - v, err := strconv.ParseFloat(value, mnd.Bits64) - if err != nil || v == 0 { - continue - } + for rows.Next() { + var vname, value string - list[vname] = v + if err := rows.Scan(&vname, &value); err != nil { + mnd.Apps.Add("MySQL&&Errors", 1) + return fmt.Errorf("scanning global status rows: %w", err) } - rows.Close() + v, err := strconv.ParseFloat(value, mnd.Bits64) + if err != nil || v == 0 { + continue + } + + m[vname] = v } - return list, nil + return nil } // Len allows us to sort MySQLProcesses. From 161a77d58d7be79e8f1e6bc4bf25a53f6f5cb234 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Wed, 10 Jul 2024 00:12:53 -0700 Subject: [PATCH 079/192] add now to popups --- pkg/ui/dlgs.go | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/pkg/ui/dlgs.go b/pkg/ui/dlgs.go index 5bef11081..59e0a76f9 100644 --- a/pkg/ui/dlgs.go +++ b/pkg/ui/dlgs.go @@ -2,7 +2,15 @@ package ui -import "github.com/gen2brain/dlgs" +import ( + "time" + + "github.com/gen2brain/dlgs" +) + +func now() string { + return "\nNow: " + time.Now().Format("Mon Jan 2, 2006 @ 15:04:05 MST") +} // Warning wraps dlgs.Warning. func Warning(title, msg string) (bool, error) { @@ -10,7 +18,7 @@ func Warning(title, msg string) (bool, error) { return true, nil } - return dlgs.Warning(title, msg) //nolint:wrapcheck + return dlgs.Warning(title, msg+now()) //nolint:wrapcheck } // Error wraps dlgs.Error. @@ -19,7 +27,7 @@ func Error(title, msg string) (bool, error) { return true, nil } - return dlgs.Error(title, msg) //nolint:wrapcheck + return dlgs.Error(title, msg+now()) //nolint:wrapcheck } // Info wraps dlgs.Info. @@ -28,7 +36,7 @@ func Info(title, msg string) (bool, error) { return true, nil } - return dlgs.Info(title, msg) //nolint:wrapcheck + return dlgs.Info(title, msg+now()) //nolint:wrapcheck } // Entry wraps dlgs.Entry. @@ -37,7 +45,7 @@ func Entry(title, msg, val string) (string, bool, error) { return val, true, nil } - return dlgs.Entry(title, msg, val) //nolint:wrapcheck + return dlgs.Entry(title, msg+now(), val) //nolint:wrapcheck } // Question wraps dlgs.Question. @@ -46,5 +54,5 @@ func Question(title, text string, defaultCancel bool) (bool, error) { return true, nil } - return dlgs.Question(title, text, defaultCancel) //nolint:wrapcheck + return dlgs.Question(title, text+now(), defaultCancel) //nolint:wrapcheck } From 3ff699798478c0206be20cae055f3808bb41008f Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Wed, 10 Jul 2024 00:47:06 -0700 Subject: [PATCH 080/192] do not poll with no api key --- pkg/triggers/crontimer/custom.go | 23 +++++++++++++++-------- pkg/website/website.go | 4 ++-- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/pkg/triggers/crontimer/custom.go b/pkg/triggers/crontimer/custom.go index d1d3e3f87..6073a07fc 100644 --- a/pkg/triggers/crontimer/custom.go +++ b/pkg/triggers/crontimer/custom.go @@ -10,6 +10,7 @@ import ( "github.com/Notifiarr/notifiarr/pkg/triggers/common" "github.com/Notifiarr/notifiarr/pkg/website" "github.com/Notifiarr/notifiarr/pkg/website/clientinfo" + "github.com/hako/durafmt" "golift.io/cnfg" ) @@ -82,14 +83,7 @@ func (c *cmd) create() { ci := clientinfo.Get() // This poller is sorta shoehorned in here for lack of a better place to put it. if ci == nil { - c.Printf("==> Started Notifiarr Poller, have_clientinfo:%v interval:%s", - ci != nil, cnfg.Duration{Duration: pollDur.Round(time.Second)}) - c.Add(&common.Action{ - Name: TrigPollSite, - Fn: c.PollForReload, - D: cnfg.Duration{Duration: pollDur + time.Duration(c.Config.Rand().Intn(randomSeconds))*time.Second}, - }) - + c.startWebsitePoller() return } @@ -123,6 +117,19 @@ func (c *cmd) create() { c.Printf("==> Custom Timers Enabled: %d timers provided", len(ci.Actions.Custom)) } +func (c *cmd) startWebsitePoller() { + if c.ValidAPIKey() != nil { + return // only poll if the api key length is valid. + } + + c.Printf("==> Started Notifiarr Website Poller, interval: %s", durafmt.Parse(pollDur)) + c.Add(&common.Action{ + Name: TrigPollSite, + Fn: c.PollForReload, + D: cnfg.Duration{Duration: pollDur + time.Duration(c.Config.Rand().Intn(randomSeconds))*time.Second}, + }) +} + // PollForReload is only started if the initial connection to the website failed. // This will keep checking until it works, then reload to grab settings and start properly. func (c *cmd) PollForReload(ctx context.Context, input *common.ActionInput) { diff --git a/pkg/website/website.go b/pkg/website/website.go index aea71a281..e1c751574 100644 --- a/pkg/website/website.go +++ b/pkg/website/website.go @@ -24,7 +24,7 @@ type httpClient struct { *http.Client } -func (s *Server) validAPIKey() error { +func (s *Server) ValidAPIKey() error { if len(s.Config.Apps.APIKey) != APIKeyLength { return fmt.Errorf("%w: length must be %d characters", ErrInvalidAPIKey, APIKeyLength) } @@ -326,7 +326,7 @@ func (s *Server) watchSendDataChan(ctx context.Context) { } func (s *Server) sendRequest(ctx context.Context, data *Request) (*Response, time.Duration, error) { - if err := s.validAPIKey(); err != nil { + if err := s.ValidAPIKey(); err != nil { if data.respChan != nil { data.respChan <- &chResponse{ Response: nil, From 24927f5d37b06858a676f8eeed8998b5aad42896 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Wed, 10 Jul 2024 11:15:10 -0700 Subject: [PATCH 081/192] update cnfgfile --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e6fbc78a5..6e5ebea0a 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,7 @@ require ( golang.org/x/time v0.5.0 golift.io/cache v0.0.2 golift.io/cnfg v0.2.3 - golift.io/cnfgfile v0.0.0-20240704165116-48378d0c6c38 + golift.io/cnfgfile v0.0.0-20240710181404-c328b7f27f47 golift.io/datacounter v1.0.4 golift.io/deluge v0.10.1 golift.io/mulery v0.0.8 diff --git a/go.sum b/go.sum index 087294b30..14d44c7d1 100644 --- a/go.sum +++ b/go.sum @@ -426,8 +426,8 @@ golift.io/cache v0.0.2 h1:759rPK+EOy6UX7HkqsesOToSQ3CWN4UN3b5BiehfpeY= golift.io/cache v0.0.2/go.mod h1:wT61rGyiP50Rg243x5UF8dWBEKSr1RpB0GpgIF5kOGE= golift.io/cnfg v0.2.3 h1:cQsC4JS20njJyu5drtGefNmgN7M4HrLaRDNBPLit3pQ= golift.io/cnfg v0.2.3/go.mod h1:T4t8MFa8aZilCdIk1qQrN4mOGaFVPZ/qHQBBMbCIZJ0= -golift.io/cnfgfile v0.0.0-20240704165116-48378d0c6c38 h1:euXQUUWtsi2M+Bf6Do4+yG3YrVj88WyN0WJdv/abeW0= -golift.io/cnfgfile v0.0.0-20240704165116-48378d0c6c38/go.mod h1:zHm9o8SkZ6Mm5DfGahsrEJPsogyR0qItP59s5lJ98/I= +golift.io/cnfgfile v0.0.0-20240710181404-c328b7f27f47 h1:ZZTKukG461j1npgWoIy6PI0RdkH29y3zBtXBPyzNEbg= +golift.io/cnfgfile v0.0.0-20240710181404-c328b7f27f47/go.mod h1:zHm9o8SkZ6Mm5DfGahsrEJPsogyR0qItP59s5lJ98/I= golift.io/datacounter v1.0.4 h1:b2gLQCs8WYRtKjOMG0qM82rF1o0+oKUXB9QH7kjmxZ4= golift.io/datacounter v1.0.4/go.mod h1:79Yf1ucynYvZzVS/hpfrAFt6y/w82FMlOJgh+MBaZvs= golift.io/deluge v0.10.1 h1:wu1GzXsDYzWGnRl4mNEd2IeY0O7+jhYJ4IKBPfDEanM= From 645ca5c5bf43cb3bcdc713173d2067dcaa414c3a Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Wed, 10 Jul 2024 13:10:54 -0700 Subject: [PATCH 082/192] detect console on windows --- Makefile | 3 +++ go.mod | 2 +- go.sum | 4 ++-- pkg/logs/logfile_others.go | 4 ++++ pkg/logs/logfiles_windows.go | 26 ++++++++++++++++++++++++++ pkg/logs/logs.go | 5 +---- 6 files changed, 37 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 7936e267d..26c29d40c 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,9 @@ include /tmp/.metadata.make # Travis CI passes the version in. Local builds get it from the current git tag. ifneq ($(_VERSION),) VERSION:=$(_VERSION) +endif + +ifneq ($(_ITERATION),) ITERATION:=$(_ITERATION) endif diff --git a/go.mod b/go.mod index 6e5ebea0a..0a8872bdd 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,7 @@ require ( golang.org/x/time v0.5.0 golift.io/cache v0.0.2 golift.io/cnfg v0.2.3 - golift.io/cnfgfile v0.0.0-20240710181404-c328b7f27f47 + golift.io/cnfgfile v0.0.0-20240710195711-cc964880efd6 golift.io/datacounter v1.0.4 golift.io/deluge v0.10.1 golift.io/mulery v0.0.8 diff --git a/go.sum b/go.sum index 14d44c7d1..02cce840a 100644 --- a/go.sum +++ b/go.sum @@ -426,8 +426,8 @@ golift.io/cache v0.0.2 h1:759rPK+EOy6UX7HkqsesOToSQ3CWN4UN3b5BiehfpeY= golift.io/cache v0.0.2/go.mod h1:wT61rGyiP50Rg243x5UF8dWBEKSr1RpB0GpgIF5kOGE= golift.io/cnfg v0.2.3 h1:cQsC4JS20njJyu5drtGefNmgN7M4HrLaRDNBPLit3pQ= golift.io/cnfg v0.2.3/go.mod h1:T4t8MFa8aZilCdIk1qQrN4mOGaFVPZ/qHQBBMbCIZJ0= -golift.io/cnfgfile v0.0.0-20240710181404-c328b7f27f47 h1:ZZTKukG461j1npgWoIy6PI0RdkH29y3zBtXBPyzNEbg= -golift.io/cnfgfile v0.0.0-20240710181404-c328b7f27f47/go.mod h1:zHm9o8SkZ6Mm5DfGahsrEJPsogyR0qItP59s5lJ98/I= +golift.io/cnfgfile v0.0.0-20240710195711-cc964880efd6 h1:iTLfwDsKKw+5aEPi2QgFI32C7XiojotH/ZfWD/XMWcY= +golift.io/cnfgfile v0.0.0-20240710195711-cc964880efd6/go.mod h1:zHm9o8SkZ6Mm5DfGahsrEJPsogyR0qItP59s5lJ98/I= golift.io/datacounter v1.0.4 h1:b2gLQCs8WYRtKjOMG0qM82rF1o0+oKUXB9QH7kjmxZ4= golift.io/datacounter v1.0.4/go.mod h1:79Yf1ucynYvZzVS/hpfrAFt6y/w82FMlOJgh+MBaZvs= golift.io/deluge v0.10.1 h1:wu1GzXsDYzWGnRl4mNEd2IeY0O7+jhYJ4IKBPfDEanM= diff --git a/pkg/logs/logfile_others.go b/pkg/logs/logfile_others.go index f2142e632..c9a329094 100644 --- a/pkg/logs/logfile_others.go +++ b/pkg/logs/logfile_others.go @@ -38,3 +38,7 @@ func getFileOwner(fileInfo os.FileInfo) string { return uid + ":" + gid } + +func hasConsoleWindow() bool { + return true +} diff --git a/pkg/logs/logfiles_windows.go b/pkg/logs/logfiles_windows.go index 5abdb8d1c..0c64e26c7 100644 --- a/pkg/logs/logfiles_windows.go +++ b/pkg/logs/logfiles_windows.go @@ -1,9 +1,35 @@ package logs import ( + "debug/pe" "os" ) func getFileOwner(_ os.FileInfo) string { return "" } + +// Sometimes we compile with -H=windowsgui and sometimes without. +// Having this function allows us to detect which, so we can turn on/off console logging. +func hasConsoleWindow() bool { + exe, err := os.Executable() + if err != nil { + return false + } + + file, err := pe.Open(exe) + if err != nil { + return false + } + defer file.Close() + + const IMAGE_SUBSYSTEM_WINDOWS_CUI = 3 + + if header, ok := file.OptionalHeader.(*pe.OptionalHeader64); ok { + return header.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI + } else if header, ok := file.OptionalHeader.(*pe.OptionalHeader32); ok { + return header.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI + } + + return false +} diff --git a/pkg/logs/logs.go b/pkg/logs/logs.go index 6da7ee22e..e27bedae6 100644 --- a/pkg/logs/logs.go +++ b/pkg/logs/logs.go @@ -95,10 +95,7 @@ func (l *Logger) SetupLogging(config *LogConfig) { logFiles = config.LogFiles logFileMb = config.LogFileMb l.LogConfig = config - - if mnd.IsWindows { - config.Quiet = true - } + config.Quiet = !hasConsoleWindow() l.setDefaultLogPaths() l.setAppLogPath() From e95dbc0c57903b4617d1d1a677c8cca60b0d0ec1 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Wed, 10 Jul 2024 15:21:20 -0700 Subject: [PATCH 083/192] mac temps --- go.mod | 2 ++ go.sum | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 0a8872bdd..0a096763b 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,8 @@ go 1.22 // pflag and tail are pinned to master. 12/31/2022 +replace github.com/shirou/gopsutil/v4 => github.com/Girbons/gopsutil/v4 v4.0.0-20240708140948-ba82fefdee75 + require ( github.com/BurntSushi/toml v1.4.0 github.com/akavel/rsrc v0.10.2 diff --git a/go.sum b/go.sum index 02cce840a..6fae1225d 100644 --- a/go.sum +++ b/go.sum @@ -21,6 +21,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/Girbons/gopsutil/v4 v4.0.0-20240708140948-ba82fefdee75 h1:lz2b9BI2CaVAsIAfc3jD7ip0hyIwrngEKs2vR4YWlp0= +github.com/Girbons/gopsutil/v4 v4.0.0-20240708140948-ba82fefdee75/go.mod h1:aoebb2vxetJ/yIDZISmduFvVNPHqXQ9SEJwRXxkf0RA= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= @@ -228,8 +230,6 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk= -github.com/shirou/gopsutil/v4 v4.24.6 h1:9qqCSYF2pgOU+t+NgJtp7Co5+5mHF/HyKBUckySQL64= -github.com/shirou/gopsutil/v4 v4.24.6/go.mod h1:aoebb2vxetJ/yIDZISmduFvVNPHqXQ9SEJwRXxkf0RA= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= From 639fd22062d5556c6b7fe8acb2c8a20011bd7047 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Wed, 10 Jul 2024 17:43:49 -0700 Subject: [PATCH 084/192] fixes --- pkg/logs/logfiles_windows.go | 6 +++--- pkg/logs/logs.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/logs/logfiles_windows.go b/pkg/logs/logfiles_windows.go index 0c64e26c7..d25a2141f 100644 --- a/pkg/logs/logfiles_windows.go +++ b/pkg/logs/logfiles_windows.go @@ -23,12 +23,12 @@ func hasConsoleWindow() bool { } defer file.Close() - const IMAGE_SUBSYSTEM_WINDOWS_CUI = 3 + const windowsTerminal = 3 if header, ok := file.OptionalHeader.(*pe.OptionalHeader64); ok { - return header.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI + return header.Subsystem == windowsTerminal } else if header, ok := file.OptionalHeader.(*pe.OptionalHeader32); ok { - return header.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI + return header.Subsystem == windowsTerminal } return false diff --git a/pkg/logs/logs.go b/pkg/logs/logs.go index e27bedae6..70648fd5f 100644 --- a/pkg/logs/logs.go +++ b/pkg/logs/logs.go @@ -95,7 +95,7 @@ func (l *Logger) SetupLogging(config *LogConfig) { logFiles = config.LogFiles logFileMb = config.LogFileMb l.LogConfig = config - config.Quiet = !hasConsoleWindow() + config.Quiet = !hasConsoleWindow() || config.Quiet l.setDefaultLogPaths() l.setAppLogPath() From 03a171bab062348452797cdac9a9b6426ea9c543 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 12 Jul 2024 16:13:00 +0000 Subject: [PATCH 085/192] Update module modernc.org/sqlite to v1.30.2 --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index e6fbc78a5..710fb8f74 100644 --- a/go.mod +++ b/go.mod @@ -50,7 +50,7 @@ require ( golift.io/starr v1.0.1-0.20240315164714-247399771c46 golift.io/version v0.0.2 golift.io/xtractr v0.2.2 - modernc.org/sqlite v1.30.1 + modernc.org/sqlite v1.30.2 ) require ( diff --git a/go.sum b/go.sum index 087294b30..334e6278d 100644 --- a/go.sum +++ b/go.sum @@ -522,6 +522,8 @@ modernc.org/sortutil v1.2.0 h1:jQiD3PfS2REGJNzNCMMaLSp/wdMNieTbKX920Cqdgqc= modernc.org/sortutil v1.2.0/go.mod h1:TKU2s7kJMf1AE84OoiGppNHJwvB753OYfNl2WRb++Ss= modernc.org/sqlite v1.30.1 h1:YFhPVfu2iIgUf9kuA1CR7iiHdcEEsI2i+yjRYHscyxk= modernc.org/sqlite v1.30.1/go.mod h1:DUmsiWQDaAvU4abhc/N+djlom/L2o8f7gZ95RCvyoLU= +modernc.org/sqlite v1.30.2 h1:IPVVkhLu5mMVnS1dQgh3h0SAACRWcVk7aoLP9Us3UCk= +modernc.org/sqlite v1.30.2/go.mod h1:DUmsiWQDaAvU4abhc/N+djlom/L2o8f7gZ95RCvyoLU= modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA= modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0= modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= From c38ac503f46423a6e5719c2f15f6dbcbff6b67f1 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Fri, 12 Jul 2024 15:47:53 -0700 Subject: [PATCH 086/192] add a bit more info to startup logs --- pkg/client/init.go | 19 ++++++++++++++----- pkg/client/start.go | 7 ++++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/pkg/client/init.go b/pkg/client/init.go index a60863cb5..161889b87 100644 --- a/pkg/client/init.go +++ b/pkg/client/init.go @@ -7,6 +7,7 @@ package client import ( "context" + "os" "path" "github.com/Notifiarr/notifiarr/pkg/mnd" @@ -42,8 +43,10 @@ func (c *Client) PrintStartupInfo(ctx context.Context, clientInfo *clientinfo.Cl c.Printf("==> Unique Host ID: %s (%s)", hi.HostID, hi.Hostname) } + hostname, _ := os.Hostname() + c.Printf("==> %s <==", mnd.HelpLink) - c.Printf("==> Startup Settings <==") + c.Printf("==> %s Startup Settings <==", hostname) c.printLidarr(&clientInfo.Actions.Apps.Lidarr) c.printProwlarr(&clientInfo.Actions.Apps.Prowlarr) c.printRadarr(&clientInfo.Actions.Apps.Radarr) @@ -83,15 +86,21 @@ func (c *Client) printVersionChangeInfo(ctx context.Context) { c.Errorf("XX> Getting version from database: %v", err) } + currentVersion := version.Version + "-" + version.Revision previousVersion := string(values[clientVersion]) - if previousVersion == version.Version || - version.Version == "" { + + if previousVersion == currentVersion || version.Version == "" { return } - c.Printf("==> Detected application version change! %s => %s", previousVersion, version.Version) + if previousVersion == "" { + hostname, _ := os.Hostname() + c.Printf("==> Detected a new client, %s. Welcome to Notifiarr!", hostname) + } else { + c.Printf("==> Detected application version change! %s => %s", previousVersion, currentVersion) + } - err = c.website.SetState(ctx, clientVersion, []byte(version.Version)) + err = c.website.SetState(ctx, clientVersion, []byte(currentVersion)) if err != nil { c.Errorf("Updating version in database: %v", err) } diff --git a/pkg/client/start.go b/pkg/client/start.go index 99c1c894b..00b28c4d6 100644 --- a/pkg/client/start.go +++ b/pkg/client/start.go @@ -151,9 +151,10 @@ func (c *Client) start(ctx context.Context) error { //nolint:cyclop } c.Logger.SetupLogging(c.Config.LogConfig) - c.Printf(" %s %s v%s-%s Starting! [PID: %v] %s", - mnd.TodaysEmoji(), c.Flags.Name(), version.Version, version.Revision, os.Getpid(), - version.Started.Format("Monday, January 2, 2006 @ 3:04:05 PM MST -0700")) + c.Printf(" %s %s v%s-%s Starting! [PID: %v, UID: %d, GID: %d] %s", + mnd.TodaysEmoji(), mnd.Title, version.Version, version.Revision, + os.Getpid(), os.Getuid(), os.Getgid(), + version.Started.Format("Mon, Jan 2, 2006 @ 3:04:05 PM MST -0700")) c.Printf("==> %s", msg) c.printUpdateMessage() From d22d4eeb6f4a1c05869319fb7c56e9056a1e6059 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 13 Jul 2024 03:51:41 +0000 Subject: [PATCH 087/192] Update golift.io/cnfgfile digest to a5436d8 --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index e6fbc78a5..b3ca2d474 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,7 @@ require ( golang.org/x/time v0.5.0 golift.io/cache v0.0.2 golift.io/cnfg v0.2.3 - golift.io/cnfgfile v0.0.0-20240704165116-48378d0c6c38 + golift.io/cnfgfile v0.0.0-20240713024420-a5436d84eb48 golift.io/datacounter v1.0.4 golift.io/deluge v0.10.1 golift.io/mulery v0.0.8 diff --git a/go.sum b/go.sum index 087294b30..2f147aff9 100644 --- a/go.sum +++ b/go.sum @@ -428,6 +428,8 @@ golift.io/cnfg v0.2.3 h1:cQsC4JS20njJyu5drtGefNmgN7M4HrLaRDNBPLit3pQ= golift.io/cnfg v0.2.3/go.mod h1:T4t8MFa8aZilCdIk1qQrN4mOGaFVPZ/qHQBBMbCIZJ0= golift.io/cnfgfile v0.0.0-20240704165116-48378d0c6c38 h1:euXQUUWtsi2M+Bf6Do4+yG3YrVj88WyN0WJdv/abeW0= golift.io/cnfgfile v0.0.0-20240704165116-48378d0c6c38/go.mod h1:zHm9o8SkZ6Mm5DfGahsrEJPsogyR0qItP59s5lJ98/I= +golift.io/cnfgfile v0.0.0-20240713024420-a5436d84eb48 h1:c7cJWRr0cUnFHKtq072esKzhQHKlFA5YRY/hPzQrdko= +golift.io/cnfgfile v0.0.0-20240713024420-a5436d84eb48/go.mod h1:zHm9o8SkZ6Mm5DfGahsrEJPsogyR0qItP59s5lJ98/I= golift.io/datacounter v1.0.4 h1:b2gLQCs8WYRtKjOMG0qM82rF1o0+oKUXB9QH7kjmxZ4= golift.io/datacounter v1.0.4/go.mod h1:79Yf1ucynYvZzVS/hpfrAFt6y/w82FMlOJgh+MBaZvs= golift.io/deluge v0.10.1 h1:wu1GzXsDYzWGnRl4mNEd2IeY0O7+jhYJ4IKBPfDEanM= From 3b7b7d255d3c946c81dfcde7eefdfce8f83279a0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 13 Jul 2024 03:51:45 +0000 Subject: [PATCH 088/192] Update nvidia/cuda Docker tag to v12.5.1 --- init/docker/Dockerfile.cuda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init/docker/Dockerfile.cuda b/init/docker/Dockerfile.cuda index e5c93f3a6..3d4ee09d1 100644 --- a/init/docker/Dockerfile.cuda +++ b/init/docker/Dockerfile.cuda @@ -41,7 +41,7 @@ RUN GOFLAGS="-trimpath -mod=readonly -modcacherw" \ -X \"golift.io/version.Revision=${ITERATION}\" \ -X \"golift.io/version.Version=${VERSION}\"" -FROM nvidia/cuda:12.5.0-base-ubuntu22.04 +FROM nvidia/cuda:12.5.1-base-ubuntu22.04 COPY --from=builder /tmp/notifiarr / # Other tools. From e94dba45ef6f65d9e36fbddc732906fa5e998777 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 15 Jul 2024 20:18:40 +0000 Subject: [PATCH 089/192] Update golift.io/qbit digest to 11930ac --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index e6fbc78a5..1ecb8da6a 100644 --- a/go.mod +++ b/go.mod @@ -45,7 +45,7 @@ require ( golift.io/deluge v0.10.1 golift.io/mulery v0.0.8 golift.io/nzbget v0.1.5 - golift.io/qbit v0.0.0-20240407164833-5de994cfd55e + golift.io/qbit v0.0.0-20240715191156-11930ac2546e golift.io/rotatorr v0.0.0-20230911015553-cd2abbd726c7 golift.io/starr v1.0.1-0.20240315164714-247399771c46 golift.io/version v0.0.2 diff --git a/go.sum b/go.sum index 087294b30..6aee4b3a9 100644 --- a/go.sum +++ b/go.sum @@ -438,6 +438,8 @@ golift.io/nzbget v0.1.5 h1:TE/TPldaLr/Qy5wy+7R4Lvur1SosOpjTLs6BLK3TMrU= golift.io/nzbget v0.1.5/go.mod h1:YYGQsadsgvadzM6qlVBS21gz8DBhfbxexGMndsGelj8= golift.io/qbit v0.0.0-20240407164833-5de994cfd55e h1:MUKqgMVV3RuXrWXQoDUD2sqWX6kAL3qHa/7nZpL5mGc= golift.io/qbit v0.0.0-20240407164833-5de994cfd55e/go.mod h1:8fUXWdcWtuqnfJg/Z9yWbrOxovyhH0V9jE0eK7pFffA= +golift.io/qbit v0.0.0-20240715191156-11930ac2546e h1:JtgHLTF8YPH9fuyHxUYvteJMKyDtxCIbTA9KkbtwsgI= +golift.io/qbit v0.0.0-20240715191156-11930ac2546e/go.mod h1:rW0J8ruEeqTiICfWSk54gja8WLqUjNkbcsFN3wVdO94= golift.io/rotatorr v0.0.0-20230911015553-cd2abbd726c7 h1:8reg8mRdLxCz168FaGPf/kVxmDRDc92/Dhub54trdOc= golift.io/rotatorr v0.0.0-20230911015553-cd2abbd726c7/go.mod h1:59bC4ue06MetIY4iiHu3PCqVbzW0leGoCONZhH8dPZ8= golift.io/starr v1.0.1-0.20240315164714-247399771c46 h1:RpNfYz8V2EZGF52U+RpurYDKFMpQYXW6VxIOVlHBbr0= From 13846500d0fac1c5f4deb86d702ab86bd91cce19 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Tue, 16 Jul 2024 23:12:52 -0700 Subject: [PATCH 090/192] lint --- pkg/client/start.go | 23 +++++++++++++---------- pkg/client/tray.go | 7 +++---- pkg/client/webserver.go | 3 +-- pkg/configfile/config.go | 3 +++ 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/pkg/client/start.go b/pkg/client/start.go index 00b28c4d6..4e7488b4f 100644 --- a/pkg/client/start.go +++ b/pkg/client/start.go @@ -103,7 +103,7 @@ func Start() error { _, err := fmt.Println(client.Flags.Name() + " " + version.Version + "-" + version.Revision) return err case client.Flags.PSlist: // print process list and exit. - ctx, cancel := context.WithTimeout(ctx, time.Minute) + ctx, cancel := context.WithTimeout(ctx, mnd.DefaultTimeout) defer cancel() return printProcessList(ctx) @@ -113,11 +113,11 @@ func Start() error { case client.Flags.Curl != "": // curl a URL and exit. return curlURL(client.Flags.Curl, client.Flags.Headers) default: - return client.start(ctx) + return client.checkFlags(ctx) } } -func (c *Client) start(ctx context.Context) error { //nolint:cyclop +func (c *Client) checkFlags(ctx context.Context) error { //nolint:cyclop msg, newPassword, err := c.loadConfiguration(ctx) ctx, cancel := context.WithCancel(ctx) @@ -131,14 +131,14 @@ func (c *Client) start(ctx context.Context) error { //nolint:cyclop return fmt.Errorf("cannot reset admin password, got error reading configuration file: %w", err) } - ctx, cancel := context.WithTimeout(ctx, time.Minute) + ctx, cancel := context.WithTimeout(ctx, mnd.DefaultTimeout) defer cancel() return c.resetAdminPassword(ctx) case c.Flags.Write != "" && (err == nil || strings.Contains(err.Error(), "ip:port")): c.Printf("==> %s", msg) - ctx, cancel := context.WithTimeout(ctx, time.Minute) + ctx, cancel := context.WithTimeout(ctx, mnd.DefaultTimeout) defer cancel() return c.forceWriteWithExit(ctx, c.Flags.Write) @@ -148,8 +148,12 @@ func (c *Client) start(ctx context.Context) error { //nolint:cyclop return nil case c.Config.APIKey == "": return fmt.Errorf("%s: %w %s_API_KEY", msg, ErrNilAPIKey, c.Flags.EnvPrefix) + default: + return c.start(ctx, msg, newPassword) } +} +func (c *Client) start(ctx context.Context, msg, newPassword string) error { c.Logger.SetupLogging(c.Config.LogConfig) c.Printf(" %s %s v%s-%s Starting! [PID: %v, UID: %d, GID: %d] %s", mnd.TodaysEmoji(), mnd.Title, version.Version, version.Revision, @@ -174,15 +178,15 @@ func (c *Client) start(ctx context.Context) error { //nolint:cyclop if ui.HasGUI() { // This starts the web server and calls os.Exit() when done. - c.startTray(ctx, cancel, clientInfo) + c.startTray(ctx, clientInfo) return nil } - return c.Exit(ctx, cancel) + return c.Exit(ctx) } func (c *Client) makeNewConfigFile(ctx context.Context, newPassword string) { - ctx, cancel := context.WithTimeout(ctx, time.Minute) + ctx, cancel := context.WithTimeout(ctx, mnd.DefaultTimeout) defer cancel() _, _ = c.Config.Write(ctx, c.Flags.ConfigFile, false) @@ -279,10 +283,9 @@ func (c *Client) triggerConfigReload(event website.EventType, source string) { } // Exit stops the web server and logs our exit messages. Start() calls this. -func (c *Client) Exit(ctx context.Context, cancel context.CancelFunc) error { +func (c *Client) Exit(ctx context.Context) error { defer func() { defer c.CapturePanic() - cancel() c.Print(" ❌ Good bye! Exiting" + mnd.DurationAge(version.Started)) }() diff --git a/pkg/client/tray.go b/pkg/client/tray.go index 17ef090ff..e6aa12fa8 100644 --- a/pkg/client/tray.go +++ b/pkg/client/tray.go @@ -8,7 +8,6 @@ import ( "fmt" "os" "strings" - "time" "github.com/Notifiarr/notifiarr/pkg/bindata" "github.com/Notifiarr/notifiarr/pkg/mnd" @@ -29,7 +28,7 @@ const timerPrefix = "TimErr" var menu = make(map[string]*systray.MenuItem) //nolint:gochecknoglobals // startTray Run()s readyTray to bring up the web server and the GUI app. -func (c *Client) startTray(ctx context.Context, cancel context.CancelFunc, clientInfo *clientinfo.ClientInfo) { +func (c *Client) startTray(ctx context.Context, clientInfo *clientinfo.ClientInfo) { systray.Run(func() { defer os.Exit(0) defer c.CapturePanic() @@ -44,7 +43,7 @@ func (c *Client) startTray(ctx context.Context, cancel context.CancelFunc, clien c.setupMenus(clientInfo) // code that runs on reload, too. // This starts the web server, and waits for reload/exit signals. - if err := c.Exit(ctx, cancel); err != nil { + if err := c.Exit(ctx); err != nil { c.Errorf("Server: %v", err) os.Exit(1) // web server problem } @@ -164,7 +163,7 @@ func (c *Client) configMenu(ctx context.Context) { menu["write"] = conf.AddSubMenuItem("Write", "write config file") menu["write"].Click(func() { - ctx, cancel := context.WithTimeout(ctx, time.Minute) + ctx, cancel := context.WithTimeout(ctx, mnd.DefaultTimeout) defer cancel() c.writeConfigFile(ctx) }) diff --git a/pkg/client/webserver.go b/pkg/client/webserver.go index 992a01eb1..cbe4e56dd 100644 --- a/pkg/client/webserver.go +++ b/pkg/client/webserver.go @@ -9,7 +9,6 @@ import ( "net/http" "os" "path" - "time" "github.com/Notifiarr/notifiarr/pkg/mnd" "github.com/gorilla/mux" @@ -42,7 +41,7 @@ func (c *Client) StartWebServer(ctx context.Context) { c.server = &http.Server{ //nolint: exhaustivestruct Handler: smx, Addr: c.Config.BindAddr, - IdleTimeout: time.Minute, + IdleTimeout: mnd.DefaultTimeout, WriteTimeout: c.Config.Timeout.Duration, ReadTimeout: c.Config.Timeout.Duration, ReadHeaderTimeout: c.Config.Timeout.Duration, diff --git a/pkg/configfile/config.go b/pkg/configfile/config.go index d73ae4232..d00544931 100644 --- a/pkg/configfile/config.go +++ b/pkg/configfile/config.go @@ -315,6 +315,9 @@ func (c *Config) Write(ctx context.Context, file string, encode bool) (string, e } defer newFile.Close() + ctx, cancel := context.WithTimeout(ctx, mnd.DefaultTimeout) + defer cancel() + if c.HostID == "" { c.HostID, _ = host.HostIDWithContext(ctx) } From 41b888cfbdf8877c62fcdc81ffa120c2c3b18410 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Tue, 16 Jul 2024 23:15:13 -0700 Subject: [PATCH 091/192] update starr --- go.mod | 2 +- go.sum | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index f2659f520..8722fefa6 100644 --- a/go.mod +++ b/go.mod @@ -49,7 +49,7 @@ require ( golift.io/nzbget v0.1.5 golift.io/qbit v0.0.0-20240715191156-11930ac2546e golift.io/rotatorr v0.0.0-20230911015553-cd2abbd726c7 - golift.io/starr v1.0.1-0.20240315164714-247399771c46 + golift.io/starr v1.0.1-0.20240717055349-aa3e015cc8a4 golift.io/version v0.0.2 golift.io/xtractr v0.2.2 modernc.org/sqlite v1.30.2 diff --git a/go.sum b/go.sum index 485c29c8b..a14338f41 100644 --- a/go.sum +++ b/go.sum @@ -436,14 +436,12 @@ golift.io/mulery v0.0.8 h1:0D57orumzv9QORLLfTi4ao7uIACSyXkGSze32xLc04Q= golift.io/mulery v0.0.8/go.mod h1:4qn4yK/A4GdSKjl4pKBK0ORVHTF466Zfsy8YI0+9dps= golift.io/nzbget v0.1.5 h1:TE/TPldaLr/Qy5wy+7R4Lvur1SosOpjTLs6BLK3TMrU= golift.io/nzbget v0.1.5/go.mod h1:YYGQsadsgvadzM6qlVBS21gz8DBhfbxexGMndsGelj8= -golift.io/qbit v0.0.0-20240407164833-5de994cfd55e h1:MUKqgMVV3RuXrWXQoDUD2sqWX6kAL3qHa/7nZpL5mGc= -golift.io/qbit v0.0.0-20240407164833-5de994cfd55e/go.mod h1:8fUXWdcWtuqnfJg/Z9yWbrOxovyhH0V9jE0eK7pFffA= golift.io/qbit v0.0.0-20240715191156-11930ac2546e h1:JtgHLTF8YPH9fuyHxUYvteJMKyDtxCIbTA9KkbtwsgI= golift.io/qbit v0.0.0-20240715191156-11930ac2546e/go.mod h1:rW0J8ruEeqTiICfWSk54gja8WLqUjNkbcsFN3wVdO94= golift.io/rotatorr v0.0.0-20230911015553-cd2abbd726c7 h1:8reg8mRdLxCz168FaGPf/kVxmDRDc92/Dhub54trdOc= golift.io/rotatorr v0.0.0-20230911015553-cd2abbd726c7/go.mod h1:59bC4ue06MetIY4iiHu3PCqVbzW0leGoCONZhH8dPZ8= -golift.io/starr v1.0.1-0.20240315164714-247399771c46 h1:RpNfYz8V2EZGF52U+RpurYDKFMpQYXW6VxIOVlHBbr0= -golift.io/starr v1.0.1-0.20240315164714-247399771c46/go.mod h1:XdwHrSBkAbcEfqOOXJGg5QQQ2sE/PVo1PMY/WMhzd8s= +golift.io/starr v1.0.1-0.20240717055349-aa3e015cc8a4 h1:8ijJymuEKA2xvSuRh3/k6G1esCGQxL6RiuFQ4jjN5Kk= +golift.io/starr v1.0.1-0.20240717055349-aa3e015cc8a4/go.mod h1:hoY+g9EudDC7lbpJxdSjfdxfFMeEtU3ko9BKon0qUrs= golift.io/version v0.0.2 h1:i0gXRuSDHKs4O0sVDUg4+vNIuOxYoXhaxspftu2FRTE= golift.io/version v0.0.2/go.mod h1:76aHNz8/Pm7CbuxIsDi97jABL5Zui3f2uZxDm4vB6hU= golift.io/xtractr v0.2.2 h1:MvujxeuX629d1rQs2VJbbcvYMvMmN5SzIkEflU5ryOc= @@ -522,8 +520,6 @@ modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4= modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= modernc.org/sortutil v1.2.0 h1:jQiD3PfS2REGJNzNCMMaLSp/wdMNieTbKX920Cqdgqc= modernc.org/sortutil v1.2.0/go.mod h1:TKU2s7kJMf1AE84OoiGppNHJwvB753OYfNl2WRb++Ss= -modernc.org/sqlite v1.30.1 h1:YFhPVfu2iIgUf9kuA1CR7iiHdcEEsI2i+yjRYHscyxk= -modernc.org/sqlite v1.30.1/go.mod h1:DUmsiWQDaAvU4abhc/N+djlom/L2o8f7gZ95RCvyoLU= modernc.org/sqlite v1.30.2 h1:IPVVkhLu5mMVnS1dQgh3h0SAACRWcVk7aoLP9Us3UCk= modernc.org/sqlite v1.30.2/go.mod h1:DUmsiWQDaAvU4abhc/N+djlom/L2o8f7gZ95RCvyoLU= modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA= From 2177a08e9358490490caad48f52ddb7395e05bc1 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Tue, 16 Jul 2024 23:20:30 -0700 Subject: [PATCH 092/192] oops, breaking change in starr --- pkg/apps/radarr.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/apps/radarr.go b/pkg/apps/radarr.go index bb006e03c..2201dc88d 100644 --- a/pkg/apps/radarr.go +++ b/pkg/apps/radarr.go @@ -980,7 +980,7 @@ func radarrAddImportList(req *http.Request) (int, interface{}) { return apiError(http.StatusBadRequest, "decoding payload", err) } - output, err := getRadarr(req).CreateImportListContext(req.Context(), &ilist) + output, err := getRadarr(req).AddImportListContext(req.Context(), &ilist) if err != nil { return apiError(http.StatusInternalServerError, "creating import list", err) } From 1f128b83553ff59e498a18765d35c9dde4f2b342 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Tue, 16 Jul 2024 23:27:34 -0700 Subject: [PATCH 093/192] missed one --- pkg/client/client_other.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/client/client_other.go b/pkg/client/client_other.go index 31f976db7..0d1614f4f 100644 --- a/pkg/client/client_other.go +++ b/pkg/client/client_other.go @@ -23,9 +23,9 @@ func (f *fakeMenu) Uncheck() {} func (f *fakeMenu) Check() {} func (f *fakeMenu) SetTooltip(interface{}) {} -func (c *Client) printUpdateMessage() {} -func (c *Client) setupMenus(interface{}) {} -func (c *Client) startTray(_, _, _ interface{}) {} +func (c *Client) printUpdateMessage() {} +func (c *Client) setupMenus(interface{}) {} +func (c *Client) startTray(_, _ interface{}) {} func (c *Client) handleAptHook(_ context.Context) error { return fmt.Errorf("this feature is not supported on this platform") //nolint:goerr113 } From 856f2bc8388abf124d7571481af878fa9fdeac3a Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Thu, 18 Jul 2024 11:55:08 -0700 Subject: [PATCH 094/192] remove override --- go.mod | 2 -- go.sum | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 8722fefa6..ff5e56e7d 100644 --- a/go.mod +++ b/go.mod @@ -4,8 +4,6 @@ go 1.22 // pflag and tail are pinned to master. 12/31/2022 -replace github.com/shirou/gopsutil/v4 => github.com/Girbons/gopsutil/v4 v4.0.0-20240708140948-ba82fefdee75 - require ( github.com/BurntSushi/toml v1.4.0 github.com/akavel/rsrc v0.10.2 diff --git a/go.sum b/go.sum index a14338f41..e0f8f010f 100644 --- a/go.sum +++ b/go.sum @@ -21,8 +21,6 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/Girbons/gopsutil/v4 v4.0.0-20240708140948-ba82fefdee75 h1:lz2b9BI2CaVAsIAfc3jD7ip0hyIwrngEKs2vR4YWlp0= -github.com/Girbons/gopsutil/v4 v4.0.0-20240708140948-ba82fefdee75/go.mod h1:aoebb2vxetJ/yIDZISmduFvVNPHqXQ9SEJwRXxkf0RA= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= @@ -230,6 +228,8 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk= +github.com/shirou/gopsutil/v4 v4.24.6 h1:9qqCSYF2pgOU+t+NgJtp7Co5+5mHF/HyKBUckySQL64= +github.com/shirou/gopsutil/v4 v4.24.6/go.mod h1:aoebb2vxetJ/yIDZISmduFvVNPHqXQ9SEJwRXxkf0RA= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= From 73b6a4d9b127f718b268dcf924f2234919e134a3 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Thu, 18 Jul 2024 15:43:35 -0700 Subject: [PATCH 095/192] add service/list endpoint, add upcheck interval --- pkg/client/handlers.go | 1 + pkg/services/config.go | 4 ++ pkg/services/services.go | 31 +++++++++++++++ pkg/triggers/common/triggers.go | 9 +++++ pkg/triggers/crontimer/custom.go | 58 ++++++++++++++++++++++++----- pkg/triggers/filewatch/filewatch.go | 6 ++- pkg/triggers/triggers.go | 17 ++------- pkg/website/website_routes.go | 1 + 8 files changed, 104 insertions(+), 23 deletions(-) diff --git a/pkg/client/handlers.go b/pkg/client/handlers.go index 3fefcc68c..d1cf4f4fc 100644 --- a/pkg/client/handlers.go +++ b/pkg/client/handlers.go @@ -97,6 +97,7 @@ func (c *Client) httpAPIHandlers() { c.Config.HandleAPIpath("", "version/{app}/{instance:[0-9]+}", c.clientinfo.VersionHandlerInstance, "GET", "HEAD") c.Config.HandleAPIpath("", "trigger/{trigger:[0-9a-z-]+}", c.triggers.APIHandler, "GET", "POST") c.Config.HandleAPIpath("", "trigger/{trigger:[0-9a-z-]+}/{content}", c.triggers.APIHandler, "GET", "POST") + c.Config.HandleAPIpath("", "services/{action}", c.Config.Services.APIHandler, "GET") c.Config.HandleAPIpath("", "triggers", c.triggers.HandleGetTriggers, "GET") c.Config.HandleAPIpath("", "ping", c.handleInstancePing, "GET") c.Config.HandleAPIpath("", "ping/{app:[a-z,]+}", c.handleInstancePing, "GET") diff --git a/pkg/services/config.go b/pkg/services/config.go index 2f3ba0d0f..76ecb7d4a 100644 --- a/pkg/services/config.go +++ b/pkg/services/config.go @@ -143,3 +143,7 @@ func (o *Output) String() string { func (o *Output) MarshalJSON() ([]byte, error) { return json.Marshal(o.str) //nolint:wrapcheck // do not unescape it. } + +func (o *Output) UnmarshalJSON(input []byte) error { + return json.Unmarshal(input, &o.str) //nolint:wrapcheck +} diff --git a/pkg/services/services.go b/pkg/services/services.go index 79367ecf7..af5829c73 100644 --- a/pkg/services/services.go +++ b/pkg/services/services.go @@ -6,12 +6,14 @@ package services import ( "context" "encoding/json" + "net/http" "strings" "time" "github.com/Notifiarr/notifiarr/pkg/logs" "github.com/Notifiarr/notifiarr/pkg/mnd" "github.com/Notifiarr/notifiarr/pkg/website" + "github.com/gorilla/mux" ) func (c *Config) Setup(services []*Service) error { @@ -260,3 +262,32 @@ func (c *Config) Stop() { func (c *Config) SvcCount() int { return len(c.services) } + +// APIHandler is passed into the webserver so services can be accessed by the API. +func (c *Config) APIHandler(req *http.Request) (int, any) { + return c.handleTrigger(req, website.EventAPI) +} + +func (c *Config) handleTrigger(req *http.Request, event website.EventType) (int, any) { + action := mux.Vars(req)["action"] + c.Debugf("[%s requested] Incoming Service Action: %s (%s)", event, action) + + switch action { + case "list": + return c.returnServiceList() + default: + return http.StatusBadRequest, "unknown action: " + action + } +} + +// @Description Returns a list of service check results. +// @Summary Get service check results +// @Tags Triggers +// @Produce json +// @Success 200 {object} apps.Respond.apiResponse{message=[]CheckResult} "list check results" +// @Failure 404 {object} string "bad token or api key" +// @Router /api/services/list [get] +// @Security ApiKeyAuth +func (c *Config) returnServiceList() (int, any) { + return http.StatusOK, c.GetResults() +} diff --git a/pkg/triggers/common/triggers.go b/pkg/triggers/common/triggers.go index e9c924cd9..d1954f928 100644 --- a/pkg/triggers/common/triggers.go +++ b/pkg/triggers/common/triggers.go @@ -37,6 +37,15 @@ type Config struct { rand *rand.Rand } +type Create interface { + Create() +} + +type Run interface { + Run(context.Context) + Stop() +} + // SetReloadCh is used to set the reload channel for triggers. // This is an exported method because the channel is not always // available when triggers are initialized. diff --git a/pkg/triggers/crontimer/custom.go b/pkg/triggers/crontimer/custom.go index 6073a07fc..bc8e537d6 100644 --- a/pkg/triggers/crontimer/custom.go +++ b/pkg/triggers/crontimer/custom.go @@ -15,14 +15,21 @@ import ( ) // TrigPollSite is our site polling trigger identifier. -const TrigPollSite common.TriggerName = "Polling Notifiarr for new settings." +const ( + TrigPollSite common.TriggerName = "Polling Notifiarr for new settings." + TrigUpCheck common.TriggerName = "Telling Notifiarr website we are still up!" +) const ( // How often to poll the website for changes. // This only fires when: - // 1. the cliet isn't reachable from the website. + // 1. the client isn't reachable from the website. // 2. the client didn't get a valid response to clientInfo. - pollDur = 4 * time.Minute + pollDur = 4 * time.Minute + // This just tells the website the client is up. + upCheckDur = 14*time.Minute + 57*time.Second + // How long to be up before sending first up check. + checkWait = 2 * time.Minute randomMilliseconds = 5000 randomSeconds = 30 ) @@ -79,6 +86,20 @@ func (a *Action) Create() { a.cmd.create() } +// Stop satisifies an interface. +func (a *Action) Stop() {} + +// Verify the interfaces are satisfied. +var ( + _ = common.Run(&Action{nil}) + _ = common.Create(&Action{nil}) +) + +// Run files after create to take some immediate action. +func (a *Action) Run(ctx context.Context) { + a.cmd.PollUpCheck(ctx, &common.ActionInput{Type: website.EventStart}) +} + func (c *cmd) create() { ci := clientinfo.Get() // This poller is sorta shoehorned in here for lack of a better place to put it. @@ -87,6 +108,13 @@ func (c *cmd) create() { return } + c.Printf("==> Started Notifiarr Website Up-Checker, interval: %s", durafmt.Parse(upCheckDur)) + c.Add(&common.Action{ + Name: TrigUpCheck, + Fn: c.PollUpCheck, + D: cnfg.Duration{Duration: upCheckDur}, + }) + for _, custom := range ci.Actions.Custom { timer := &Timer{ CronConfig: custom, @@ -95,13 +123,10 @@ func (c *cmd) create() { } custom.URI = "/" + strings.TrimPrefix(custom.URI, "/") - var randomTime time.Duration - if custom.Interval.Duration < time.Minute { - c.Errorf("Website provided custom cron interval under 1 minute. Ignored! Interval: %s Name: %s, URI: %s", + c.Errorf("Website provided custom cron interval under 1 minute. Interval: %s Name: %s, URI: %s", custom.Interval, custom.Name, custom.URI) - } else { - randomTime = time.Duration(c.Config.Rand().Intn(randomMilliseconds)) * time.Millisecond + custom.Interval.Duration = time.Minute } c.list = append(c.list, timer) @@ -110,7 +135,7 @@ func (c *cmd) create() { Name: common.TriggerName(fmt.Sprintf("Running Custom Cron Timer '%s'", custom.Name)), Fn: timer.run, C: timer.ch, - D: cnfg.Duration{Duration: custom.Interval.Duration + randomTime}, + D: cnfg.Duration{Duration: custom.Interval.Duration}, }) } @@ -130,6 +155,21 @@ func (c *cmd) startWebsitePoller() { }) } +func (c *cmd) PollUpCheck(ctx context.Context, input *common.ActionInput) { + _, err := c.GetData(&website.Request{ + Route: website.ClientRoute, + Event: website.EventCheck, + Payload: c.CIC.Info(ctx, true), // true avoids polling tautulli. + LogPayload: true, + ErrorsOnly: true, + LogMsg: string(TrigUpCheck), + }) + if err != nil { + c.Errorf("[%s requested] Polling Notifiarr: %v", input.Type, err) + return + } +} + // PollForReload is only started if the initial connection to the website failed. // This will keep checking until it works, then reload to grab settings and start properly. func (c *cmd) PollForReload(ctx context.Context, input *common.ActionInput) { diff --git a/pkg/triggers/filewatch/filewatch.go b/pkg/triggers/filewatch/filewatch.go index 64d003af3..8e22b61d8 100644 --- a/pkg/triggers/filewatch/filewatch.go +++ b/pkg/triggers/filewatch/filewatch.go @@ -1,6 +1,7 @@ package filewatch import ( + "context" "fmt" "io" "path/filepath" @@ -118,8 +119,11 @@ func checkIgnored(ignored []string) ignored { return output } +// Verify the interfaces are satisfied. +var _ = common.Run(&Action{nil}) + // Run compiles any regexp's and opens a tail -f on provided watch files. -func (a *Action) Run() { +func (a *Action) Run(_ context.Context) { a.cmd.run() } diff --git a/pkg/triggers/triggers.go b/pkg/triggers/triggers.go index 1c83b2184..4548bedc2 100644 --- a/pkg/triggers/triggers.go +++ b/pkg/triggers/triggers.go @@ -94,15 +94,6 @@ func New(config *Config) *Actions { // These methods use reflection so they never really need to be updated. // They execute all Create(), Run() and Stop() procedures defined in our Actions. -type create interface { - Create() -} - -type run interface { - Run() - Stop() -} - // Start creates all the triggers and runs the timers. func (a *Actions) Start(ctx context.Context, reloadCh chan os.Signal) { a.Timers.SetReloadCh(reloadCh) @@ -115,12 +106,12 @@ func (a *Actions) Start(ctx context.Context, reloadCh chan os.Signal) { } // A panic here means you screwed up the code somewhere else. - if action, ok := actions.Field(i).Interface().(create); ok { + if action, ok := actions.Field(i).Interface().(common.Create); ok { action.Create() } // No 'else if' so you can have both if you need them. - if action, ok := actions.Field(i).Interface().(run); ok { - action.Run() + if action, ok := actions.Field(i).Interface().(common.Run); ok { + action.Run(ctx) } } } @@ -136,7 +127,7 @@ func (a *Actions) Stop(event website.EventType) { continue } - if action, ok := actions.Field(i).Interface().(run); ok { + if action, ok := actions.Field(i).Interface().(common.Run); ok { action.Stop() } } diff --git a/pkg/website/website_routes.go b/pkg/website/website_routes.go index e807a0b6b..3c2b95867 100644 --- a/pkg/website/website_routes.go +++ b/pkg/website/website_routes.go @@ -27,6 +27,7 @@ const ( EventMovie EventType = "movie" EventEpisode EventType = "episode" EventPoll EventType = "poll" + EventCheck EventType = "upcheck" EventSignal EventType = "signal" EventFile EventType = "file" EventSet EventType = "setStates" From 0e1354a63eb3b6fa541e9475a7a4f93993c255a2 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Thu, 18 Jul 2024 18:05:54 -0700 Subject: [PATCH 096/192] remove bindata module --- Makefile | 8 +++---- init/docker/Dockerfile.alpine | 3 +-- init/docker/Dockerfile.cuda | 3 +-- init/docker/Dockerfile.scratch | 3 +-- pkg/bindata/README.md | 14 +---------- pkg/bindata/docs/generate.go | 2 +- pkg/bindata/generate.go | 9 ------- pkg/bindata/tools.go | 2 -- pkg/client/cli.go | 3 ++- pkg/client/handlers.go | 2 +- pkg/client/handlers_gui.go | 2 +- pkg/client/html_templates.go | 43 ++++++++++++++++++++++++++-------- pkg/client/tray.go | 2 +- pkg/ui/ui_darwin.go | 2 +- pkg/ui/ui_windows.go | 2 +- 15 files changed, 48 insertions(+), 52 deletions(-) delete mode 100644 pkg/bindata/generate.go diff --git a/Makefile b/Makefile index 26c29d40c..505de7a58 100644 --- a/Makefile +++ b/Makefile @@ -92,7 +92,7 @@ clean: rm -f notifiarr notifiarr.*.{macos,freebsd,linux,exe}{,.gz,.zip} notifiarr.1{,.gz} notifiarr.rb rm -f notifiarr{_,-}*.{deb,rpm,txz} v*.tar.gz.sha256 examples/MANUAL .metadata.make rsrc_*.syso rm -f cmd/notifiarr/README{,.html} README{,.html} ./notifiarr_manual.html rsrc.syso Notifiarr.*.app.zip - rm -f notifiarr.service pkg/bindata/bindata.go pack.temp.dmg notifiarr.conf.example + rm -f notifiarr.service pack.temp.dmg notifiarr.conf.example rm -rf package_build_* release Notifiarr.*.app Notifiarr.app rm -f pkg/bindata/docs/api_docs.go @@ -355,12 +355,10 @@ lint: generate GOOS=freebsd golangci-lint run GOOS=windows golangci-lint run -generate: pkg/bindata/bindata.go pkg/bindata/docs/api_docs.go +generate: pkg/bindata/docs/api_docs.go pkg/bindata/docs/api_docs.go: - go generate ./pkg/bindata/docs -pkg/bindata/bindata.go: find pkg -name .DS\* -delete - go generate ./pkg/bindata/ + go generate ./pkg/bindata/docs ################## ##### Docker ##### diff --git a/init/docker/Dockerfile.alpine b/init/docker/Dockerfile.alpine index 1286232a5..d81d5648d 100644 --- a/init/docker/Dockerfile.alpine +++ b/init/docker/Dockerfile.alpine @@ -12,8 +12,7 @@ COPY main.go go.mod go.sum ./ # Cache all the needed tools. RUN go mod download \ - && go run github.com/kevinburke/go-bindata/v4/go-bindata@latest -v \ - && go run github.com/swaggo/swag/cmd/swag@master -v + && go run github.com/swaggo/swag/cmd/swag@latest -v COPY pkg pkg RUN go generate ./... diff --git a/init/docker/Dockerfile.cuda b/init/docker/Dockerfile.cuda index 3d4ee09d1..1d0fb0f8f 100644 --- a/init/docker/Dockerfile.cuda +++ b/init/docker/Dockerfile.cuda @@ -12,8 +12,7 @@ COPY main.go go.mod go.sum ./ # Cache all the needed tools. RUN go mod download \ - && go run github.com/kevinburke/go-bindata/v4/go-bindata@latest -v \ - && go run github.com/swaggo/swag/cmd/swag@master -v + && go run github.com/swaggo/swag/cmd/swag@latest -v COPY pkg pkg RUN go generate ./... diff --git a/init/docker/Dockerfile.scratch b/init/docker/Dockerfile.scratch index 865f01d28..0f3cb8639 100644 --- a/init/docker/Dockerfile.scratch +++ b/init/docker/Dockerfile.scratch @@ -12,8 +12,7 @@ COPY main.go go.mod go.sum ./ # Cache all the needed tools. RUN go mod download \ - && go run github.com/kevinburke/go-bindata/v4/go-bindata@latest -v \ - && go run github.com/swaggo/swag/cmd/swag@master -v + && go run github.com/swaggo/swag/cmd/swag@latest -v # Cache apt installs. RUN apt update \ diff --git a/pkg/bindata/README.md b/pkg/bindata/README.md index e4e945b92..0e485c96a 100644 --- a/pkg/bindata/README.md +++ b/pkg/bindata/README.md @@ -1,13 +1 @@ -The files in this folder are auto generated from the files/ and templates/ folders. - -- To generate the binary base64 data you need to install `go-bindata`: - -```shell -curl --silent --location --output /usr/local/bin/go-bindata https://github.com/kevinburke/go-bindata/releases/download/v3.22.0/go-bindata-linux-amd64 -chmod 755 /usr/local/bin/go-bindata -make generate -``` - -See: https://github.com/kevinburke/go-bindata - -- **Do not put anything except Go HTML template files in the templates/ directory.** \ No newline at end of file +- **Do not put anything except Go HTML template files in the templates/ directory.** diff --git a/pkg/bindata/docs/generate.go b/pkg/bindata/docs/generate.go index be477b624..fab4d2266 100644 --- a/pkg/bindata/docs/generate.go +++ b/pkg/bindata/docs/generate.go @@ -1,3 +1,3 @@ package docs -//go:generate go run github.com/swaggo/swag/cmd/swag@v1.8.12 i --parseDependency --instanceName api --outputTypes go --parseInternal --dir ../../../ -g main.go --output . +//go:generate go run github.com/swaggo/swag/cmd/swag@latest i --parseDependency --instanceName api --outputTypes go --parseInternal --dir ../../../ -g main.go --output . diff --git a/pkg/bindata/generate.go b/pkg/bindata/generate.go deleted file mode 100644 index bcc54c731..000000000 --- a/pkg/bindata/generate.go +++ /dev/null @@ -1,9 +0,0 @@ -// Package bindata provides the go:generate command to create new base64 binary -// data, as well as the binary data itself, in both formats. That means, you will -// find the _things_ we compress into base64 inside the files/ directory, and you -// will find the base64 files in the bindata.go file. The generate.go file contains -// the command that creates the binary data. -// See: https://github.com/kevinburke/go-bindata or the README.md file. -package bindata - -//go:generate go run github.com/kevinburke/go-bindata/v4/go-bindata@latest -pkg bindata -modtime 1587356420 -o bindata.go files/... templates/... other/... diff --git a/pkg/bindata/tools.go b/pkg/bindata/tools.go index df2dc0655..f6eee02e0 100644 --- a/pkg/bindata/tools.go +++ b/pkg/bindata/tools.go @@ -6,8 +6,6 @@ package bindata import ( // Used to build windows exe metadata. _ "github.com/akavel/rsrc" - // Used to convert static files to internal binary data. - _ "github.com/kevinburke/go-bindata/v4" // Used to create API docs. _ "github.com/swaggo/swag" ) diff --git a/pkg/client/cli.go b/pkg/client/cli.go index da4c2cdc3..3ce9c3218 100644 --- a/pkg/client/cli.go +++ b/pkg/client/cli.go @@ -163,6 +163,7 @@ func printCurlReply(resp *http.Response, body []byte) { // Fortune returns a fortune. func Fortune() string { - fortunes := strings.Split(bindata.MustAssetString("other/fortunes.txt"), "\n%\n") + file, _ := bindata.Files.ReadFile("other/fortunes.txt") + fortunes := strings.Split(string(file), "\n%\n") return fortunes[rand.Intn(len(fortunes))] //nolint:gosec } diff --git a/pkg/client/handlers.go b/pkg/client/handlers.go index 3fefcc68c..1014d9002 100644 --- a/pkg/client/handlers.go +++ b/pkg/client/handlers.go @@ -151,7 +151,7 @@ func (c *Client) slash(response http.ResponseWriter, request *http.Request) { } func (c *Client) favIcon(w http.ResponseWriter, r *http.Request) { //nolint:varnamelen - ico, err := bindata.Asset("files/images/favicon.ico") + ico, err := bindata.Files.ReadFile("files/images/favicon.ico") if err != nil { w.WriteHeader(http.StatusInternalServerError) return diff --git a/pkg/client/handlers_gui.go b/pkg/client/handlers_gui.go index 2713220b7..fcd9dcb91 100644 --- a/pkg/client/handlers_gui.go +++ b/pkg/client/handlers_gui.go @@ -849,7 +849,7 @@ func (c *Client) handleStaticAssets(response http.ResponseWriter, request *http. } func (c *Client) handleInternalAsset(response http.ResponseWriter, request *http.Request) { - data, err := bindata.Asset(request.URL.Path[1:]) + data, err := bindata.Files.ReadFile(request.URL.Path[1:]) if err != nil { http.Error(response, err.Error(), http.StatusNotFound) return diff --git a/pkg/client/html_templates.go b/pkg/client/html_templates.go index 3a28e9fa6..37761a08c 100644 --- a/pkg/client/html_templates.go +++ b/pkg/client/html_templates.go @@ -328,22 +328,45 @@ func since(t time.Time) string { return strings.ReplaceAll(durafmt.Parse(time.Since(t)).LimitFirstN(3).Format(mnd.DurafmtShort), " ", "") } +const templates = "templates/" + +func (c *Client) parseTemplatesDirectory(filePath string) error { + items, err := bindata.Templates.ReadDir(strings.TrimSuffix(filePath, "/")) + if err != nil { + return fmt.Errorf("failed reading internal templates: %w", err) + } + + for _, entry := range items { + if entry.IsDir() { + if err := c.parseTemplatesDirectory(filepath.Join(filePath, entry.Name())); err != nil { + return err + } + + continue + } + + data, err := bindata.Templates.ReadFile(filepath.Join(filePath, entry.Name())) + if err != nil { + return fmt.Errorf("failed reading internal template %s: %w", entry.Name(), err) + } + + filePath = strings.TrimPrefix(filepath.Join(filePath, entry.Name()), templates) + if c.template, err = c.template.New(filePath).Parse(string(data)); err != nil { + return fmt.Errorf("bug parsing internal template: %w", err) + } + } + + return nil +} + // ParseGUITemplates parses the baked-in templates, and overrides them if a template directory is provided. func (c *Client) ParseGUITemplates() error { // Index and 404 do not have template files, but they can be customized. index := "

    " + c.Flags.Name() + `: working

    ` c.template = template.Must(template.New("index.html").Parse(index)).Funcs(c.getFuncMap()) - var err error - - // Parse all our compiled-in templates. - for _, name := range bindata.AssetNames() { - if strings.HasPrefix(name, "templates/") { - trim := strings.TrimPrefix(name, "templates/") - if c.template, err = c.template.New(trim).Parse(bindata.MustAssetString(name)); err != nil { - return fmt.Errorf("bug parsing internal template: %w", err) - } - } + if err := c.parseTemplatesDirectory(templates); err != nil { + return err } if c.Flags.Assets != "" { diff --git a/pkg/client/tray.go b/pkg/client/tray.go index e6aa12fa8..6dbb7892b 100644 --- a/pkg/client/tray.go +++ b/pkg/client/tray.go @@ -33,7 +33,7 @@ func (c *Client) startTray(ctx context.Context, clientInfo *clientinfo.ClientInf defer os.Exit(0) defer c.CapturePanic() - b, _ := bindata.Asset(ui.SystrayIcon) + b, _ := bindata.Files.ReadFile(ui.SystrayIcon) systray.SetTemplateIcon(b, b) systray.SetTooltip(mnd.PrintVersionInfo(c.Flags.Name())) // systray.SetOnClick(c.showMenu) // buggy diff --git a/pkg/ui/ui_darwin.go b/pkg/ui/ui_darwin.go index 7720a63c3..0dab016ec 100644 --- a/pkg/ui/ui_darwin.go +++ b/pkg/ui/ui_darwin.go @@ -66,7 +66,7 @@ func getPNG() string { return try } - data, err := bindata.Asset("files/favicon.png") + data, err := bindata.Files.ReadFile("files/favicon.png") if err != nil { return "" } diff --git a/pkg/ui/ui_windows.go b/pkg/ui/ui_windows.go index 4da34afc0..e08c4be58 100644 --- a/pkg/ui/ui_windows.go +++ b/pkg/ui/ui_windows.go @@ -41,7 +41,7 @@ func getPNG() string { return "" } - data, err := bindata.Asset("files/favicon.png") + data, err := bindata.Files.ReadFile("files/favicon.png") if err != nil { return "" } From 267a09821ea14292bd782480cecaed928f13eeba Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Thu, 18 Jul 2024 18:09:01 -0700 Subject: [PATCH 097/192] add word --- pkg/services/services.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/services/services.go b/pkg/services/services.go index af5829c73..ef0985af3 100644 --- a/pkg/services/services.go +++ b/pkg/services/services.go @@ -276,7 +276,7 @@ func (c *Config) handleTrigger(req *http.Request, event website.EventType) (int, case "list": return c.returnServiceList() default: - return http.StatusBadRequest, "unknown action: " + action + return http.StatusBadRequest, "unknown service action: " + action } } From 62f9353ce9051d2d5b1f810a983151df33de0ea5 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Thu, 18 Jul 2024 18:13:51 -0700 Subject: [PATCH 098/192] missed a file --- pkg/bindata/.gitignore | 1 - pkg/bindata/bindata.go | 13 +++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 pkg/bindata/bindata.go diff --git a/pkg/bindata/.gitignore b/pkg/bindata/.gitignore index 581f91ba5..fff0ee588 100644 --- a/pkg/bindata/.gitignore +++ b/pkg/bindata/.gitignore @@ -1,2 +1 @@ api_docs.go -bindata.go \ No newline at end of file diff --git a/pkg/bindata/bindata.go b/pkg/bindata/bindata.go new file mode 100644 index 000000000..1c9e50ea6 --- /dev/null +++ b/pkg/bindata/bindata.go @@ -0,0 +1,13 @@ +// Package bindata provides file system assets to the running binary. +package bindata + +import "embed" + +var ( + //go:embed files + Files embed.FS + //go:embed templates + Templates embed.FS + //go:embed other/fortunes.txt + Fortunes string +) From c6633efa470d794c852978865438e7b8bc0c5df3 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Thu, 18 Jul 2024 18:43:16 -0700 Subject: [PATCH 099/192] lint --- pkg/client/cli.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/client/cli.go b/pkg/client/cli.go index 3ce9c3218..4ba967d61 100644 --- a/pkg/client/cli.go +++ b/pkg/client/cli.go @@ -165,5 +165,6 @@ func printCurlReply(resp *http.Response, body []byte) { func Fortune() string { file, _ := bindata.Files.ReadFile("other/fortunes.txt") fortunes := strings.Split(string(file), "\n%\n") + return fortunes[rand.Intn(len(fortunes))] //nolint:gosec } From 40c22bc596d615a840b155a7be2db272e2eeca79 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Thu, 18 Jul 2024 18:48:31 -0700 Subject: [PATCH 100/192] lint --- pkg/triggers/common/triggers.go | 2 +- pkg/triggers/crontimer/custom.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/triggers/common/triggers.go b/pkg/triggers/common/triggers.go index d1954f928..2a3c364e0 100644 --- a/pkg/triggers/common/triggers.go +++ b/pkg/triggers/common/triggers.go @@ -42,7 +42,7 @@ type Create interface { } type Run interface { - Run(context.Context) + Run(ctx context.Context) Stop() } diff --git a/pkg/triggers/crontimer/custom.go b/pkg/triggers/crontimer/custom.go index bc8e537d6..c7eb56811 100644 --- a/pkg/triggers/crontimer/custom.go +++ b/pkg/triggers/crontimer/custom.go @@ -126,6 +126,7 @@ func (c *cmd) create() { if custom.Interval.Duration < time.Minute { c.Errorf("Website provided custom cron interval under 1 minute. Interval: %s Name: %s, URI: %s", custom.Interval, custom.Name, custom.URI) + custom.Interval.Duration = time.Minute } From a073ecc12912708d872fc56b9404b3410a33070c Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Thu, 18 Jul 2024 19:00:18 -0700 Subject: [PATCH 101/192] wait before polling --- pkg/triggers/crontimer/custom.go | 5 +++-- pkg/triggers/filewatch/filewatch.go | 8 +++++--- pkg/triggers/triggers.go | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pkg/triggers/crontimer/custom.go b/pkg/triggers/crontimer/custom.go index c7eb56811..b6f8bd53a 100644 --- a/pkg/triggers/crontimer/custom.go +++ b/pkg/triggers/crontimer/custom.go @@ -29,7 +29,7 @@ const ( // This just tells the website the client is up. upCheckDur = 14*time.Minute + 57*time.Second // How long to be up before sending first up check. - checkWait = 2 * time.Minute + checkWait = 1*time.Minute + 23*time.Second randomMilliseconds = 5000 randomSeconds = 30 ) @@ -95,8 +95,9 @@ var ( _ = common.Create(&Action{nil}) ) -// Run files after create to take some immediate action. +// Run fires in a go routine. Wait a minute or two then tell the website we're up. func (a *Action) Run(ctx context.Context) { + time.Sleep(checkWait) a.cmd.PollUpCheck(ctx, &common.ActionInput{Type: website.EventStart}) } diff --git a/pkg/triggers/filewatch/filewatch.go b/pkg/triggers/filewatch/filewatch.go index 8e22b61d8..b371402c9 100644 --- a/pkg/triggers/filewatch/filewatch.go +++ b/pkg/triggers/filewatch/filewatch.go @@ -150,10 +150,12 @@ func (c *cmd) run() { validTails = append(validTails, item) } - if len(validTails) != 0 { - cases, ticker := c.collectFileTails(validTails) - go c.tailFiles(cases, validTails, ticker) + if len(validTails) == 0 { + return } + + cases, ticker := c.collectFileTails(validTails) + c.tailFiles(cases, validTails, ticker) } func (w *WatchFile) setup(logger *logger, ignored ignored) error { diff --git a/pkg/triggers/triggers.go b/pkg/triggers/triggers.go index 4548bedc2..1474e1180 100644 --- a/pkg/triggers/triggers.go +++ b/pkg/triggers/triggers.go @@ -111,7 +111,7 @@ func (a *Actions) Start(ctx context.Context, reloadCh chan os.Signal) { } // No 'else if' so you can have both if you need them. if action, ok := actions.Field(i).Interface().(common.Run); ok { - action.Run(ctx) + go action.Run(ctx) } } } From 46acb4d17704d6df3fa2109140fd1d0f5d4bde63 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Thu, 18 Jul 2024 20:56:27 -0700 Subject: [PATCH 102/192] use correct slash on windows --- pkg/client/html_templates.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/client/html_templates.go b/pkg/client/html_templates.go index 37761a08c..9ed590d2c 100644 --- a/pkg/client/html_templates.go +++ b/pkg/client/html_templates.go @@ -328,29 +328,29 @@ func since(t time.Time) string { return strings.ReplaceAll(durafmt.Parse(time.Since(t)).LimitFirstN(3).Format(mnd.DurafmtShort), " ", "") } -const templates = "templates/" - func (c *Client) parseTemplatesDirectory(filePath string) error { - items, err := bindata.Templates.ReadDir(strings.TrimSuffix(filePath, "/")) + items, err := bindata.Templates.ReadDir(filePath) if err != nil { return fmt.Errorf("failed reading internal templates: %w", err) } for _, entry := range items { - if entry.IsDir() { - if err := c.parseTemplatesDirectory(filepath.Join(filePath, entry.Name())); err != nil { + filePath := path.Join(filePath, entry.Name()) + + if entry.IsDir() { // Recursion. + if err := c.parseTemplatesDirectory(filePath); err != nil { return err } continue } - data, err := bindata.Templates.ReadFile(filepath.Join(filePath, entry.Name())) + data, err := bindata.Templates.ReadFile(filePath) if err != nil { - return fmt.Errorf("failed reading internal template %s: %w", entry.Name(), err) + return fmt.Errorf("failed reading internal template %s: %w", filePath, err) } - filePath = strings.TrimPrefix(filepath.Join(filePath, entry.Name()), templates) + filePath = strings.TrimPrefix(filePath, "templates/") // no leading junk. if c.template, err = c.template.New(filePath).Parse(string(data)); err != nil { return fmt.Errorf("bug parsing internal template: %w", err) } @@ -365,7 +365,7 @@ func (c *Client) ParseGUITemplates() error { index := "

    " + c.Flags.Name() + `: working

    ` c.template = template.Must(template.New("index.html").Parse(index)).Funcs(c.getFuncMap()) - if err := c.parseTemplatesDirectory(templates); err != nil { + if err := c.parseTemplatesDirectory("templates"); err != nil { return err } From e4ed6e7e2933deb5305e73e2d24eea76e1ffbd7d Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Fri, 19 Jul 2024 10:50:12 -0700 Subject: [PATCH 103/192] fix sab bug --- pkg/apps/apppkg/sabnzbd/sabnzbd.go | 13 ++++++++++++- pkg/client/client_windows.go | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/pkg/apps/apppkg/sabnzbd/sabnzbd.go b/pkg/apps/apppkg/sabnzbd/sabnzbd.go index 8f2b7da3b..6a87cc91d 100644 --- a/pkg/apps/apppkg/sabnzbd/sabnzbd.go +++ b/pkg/apps/apppkg/sabnzbd/sabnzbd.go @@ -112,7 +112,18 @@ type HistorySlots struct { ActionLine string `json:"action_line"` Size string `json:"size"` Loaded bool `json:"loaded"` - Retry int `json:"retry"` + Retry Bool `json:"retry"` +} + +// Bool exists because once upon a time sab changed the retry value from bool to int. +// https://github.com/sabnzbd/sabnzbd/issues/2911 +type Bool bool + +func (f *Bool) UnmarshalJSON(b []byte) error { + txt := strings.Trim(string(b), `"`) + *f = Bool(txt == "true" || (txt != "0" && txt != "false")) + + return nil } //nolint:tagliatelle diff --git a/pkg/client/client_windows.go b/pkg/client/client_windows.go index 6d5c20cf8..3f3c53efe 100644 --- a/pkg/client/client_windows.go +++ b/pkg/client/client_windows.go @@ -87,7 +87,7 @@ func (c *Client) startAutoUpdater(ctx context.Context, dur time.Duration) { } ticker := time.NewTicker(dur) - for range ticker.C { // the ticker never exits. + for range ticker.C { // This is a never-ending loop. if err := c.checkAndUpdate(ctx, "automatic"); err != nil { c.Errorf("Auto-Update Failed: %v", err) } From 5ac43a5df39a5282edb16e3ce6308f7b53ccb3d8 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Fri, 19 Jul 2024 11:28:40 -0700 Subject: [PATCH 104/192] dont log these --- pkg/triggers/crontimer/custom.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/triggers/crontimer/custom.go b/pkg/triggers/crontimer/custom.go index b6f8bd53a..ffd83cd3e 100644 --- a/pkg/triggers/crontimer/custom.go +++ b/pkg/triggers/crontimer/custom.go @@ -162,9 +162,8 @@ func (c *cmd) PollUpCheck(ctx context.Context, input *common.ActionInput) { Route: website.ClientRoute, Event: website.EventCheck, Payload: c.CIC.Info(ctx, true), // true avoids polling tautulli. - LogPayload: true, + LogPayload: false, ErrorsOnly: true, - LogMsg: string(TrigUpCheck), }) if err != nil { c.Errorf("[%s requested] Polling Notifiarr: %v", input.Type, err) From 74aeebdcf824eca952282bbbc5a4d55c20b333b7 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Fri, 19 Jul 2024 11:50:39 -0700 Subject: [PATCH 105/192] use master@psutil --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ff5e56e7d..66982843d 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 github.com/mrobinsn/go-rtorrent v1.8.0 github.com/nxadm/tail v1.4.11 - github.com/shirou/gopsutil/v4 v4.24.6 + github.com/shirou/gopsutil/v4 v4.24.7-0.20240719055159-262afcf2e6b1 github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace github.com/stretchr/testify v1.9.0 github.com/swaggo/swag v1.16.3 diff --git a/go.sum b/go.sum index e0f8f010f..70ddfdfc0 100644 --- a/go.sum +++ b/go.sum @@ -228,8 +228,8 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk= -github.com/shirou/gopsutil/v4 v4.24.6 h1:9qqCSYF2pgOU+t+NgJtp7Co5+5mHF/HyKBUckySQL64= -github.com/shirou/gopsutil/v4 v4.24.6/go.mod h1:aoebb2vxetJ/yIDZISmduFvVNPHqXQ9SEJwRXxkf0RA= +github.com/shirou/gopsutil/v4 v4.24.7-0.20240719055159-262afcf2e6b1 h1:33UxpaYMcNRVbqDrS2M5GXN6Qw+LLGnoLsHiHN0EPnY= +github.com/shirou/gopsutil/v4 v4.24.7-0.20240719055159-262afcf2e6b1/go.mod h1:0uW/073rP7FYLOkvxolUQM5rMOLTNmRXnFKafpb71rw= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= From c56f985d47e0b0c09b6e25997b76c18d77a6c669 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Fri, 19 Jul 2024 12:08:02 -0700 Subject: [PATCH 106/192] small adjustments --- pkg/apps/apppkg/sabnzbd/sabnzbd.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/apps/apppkg/sabnzbd/sabnzbd.go b/pkg/apps/apppkg/sabnzbd/sabnzbd.go index 6a87cc91d..5e1edeafc 100644 --- a/pkg/apps/apppkg/sabnzbd/sabnzbd.go +++ b/pkg/apps/apppkg/sabnzbd/sabnzbd.go @@ -1,6 +1,7 @@ package sabnzbd import ( + "bytes" "context" "encoding/json" "fmt" @@ -115,12 +116,12 @@ type HistorySlots struct { Retry Bool `json:"retry"` } -// Bool exists because once upon a time sab changed the retry value from bool to int. +// Bool exists because once upon a time sab changed the retry value from int to bool. // https://github.com/sabnzbd/sabnzbd/issues/2911 type Bool bool func (f *Bool) UnmarshalJSON(b []byte) error { - txt := strings.Trim(string(b), `"`) + txt := string(bytes.Trim(b, `"`)) *f = Bool(txt == "true" || (txt != "0" && txt != "false")) return nil From 36bd0266e1c4c79860af8473aa8848bff2608680 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Fri, 19 Jul 2024 12:11:26 -0700 Subject: [PATCH 107/192] do not hard code debug log file on linux --- init/systemd/notifiarr.service | 1 - 1 file changed, 1 deletion(-) diff --git a/init/systemd/notifiarr.service b/init/systemd/notifiarr.service index c21dd1a3d..440f4b94d 100644 --- a/init/systemd/notifiarr.service +++ b/init/systemd/notifiarr.service @@ -8,7 +8,6 @@ Requires=network.target [Service] Environment=DN_LOG_FILE=/var/log/notifiarr/app.log Environment=DN_HTTP_LOG=/var/log/notifiarr/http.log -Environment=DN_DEBUG_LOG=/var/log/notifiarr/debug.log Environment=DN_SERVICES_LOG_FILE=/var/log/notifiarr/services.log Environment=DN_QUIET=true ExecStart=/usr/bin/notifiarr $DAEMON_OPTS From 4e1ff9b374bb98559d63ccb31be8ddfa9aecc1fb Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Fri, 19 Jul 2024 13:30:03 -0700 Subject: [PATCH 108/192] fix fortunes --- pkg/client/cli.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkg/client/cli.go b/pkg/client/cli.go index 4ba967d61..0c3f32120 100644 --- a/pkg/client/cli.go +++ b/pkg/client/cli.go @@ -163,8 +163,6 @@ func printCurlReply(resp *http.Response, body []byte) { // Fortune returns a fortune. func Fortune() string { - file, _ := bindata.Files.ReadFile("other/fortunes.txt") - fortunes := strings.Split(string(file), "\n%\n") - + fortunes := strings.Split(bindata.Fortunes, "\n%\n") return fortunes[rand.Intn(len(fortunes))] //nolint:gosec } From a95c23c16246a716eda2864b91ba72222f28aafc Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Fri, 19 Jul 2024 14:23:09 -0700 Subject: [PATCH 109/192] do not start service check if no services --- pkg/services/services.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/services/services.go b/pkg/services/services.go index ef0985af3..36801aacd 100644 --- a/pkg/services/services.go +++ b/pkg/services/services.go @@ -58,6 +58,11 @@ func (c *Config) setup(services []*Service) error { // Start begins the service check routines. // Runs Parallel checkers and the check reporter. func (c *Config) Start(ctx context.Context) { + if len(c.services) == 0 { + c.Printf("==> Service Checker Disabled! No services to check.") + return + } + c.stopLock.Lock() defer c.stopLock.Unlock() From 1e176f3cc1cb4b09160a7ce55adbef8e0a86797e Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sat, 20 Jul 2024 18:08:45 -0700 Subject: [PATCH 110/192] Move auto updater to trigger --- main.go | 18 +- pkg/bindata/templates/includes/footer.html | 2 +- pkg/client/client_darwin.go | 15 +- pkg/client/client_linux.go | 6 - pkg/client/client_other.go | 19 +-- pkg/client/client_windows.go | 146 +--------------- pkg/client/start.go | 23 +-- pkg/client/tray.go | 6 +- pkg/client/tray_commands.go | 68 +------- pkg/configfile/config.go | 7 +- pkg/triggers/autoupdate/autoupdate.go | 188 +++++++++++++++++++++ pkg/triggers/autoupdate/update.go | 81 +++++++++ pkg/triggers/common/triggers.go | 19 ++- pkg/triggers/crontimer/custom.go | 36 ++-- pkg/triggers/triggers.go | 10 +- pkg/ui/dlgs.go | 27 +-- pkg/website/website.go | 3 +- 17 files changed, 388 insertions(+), 286 deletions(-) create mode 100644 pkg/triggers/autoupdate/autoupdate.go create mode 100644 pkg/triggers/autoupdate/update.go diff --git a/main.go b/main.go index da5c5db36..510e2baf1 100644 --- a/main.go +++ b/main.go @@ -10,7 +10,7 @@ import ( "github.com/Notifiarr/notifiarr/pkg/ui" ) -// @title Notifiarr Client API Docs +// @title Notifiarr Client API Documentation // @version 1.0 // @description Notifiarr Client monitors local services and sends notifications. // @termsOfService https://notifiarr.com @@ -27,14 +27,16 @@ func main() { log.SetFlags(log.LstdFlags) log.SetPrefix("[ERROR] ") - defer func() { - if r := recover(); r != nil { - log.Printf("Go Panic! %s\n%v\n%s", mnd.BugIssue, r, string(debug.Stack())) - } - }() + defer logPanic() if err := client.Start(); err != nil { - _, _ = ui.Error(mnd.Title, err.Error()) - log.Fatal(err) //nolint:gocritic // defer does not need to run if we have an error. + _, _ = ui.Error(err.Error()) + defer log.Fatal(err) + } +} + +func logPanic() { + if r := recover(); r != nil { + log.Printf("Go Panic! %s\n%v\n%s", mnd.BugIssue, r, string(debug.Stack())) } } diff --git a/pkg/bindata/templates/includes/footer.html b/pkg/bindata/templates/includes/footer.html index 7cbd15c3f..b107cab29 100644 --- a/pkg/bindata/templates/includes/footer.html +++ b/pkg/bindata/templates/includes/footer.html @@ -2,7 +2,7 @@ -