File tree Expand file tree Collapse file tree 3 files changed +38
-26
lines changed Expand file tree Collapse file tree 3 files changed +38
-26
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import (
13
13
"github.com/knadh/koanf/v2"
14
14
"sigs.k8s.io/yaml"
15
15
16
+ "github.com/nezhahq/agent/pkg/logger"
16
17
"github.com/nezhahq/agent/pkg/util"
17
18
)
18
19
@@ -76,10 +77,19 @@ func (c *AgentConfig) Read(path string) error {
76
77
return err
77
78
}
78
79
80
+ if ! c .DisableAutoUpdate || ! c .DisableForceUpdate {
81
+ if util .IsBelow10 () {
82
+ c .DisableAutoUpdate = true
83
+ c .DisableForceUpdate = true
84
+ logger .Println ("This version of Windows is no longer supported, disabling self-update now" )
85
+ defer saveOnce ()
86
+ }
87
+ }
88
+
79
89
if c .UUID == "" {
80
90
if uuid , err := uuid .GenerateUUID (); err == nil {
81
91
c .UUID = uuid
82
- saveOnce ()
92
+ defer saveOnce ()
83
93
} else {
84
94
return fmt .Errorf ("generate UUID failed: %v" , err )
85
95
}
Original file line number Diff line number Diff line change @@ -9,20 +9,19 @@ import (
9
9
"os"
10
10
"os/exec"
11
11
"path/filepath"
12
- "regexp"
13
12
"runtime"
14
- "strconv"
15
13
16
14
"github.com/UserExistsError/conpty"
17
15
"github.com/artdarek/go-unzip"
18
16
"github.com/iamacarpet/go-winpty"
19
- "github.com/shirou/gopsutil/v4/host"
17
+
18
+ "github.com/nezhahq/agent/pkg/util"
20
19
)
21
20
22
21
var _ IPty = (* winPTY )(nil )
23
22
var _ IPty = (* conPty )(nil )
24
23
25
- var isWin10 = VersionCheck ()
24
+ var isWin10 = ! util . IsBelow10 ()
26
25
27
26
type winPTY struct {
28
27
tty * winpty.WinPTY
@@ -32,27 +31,6 @@ type conPty struct {
32
31
tty * conpty.ConPty
33
32
}
34
33
35
- func VersionCheck () bool {
36
- hi , err := host .Info ()
37
- if err != nil {
38
- return false
39
- }
40
-
41
- re := regexp .MustCompile (`Build (\d+(\.\d+)?)` )
42
- match := re .FindStringSubmatch (hi .KernelVersion )
43
- if len (match ) > 1 {
44
- versionStr := match [1 ]
45
-
46
- version , err := strconv .ParseFloat (versionStr , 64 )
47
- if err != nil {
48
- return false
49
- }
50
-
51
- return version >= 17763
52
- }
53
- return false
54
- }
55
-
56
34
func DownloadDependency () error {
57
35
if isWin10 {
58
36
return nil
Original file line number Diff line number Diff line change @@ -6,10 +6,13 @@ import (
6
6
"net"
7
7
"net/http"
8
8
"os"
9
+ "regexp"
10
+ "strconv"
9
11
"strings"
10
12
"sync"
11
13
12
14
jsoniter "github.com/json-iterator/go"
15
+ "github.com/shirou/gopsutil/v4/host"
13
16
"github.com/shirou/gopsutil/v4/process"
14
17
)
15
18
@@ -147,3 +150,24 @@ func SubUintChecked[T Unsigned](a, b T) T {
147
150
type Unsigned interface {
148
151
~ uint | ~ uint8 | ~ uint16 | ~ uint32 | ~ uint64
149
152
}
153
+
154
+ func IsBelow10 () bool {
155
+ hi , err := host .Info ()
156
+ if err != nil {
157
+ return true
158
+ }
159
+
160
+ re := regexp .MustCompile (`Build (\d+(\.\d+)?)` )
161
+ match := re .FindStringSubmatch (hi .KernelVersion )
162
+ if len (match ) > 1 {
163
+ versionStr := match [1 ]
164
+
165
+ version , err := strconv .ParseFloat (versionStr , 64 )
166
+ if err != nil {
167
+ return true
168
+ }
169
+
170
+ return version < 17763
171
+ }
172
+ return true
173
+ }
You can’t perform that action at this time.
0 commit comments