Documentation
¶
Index ¶
- Constants
- func IsAllowedProtocol(protocol Protocol) bool
- func IsNumber(n string) bool
- func IsValidPort(port int) bool
- func NewFileWriter(path string) *fileWriter
- func NewJSONScanResultsFormatter() *jsonScanResultsFormatter
- func NewPlainScanResultsFormatter() *plainScanResultsFormatter
- func NewStdWriter() *stdWriter
- func NewYAMLScanResultsFormatter() *yamlScanResultsFormatter
- type Format
- type Protocol
- type ScanResult
- type ScanResultsFormatter
- type State
- type Writer
Constants ¶
const ( MinValidPortNumber = 0 MaxValidPortNumber = 65535 PortScanTimeout = 60 * time.Second )
const (
FileMode = 0644
)
Variables ¶
This section is empty.
Functions ¶
func IsAllowedProtocol ¶
IsAllowedProtocol returns true if the given input is a valid value for the transport layer protocol. TODO: Use const values.
func IsNumber ¶
IsNumber returns true if the given input can be converted into an integer, otherwise returns false.
func IsValidPort ¶
IsValidPort returns true if the given input is within the range of valid port numbers, otherwise returns false.
func NewFileWriter ¶
func NewFileWriter(path string) *fileWriter
NewFileWriter returns a new file writer.
func NewJSONScanResultsFormatter ¶
func NewJSONScanResultsFormatter() *jsonScanResultsFormatter
NewJSONScanResultsFormatter returns a new JSON results formatter.
func NewPlainScanResultsFormatter ¶
func NewPlainScanResultsFormatter() *plainScanResultsFormatter
NewPlainScanResultsFormatter returns a new plain results formatter.
func NewStdWriter ¶
func NewStdWriter() *stdWriter
NewStdWriter returns a new standard (stdin) writer.
func NewYAMLScanResultsFormatter ¶
func NewYAMLScanResultsFormatter() *yamlScanResultsFormatter
NewYAMLScanResultsFormatter returns a new YAML results formatter.
Types ¶
type Format ¶
type Format string
Format represents a valid serialization format.
func FormatFromString ¶
FormatFromString instances a new Format from the given string.
type Protocol ¶
type Protocol string
Protocol represents a valid transport layer protocol.
func ProtocolFromString ¶
ProtocolFromString instances a new Protocol from the given string.
type ScanResult ¶
type ScanResult struct {
Protocol Protocol `json:"protocol"`
Port int `json:"port"`
State State `json:"state"`
}
ScanResult contains all the information related with an specific port scan. It includes the protocol, the port and the state {open, closed}.
func ScanPort ¶
func ScanPort(protocol Protocol, hostname string, port int) (ScanResult, error)
ScanPort does a Dial check of the given port at the given address through the given protocol. It returns an ScanResult with the info.
func ScanPortRange ¶
func ScanPortRange(protocol Protocol, hostname string, from, to int) (results []ScanResult, err error)
ScanPortRange does a concurrent ScanPort call for each port present within the given ports range. It returns a slide of ScanResults with the info.
type ScanResultsFormatter ¶
type ScanResultsFormatter interface {
Format(results []ScanResult) []byte
}
ScanResultFormatter defines the behaviour needed to format a given slide of ScanResults into the formatter format.
func NewScanResultsFormatter ¶
func NewScanResultsFormatter(format Format) (ScanResultsFormatter, error)
NewScanResultsFormatter is a factory method that returns a valid ScanResultsFormatter implementation or an error.