drakkan / sftpgo

@@ -39,14 +39,14 @@
Loading
39 39
}
40 40
41 41
// GetHosts returns hosts that are banned or for which some violations have been detected
42 -
func (d *memoryDefender) GetHosts() ([]*dataprovider.DefenderEntry, error) {
42 +
func (d *memoryDefender) GetHosts() ([]dataprovider.DefenderEntry, error) {
43 43
	d.RLock()
44 44
	defer d.RUnlock()
45 45
46 -
	var result []*dataprovider.DefenderEntry
46 +
	var result []dataprovider.DefenderEntry
47 47
	for k, v := range d.banned {
48 48
		if v.After(time.Now()) {
49 -
			result = append(result, &dataprovider.DefenderEntry{
49 +
			result = append(result, dataprovider.DefenderEntry{
50 50
				IP:      k,
51 51
				BanTime: v,
52 52
			})
@@ -60,7 +60,7 @@
Loading
60 60
			}
61 61
		}
62 62
		if score > 0 {
63 -
			result = append(result, &dataprovider.DefenderEntry{
63 +
			result = append(result, dataprovider.DefenderEntry{
64 64
				IP:    k,
65 65
				Score: score,
66 66
			})
@@ -71,13 +71,13 @@
Loading
71 71
}
72 72
73 73
// GetHost returns a defender host by ip, if any
74 -
func (d *memoryDefender) GetHost(ip string) (*dataprovider.DefenderEntry, error) {
74 +
func (d *memoryDefender) GetHost(ip string) (dataprovider.DefenderEntry, error) {
75 75
	d.RLock()
76 76
	defer d.RUnlock()
77 77
78 78
	if banTime, ok := d.banned[ip]; ok {
79 79
		if banTime.After(time.Now()) {
80 -
			return &dataprovider.DefenderEntry{
80 +
			return dataprovider.DefenderEntry{
81 81
				IP:      ip,
82 82
				BanTime: banTime,
83 83
			}, nil
@@ -92,14 +92,14 @@
Loading
92 92
			}
93 93
		}
94 94
		if score > 0 {
95 -
			return &dataprovider.DefenderEntry{
95 +
			return dataprovider.DefenderEntry{
96 96
				IP:    ip,
97 97
				Score: score,
98 98
			}, nil
99 99
		}
100 100
	}
101 101
102 -
	return nil, util.NewRecordNotFoundError("host not found")
102 +
	return dataprovider.DefenderEntry{}, util.NewRecordNotFoundError("host not found")
103 103
}
104 104
105 105
// IsBanned returns true if the specified IP is banned

@@ -33,12 +33,12 @@
Loading
33 33
}
34 34
35 35
// GetHosts returns hosts that are banned or for which some violations have been detected
36 -
func (d *dbDefender) GetHosts() ([]*dataprovider.DefenderEntry, error) {
36 +
func (d *dbDefender) GetHosts() ([]dataprovider.DefenderEntry, error) {
37 37
	return dataprovider.GetDefenderHosts(d.getStartObservationTime(), d.config.EntriesHardLimit)
38 38
}
39 39
40 40
// GetHost returns a defender host by ip, if any
41 -
func (d *dbDefender) GetHost(ip string) (*dataprovider.DefenderEntry, error) {
41 +
func (d *dbDefender) GetHost(ip string) (dataprovider.DefenderEntry, error) {
42 42
	return dataprovider.GetDefenderHostByIP(ip, d.getStartObservationTime())
43 43
}
44 44

@@ -38,8 +38,8 @@
Loading
38 38
39 39
// Defender defines the interface that a defender must implements
40 40
type Defender interface {
41 -
	GetHosts() ([]*dataprovider.DefenderEntry, error)
42 -
	GetHost(ip string) (*dataprovider.DefenderEntry, error)
41 +
	GetHosts() ([]dataprovider.DefenderEntry, error)
42 +
	GetHost(ip string) (dataprovider.DefenderEntry, error)
43 43
	AddEvent(ip string, event HostEvent)
44 44
	IsBanned(ip string) bool
45 45
	GetBanTime(ip string) (*time.Time, error)

@@ -135,7 +135,7 @@
Loading
135 135
136 136
type connectionsPage struct {
137 137
	basePage
138 -
	Connections []*common.ConnectionStatus
138 +
	Connections []common.ConnectionStatus
139 139
}
140 140
141 141
type statusPage struct {

@@ -222,7 +222,7 @@
Loading
222 222
}
223 223
224 224
// GetDefenderHosts returns hosts that are banned or for which some violations have been detected
225 -
func GetDefenderHosts() ([]*dataprovider.DefenderEntry, error) {
225 +
func GetDefenderHosts() ([]dataprovider.DefenderEntry, error) {
226 226
	if Config.defender == nil {
227 227
		return nil, nil
228 228
	}
@@ -231,9 +231,9 @@
Loading
231 231
}
232 232
233 233
// GetDefenderHost returns a defender host by ip, if any
234 -
func GetDefenderHost(ip string) (*dataprovider.DefenderEntry, error) {
234 +
func GetDefenderHost(ip string) (dataprovider.DefenderEntry, error) {
235 235
	if Config.defender == nil {
236 -
		return nil, errors.New("defender is disabled")
236 +
		return dataprovider.DefenderEntry{}, errors.New("defender is disabled")
237 237
	}
238 238
239 239
	return Config.defender.GetHost(ip)
@@ -873,13 +873,13 @@
Loading
873 873
}
874 874
875 875
// GetStats returns stats for active connections
876 -
func (conns *ActiveConnections) GetStats() []*ConnectionStatus {
876 +
func (conns *ActiveConnections) GetStats() []ConnectionStatus {
877 877
	conns.RLock()
878 878
	defer conns.RUnlock()
879 879
880 -
	stats := make([]*ConnectionStatus, 0, len(conns.connections))
880 +
	stats := make([]ConnectionStatus, 0, len(conns.connections))
881 881
	for _, c := range conns.connections {
882 -
		stat := &ConnectionStatus{
882 +
		stat := ConnectionStatus{
883 883
			Username:       c.GetUsername(),
884 884
			ConnectionID:   c.GetID(),
885 885
			ClientVersion:  c.GetClientVersion(),
Files Coverage
common 99.90%
config 100.00%
ftpd 100.00%
httpd 99.95%
mfa 100.00%
sftpd 98.52%
telemetry 100.00%
webdavd 100.00%
Project Totals (62 files) 99.71%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading