-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28eedf9
commit a08af0a
Showing
15 changed files
with
199 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package agent | ||
|
||
import "errors" | ||
|
||
var ( | ||
errGrpcAddressRequired = errors.New("address is required for gRPC checker") | ||
errUnknownCheckerType = errors.New("unknown checker type") | ||
errGrpcMissingConfig = errors.New("no configuration or address provided for gRPC checker") | ||
errNoLocalConfig = errors.New("no local config found") | ||
errShutdown = errors.New("error while shutting down") | ||
errServiceStartup = errors.New("error while starting services") | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package models | ||
|
||
import "time" | ||
|
||
// SweepData represents network sweep results. | ||
type SweepData struct { | ||
Network string `json:"network"` | ||
TotalHosts int32 `json:"total_hosts"` | ||
AvailableHosts int32 `json:"available_hosts"` | ||
LastSweep int64 `json:"last_sweep"` | ||
Ports []PortStatus `json:"ports"` | ||
} | ||
|
||
// PortStatus represents port availability information. | ||
type PortStatus struct { | ||
Port int32 `json:"port"` | ||
Available int32 `json:"available"` | ||
} | ||
|
||
// Config defines sweeper configuration. | ||
type Config struct { | ||
Networks []string `json:"networks"` | ||
Ports []int `json:"ports"` | ||
SweepModes []SweepMode `json:"sweep_modes"` | ||
Interval time.Duration `json:"interval"` | ||
Concurrency int `json:"concurrency"` | ||
Timeout time.Duration `json:"timeout"` | ||
ICMPCount int `json:"icmp_count"` | ||
} | ||
|
||
type SweepMode string | ||
|
||
const ( | ||
ModeTCP SweepMode = "tcp" | ||
ModeICMP SweepMode = "icmp" | ||
) | ||
|
||
// Target represents a network target to be scanned. | ||
type Target struct { | ||
Host string | ||
Port int | ||
Mode SweepMode | ||
} | ||
|
||
// Result represents the outcome of a sweep against a target. | ||
type Result struct { | ||
Target Target | ||
Available bool | ||
FirstSeen time.Time | ||
LastSeen time.Time | ||
RespTime time.Duration | ||
PacketLoss float64 | ||
Error error | ||
} | ||
|
||
// ResultFilter defines criteria for retrieving results. | ||
type ResultFilter struct { | ||
Host string | ||
Port int | ||
StartTime time.Time | ||
EndTime time.Time | ||
Available *bool | ||
} | ||
|
||
// ContainsMode checks if a mode is in a list of modes. | ||
func ContainsMode(modes []SweepMode, mode SweepMode) bool { | ||
for _, m := range modes { | ||
if m == mode { | ||
return true | ||
} | ||
} | ||
|
||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.