-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.go
33 lines (26 loc) · 887 Bytes
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package tlsmodel
import "strconv"
//ScanResultSorter sorts scan results by server IP and port
type ScanResultSorter []ScanResult
func (k ScanResultSorter) Len() int {
return len(k)
}
func (k ScanResultSorter) Swap(i, j int) {
k[i], k[j] = k[j], k[i]
}
func (k ScanResultSorter) Less(i, j int) bool {
iPort, _ := strconv.Atoi(k[i].Port)
jPort, _ := strconv.Atoi(k[j].Port)
return k[i].Server < k[j].Server || (k[i].Server == k[j].Server && iPort <= jPort)
}
//CipherMetricsSorter sorts scan results by server IP and port
type CipherMetricsSorter []CipherMetrics
func (k CipherMetricsSorter) Len() int {
return len(k)
}
func (k CipherMetricsSorter) Swap(i, j int) {
k[i], k[j] = k[j], k[i]
}
func (k CipherMetricsSorter) Less(i, j int) bool {
return k[i].OverallScore > k[j].OverallScore || (k[i].OverallScore == k[j].OverallScore && k[i].Performance <= k[j].Performance)
}