@@ -22,6 +22,8 @@ type SupportedVersion struct {
22
22
MinorVersions []int
23
23
}
24
24
25
+ var MAJOR_VERSIONS []int
26
+
25
27
var SUPPORTED_VERSIONS map [string ]SupportedVersion = map [string ]SupportedVersion {
26
28
"11" : SupportedVersion {
27
29
FirstRelease : "2018-10-18" ,
@@ -50,7 +52,24 @@ var SUPPORTED_VERSIONS map[string]SupportedVersion = map[string]SupportedVersion
50
52
},
51
53
}
52
54
55
+ func getMajorMinorVersion (serverVersion string ) (string , string ) {
56
+ var minorVersion string
57
+ var majorVersion string
58
+ minorVersion = serverVersion [len (serverVersion )- 2 : len (serverVersion )]
59
+ i , _ := strconv .Atoi (minorVersion )
60
+ minorVersion = strconv .Itoa (i )
61
+ if serverVersion [0 :1 ] == "9" {
62
+ majorVersion = serverVersion [0 :3 ]
63
+ majorVersion = strings .Replace (majorVersion , "0" , "." , 1 )
64
+ } else {
65
+ majorVersion = serverVersion [0 :2 ]
66
+ }
67
+ return majorVersion , minorVersion
68
+ }
69
+
53
70
func A002PrepareVersionInfo () {
71
+ var majorVersions map [int ]bool
72
+ majorVersions = make (map [int ]bool )
54
73
url := VERSION_SOURCE_URL
55
74
log .Dbg ("HTML code of %s ...\n " , url )
56
75
resp , err := http .Get (url )
@@ -81,6 +100,12 @@ func A002PrepareVersionInfo() {
81
100
majorVersion = majorVersion + "."
82
101
}
83
102
majorVersion = majorVersion + ver [1 ]
103
+ intMajorVersion := strings .Replace (majorVersion , "." , "0" , 1 )
104
+ if len (intMajorVersion ) < 3 {
105
+ intMajorVersion = intMajorVersion + "00"
106
+ }
107
+ iMVer , _ := strconv .Atoi (intMajorVersion )
108
+ majorVersions [iMVer ] = true
84
109
minorVersion := ver [2 ]
85
110
ver , ok := SUPPORTED_VERSIONS [majorVersion ]
86
111
if ok {
@@ -92,6 +117,10 @@ func A002PrepareVersionInfo() {
92
117
}
93
118
tokenType = domDocTest .Next ()
94
119
}
120
+ for ver , _ := range majorVersions {
121
+ MAJOR_VERSIONS = append (MAJOR_VERSIONS , ver )
122
+ }
123
+ sort .Ints (MAJOR_VERSIONS )
95
124
}
96
125
97
126
func A002CheckAllVersionsIsSame (report A002Report ,
@@ -101,19 +130,20 @@ func A002CheckAllVersionsIsSame(report A002Report,
101
130
var vers []string
102
131
diff := false
103
132
for host , hostData := range report .Results {
133
+ majorVersion , minorVersion := getMajorMinorVersion (hostData .Data .ServerVersionNum )
104
134
if version == "" {
105
- version = hostData . Data . ServerMajorVer + "." + hostData . Data . ServerMinorVer
135
+ version = majorVersion + "." + minorVersion
106
136
}
107
- if version != (hostData . Data . ServerMajorVer + "." + hostData . Data . ServerMinorVer ) {
137
+ if version != (majorVersion + "." + minorVersion ) {
108
138
diff = true
109
139
}
110
140
hosts = append (hosts , host )
111
- vers = append (vers , hostData . Data . ServerMajorVer + "." + hostData . Data . ServerMinorVer )
141
+ vers = append (vers , majorVersion + "." + minorVersion )
112
142
}
113
143
if diff && len (hosts ) > 1 {
114
144
result .AppendConclusion (english .PluralWord (len (hosts ),
115
145
MSG_NOT_ALL_VERSIONS_SAME_CONCLUSION_1 , MSG_NOT_ALL_VERSIONS_SAME_CONCLUSION_N ),
116
- strings .Join (hosts , ", " ), strings .Join (vers , ", " ))
146
+ strings .Join (hosts , "`, ` " ), strings .Join (getUniques ( vers ) , "`, ` " ))
117
147
result .AppendRecommendation (MSG_NOT_ALL_VERSIONS_SAME_RECOMMENDATION )
118
148
result .P2 = true
119
149
} else {
@@ -125,11 +155,14 @@ func A002CheckAllVersionsIsSame(report A002Report,
125
155
func A002CheckMajorVersions (report A002Report , result checkup.ReportOutcome ) checkup.ReportOutcome {
126
156
var processed map [string ]bool = map [string ]bool {}
127
157
for host , hostData := range report .Results {
128
- if _ , vok := processed [hostData .Data .ServerMajorVer ]; vok {
158
+ majorVersion , _ := getMajorMinorVersion (hostData .Data .ServerVersionNum )
159
+ mjVersion := hostData .Data .ServerVersionNum [0 : len (hostData .Data .ServerVersionNum )- 2 ]
160
+ iMajorVersion , _ := strconv .Atoi (mjVersion )
161
+ if _ , vok := processed [majorVersion ]; vok {
129
162
// version already checked
130
163
continue
131
164
}
132
- ver , ok := SUPPORTED_VERSIONS [hostData . Data . ServerMajorVer ]
165
+ ver , ok := SUPPORTED_VERSIONS [majorVersion ]
133
166
if ! ok {
134
167
result .AppendConclusion (MSG_WRONG_VERSION_CONCLUSION , hostData .Data .Version , host )
135
168
result .AppendRecommendation (MSG_WRONG_VERSION_RECOMMENDATION , host )
@@ -142,20 +175,24 @@ func A002CheckMajorVersions(report A002Report, result checkup.ReportOutcome) che
142
175
today := time .Now ()
143
176
if today .After (to ) {
144
177
// already not supported versions
145
- result .AppendConclusion (MSG_NOT_SUPPORTED_VERSION_CONCLUSION , hostData . Data . ServerMajorVer , ver .FinalRelease )
146
- result .AppendRecommendation (MSG_NOT_SUPPORTED_VERSION_RECOMMENDATION , hostData . Data . ServerMajorVer )
178
+ result .AppendConclusion (MSG_NOT_SUPPORTED_VERSION_CONCLUSION , majorVersion , ver .FinalRelease )
179
+ result .AppendRecommendation (MSG_NOT_SUPPORTED_VERSION_RECOMMENDATION , majorVersion )
147
180
result .P1 = true
148
181
}
149
182
if today .After (yearBeforeFinal ) && today .Before (to ) {
150
183
// supported last year
151
- result .AppendConclusion (MSG_LAST_YEAR_SUPPORTED_VERSION_CONCLUSION , hostData . Data . ServerMajorVer , ver .FinalRelease )
184
+ result .AppendConclusion (MSG_LAST_YEAR_SUPPORTED_VERSION_CONCLUSION , majorVersion , ver .FinalRelease )
152
185
result .P2 = true
153
186
}
154
187
if today .After (from ) && today .After (to ) {
155
188
// ok
156
- result .AppendConclusion (MSG_SUPPORTED_VERSION_CONCLUSION , hostData .Data .ServerMajorVer , ver .FinalRelease )
189
+ result .AppendConclusion (MSG_SUPPORTED_VERSION_CONCLUSION , majorVersion , ver .FinalRelease )
190
+ }
191
+ if MAJOR_VERSIONS [len (MAJOR_VERSIONS )- 1 ] > iMajorVersion {
192
+ result .AppendRecommendation (MSG_NOT_LAST_MAJOR_VERSION_CONCLUSION , float32 (MAJOR_VERSIONS [len (MAJOR_VERSIONS )- 1 ])/ 100.0 )
193
+ result .P3 = true
157
194
}
158
- processed [hostData . Data . ServerMajorVer ] = true
195
+ processed [majorVersion ] = true
159
196
}
160
197
return result
161
198
}
@@ -166,35 +203,36 @@ func A002CheckMinorVersions(report A002Report, result checkup.ReportOutcome) che
166
203
var updateVersions []string
167
204
var processed map [string ]bool = map [string ]bool {}
168
205
for host , hostData := range report .Results {
169
- if _ , vok := processed [hostData .Data .ServerMinorVer ]; vok {
206
+ majorVersion , minorVersion := getMajorMinorVersion (hostData .Data .ServerVersionNum )
207
+ if _ , vok := processed [minorVersion ]; vok {
170
208
// version already checked
171
209
continue
172
210
}
173
- ver , ok := SUPPORTED_VERSIONS [hostData . Data . ServerMajorVer ]
211
+ ver , ok := SUPPORTED_VERSIONS [majorVersion ]
174
212
if ! ok {
175
- result .AppendConclusion (MSG_NOT_SUPPORTED_VERSION_CONCLUSION , hostData . Data . ServerMajorVer , ver .FinalRelease )
176
- result .AppendRecommendation (MSG_NOT_SUPPORTED_VERSION_RECOMMENDATION , hostData . Data . ServerMajorVer )
213
+ result .AppendConclusion (MSG_NOT_SUPPORTED_VERSION_CONCLUSION , majorVersion , ver .FinalRelease )
214
+ result .AppendRecommendation (MSG_NOT_SUPPORTED_VERSION_RECOMMENDATION , majorVersion )
177
215
result .P1 = true
178
216
continue
179
217
}
180
218
sort .Ints (ver .MinorVersions )
181
219
lastVersion := ver .MinorVersions [len (ver .MinorVersions )- 1 ]
182
- minorVersion , _ := strconv .Atoi (hostData . Data . ServerMinorVer )
183
- if minorVersion >= lastVersion {
220
+ intMinorVersion , _ := strconv .Atoi (minorVersion )
221
+ if intMinorVersion >= lastVersion {
184
222
result .AppendConclusion (MSG_LAST_MINOR_VERSION_CONCLUSION ,
185
- hostData . Data . ServerMajorVer + "." + hostData . Data . ServerMinorVer , hostData . Data . ServerMajorVer )
186
- processed [hostData . Data . ServerMinorVer ] = true
223
+ majorVersion + "." + minorVersion , majorVersion )
224
+ processed [minorVersion ] = true
187
225
} else {
188
226
updateHosts = append (updateHosts , host )
189
- curVersions = append (curVersions , hostData . Data . ServerMajorVer + "." + hostData . Data . ServerMinorVer )
190
- updateVersions = append (updateVersions , hostData . Data . ServerMajorVer + "." + strconv .Itoa (lastVersion ))
227
+ curVersions = append (curVersions , majorVersion + "." + minorVersion )
228
+ updateVersions = append (updateVersions , majorVersion + "." + strconv .Itoa (lastVersion ))
191
229
}
192
230
}
193
231
curVersions = getUniques (curVersions )
194
232
if len (curVersions ) > 0 {
195
233
result .AppendConclusion (english .PluralWord (len (curVersions ),
196
234
MSG_NOT_LAST_MINOR_VERSION_CONCLUSION_1 , MSG_NOT_LAST_MINOR_VERSION_CONCLUSION_N ),
197
- strings .Join (curVersions , ", " ), updateVersions [0 ])
235
+ strings .Join (curVersions , "`, ` " ), updateVersions [0 ])
198
236
result .AppendRecommendation (MSG_NOT_LAST_MINOR_VERSION_RECOMMENDATION , updateVersions [0 ])
199
237
result .P2 = true
200
238
}
@@ -238,7 +276,11 @@ func A002PreprocessReportData(data map[string]interface{}) {
238
276
if len (result .Recommendations ) == 0 {
239
277
result .AppendRecommendation (MSG_NO_RECOMMENDATION )
240
278
} else {
241
- result .AppendRecommendation (MSG_GENERAL_RECOMMENDATION )
279
+ if ! result .P3 {
280
+ result .AppendRecommendation (MSG_GENERAL_RECOMMENDATION_1 )
281
+ } else {
282
+ result .AppendRecommendation (MSG_GENERAL_RECOMMENDATION_1 + MSG_GENERAL_RECOMMENDATION_2 )
283
+ }
242
284
}
243
285
// update data and file
244
286
checkup .SaveConclusionsRecommendations (data , result )
0 commit comments