protocols

package
v0.0.0-...-98a2988 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2023 License: GPL-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package protocols is where the protocol-testers live.

Tests are dynamically instantiated at run-time, via a class-factory pattern, and due to their plugin nature they are simple to implement as they require only implementing a single method.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handlers

func Handlers() []string

Handlers returns the names of all the registered protocol-handlers.

func Register

func Register(id string, newfunc TestCtor)

Register a test-type with a constructor.

Types

type DNSTest

type DNSTest struct {
}

DNSTest is our object.

func (*DNSTest) Arguments

func (s *DNSTest) Arguments() map[string]string

Arguments returns the names of arguments which this protocol-test understands, along with corresponding regular-expressions to validate their values.

func (*DNSTest) Example

func (s *DNSTest) Example() string

Example returns sample usage-instructions for self-documentation purposes.

func (*DNSTest) RunTest

func (s *DNSTest) RunTest(tst test.Test, target string, opts test.Options) error

RunTest is the part of our API which is invoked to actually execute a test against the given target.

In this case we make a DNS-lookup against the named host, and compare the result with what the user specified. look for a response which appears to be an FTP-server.

type FINGERTest

type FINGERTest struct {
}

FINGERTest is our object.

func (*FINGERTest) Arguments

func (s *FINGERTest) Arguments() map[string]string

Arguments returns the names of arguments which this protocol-test understands, along with corresponding regular-expressions to validate their values.

func (*FINGERTest) Example

func (s *FINGERTest) Example() string

Example returns sample usage-instructions for self-documentation purposes.

func (*FINGERTest) RunTest

func (s *FINGERTest) RunTest(tst test.Test, target string, opts test.Options) error

RunTest is the part of our API which is invoked to actually execute a test against the given target.

In this case we make a TCP connection, defaulting to port 79, and look for a non-empty response.

type FTPTest

type FTPTest struct {
}

FTPTest is our object.

func (*FTPTest) Arguments

func (s *FTPTest) Arguments() map[string]string

Arguments returns the names of arguments which this protocol-test understands, along with corresponding regular-expressions to validate their values.

func (*FTPTest) Example

func (s *FTPTest) Example() string

Example returns sample usage-instructions for self-documentation purposes.

func (*FTPTest) RunTest

func (s *FTPTest) RunTest(tst test.Test, target string, opts test.Options) error

RunTest is the part of our API which is invoked to actually execute a test against the given target.

In this case we make a TCP connection, defaulting to port 21, and look for a response which appears to be an FTP-server.

type HTTPTest

type HTTPTest struct {
}

HTTPTest is our object.

func (*HTTPTest) Arguments

func (s *HTTPTest) Arguments() map[string]string

Arguments returns the names of arguments which this protocol-test understands, along with corresponding regular-expressions to validate their values.

func (*HTTPTest) Example

func (s *HTTPTest) Example() string

Example returns sample usage-instructions for self-documentation purposes.

func (*HTTPTest) RunTest

func (s *HTTPTest) RunTest(tst test.Test, target string, opts test.Options) error

RunTest is the part of our API which is invoked to actually execute a HTTP-test against the given URL.

For the purposes of clarity this test makes a HTTP-fetch. The `test.Test` structure contains our raw test, and the `target` variable contains the IP address against which to make the request.

So:

tst.Target => "https://steve.kemp.fi/

target => "176.9.183.100"

func (*HTTPTest) SSLExpiration

func (s *HTTPTest) SSLExpiration(host string, verbose bool) (int64, string, error)

SSLExpiration returns the number of hours remaining for a given SSL certificate chain.

type IMAPSTest

type IMAPSTest struct {
}

IMAPSTest is our object

func (*IMAPSTest) Arguments

func (s *IMAPSTest) Arguments() map[string]string

Arguments returns the names of arguments which this protocol-test understands, along with corresponding regular-expressions to validate their values.

func (*IMAPSTest) Example

func (s *IMAPSTest) Example() string

Example returns sample usage-instructions for self-documentation purposes.

func (*IMAPSTest) RunTest

func (s *IMAPSTest) RunTest(tst test.Test, target string, opts test.Options) error

RunTest is the part of our API which is invoked to actually execute a test against the given target.

In this case we make a IMAP connection to the specified host, and if a username + password were specified we then attempt to authenticate to the remote host too.

type IMAPTest

type IMAPTest struct {
}

IMAPTest is our object

func (*IMAPTest) Arguments

func (s *IMAPTest) Arguments() map[string]string

Arguments returns the names of arguments which this protocol-test understands, along with corresponding regular-expressions to validate their values.

func (*IMAPTest) Example

func (s *IMAPTest) Example() string

Example returns sample usage-instructions for self-documentation purposes.

func (*IMAPTest) RunTest

func (s *IMAPTest) RunTest(tst test.Test, target string, opts test.Options) error

RunTest is the part of our API which is invoked to actually execute a test against the given target.

In this case we make a IMAP connection to the specified host, and if a username + password were specified we then attempt to authenticate to the remote host too.

type MYSQLTest

type MYSQLTest struct {
}

MYSQLTest is our object

func (*MYSQLTest) Arguments

func (s *MYSQLTest) Arguments() map[string]string

Arguments returns the names of arguments which this protocol-test understands, along with corresponding regular-expressions to validate their values.

func (*MYSQLTest) Example

func (s *MYSQLTest) Example() string

Example returns sample usage-instructions for self-documentation purposes.

func (*MYSQLTest) RunTest

func (s *MYSQLTest) RunTest(tst test.Test, target string, opts test.Options) error

RunTest is the part of our API which is invoked to actually execute a test against the given target.

In this case we make a TCP connection to the host and attempt to login with the specified username & password.

type NNTPTest

type NNTPTest struct {
}

NNTPTest is our object.

func (*NNTPTest) Arguments

func (s *NNTPTest) Arguments() map[string]string

Arguments returns the names of arguments which this protocol-test understands, along with corresponding regular-expressions to validate their values.

func (*NNTPTest) Example

func (s *NNTPTest) Example() string

Example returns sample usage-instructions for self-documentation purposes.

func (*NNTPTest) RunTest

func (s *NNTPTest) RunTest(tst test.Test, target string, opts test.Options) error

RunTest is the part of our API which is invoked to actually execute a test against the given target.

In this case we make a TCP connection, defaulting to port 119, and look for a response which appears to be an NNTP-server.

type PINGTest

type PINGTest struct {
}

PINGTest is our object.

func (*PINGTest) Arguments

func (s *PINGTest) Arguments() map[string]string

Arguments returns the names of arguments which this protocol-test understands, along with corresponding regular-expressions to validate their values.

func (*PINGTest) Example

func (s *PINGTest) Example() string

Example returns sample usage-instructions for self-documentation purposes.

func (*PINGTest) Ping4

func (s *PINGTest) Ping4(target string) bool

Ping4 runs a ping test against an IPv4 address, returning true if the ping succeeded.

func (*PINGTest) Ping6

func (s *PINGTest) Ping6(target string) bool

Ping6 runs a ping test against an IPv6 address, returning true if the ping succeeded.

func (*PINGTest) RunCommand

func (s *PINGTest) RunCommand(name string, args ...string) (stdout string, stderr string, exitCode int)

RunCommand invokes an external binary and returns stdout/stderr/exit-code

func (*PINGTest) RunTest

func (s *PINGTest) RunTest(tst test.Test, target string, opts test.Options) error

RunTest is the part of our API which is invoked to actually execute a test against the given target.

In this case we run a ping-command with the appropriate binary depending on the address-family of the target host.

type POP3STest

type POP3STest struct {
}

POP3STest is our object

func (*POP3STest) Arguments

func (s *POP3STest) Arguments() map[string]string

Arguments returns the names of arguments which this protocol-test understands, along with corresponding regular-expressions to validate their values.

func (*POP3STest) Example

func (s *POP3STest) Example() string

Example returns sample usage-instructions for self-documentation purposes.

func (*POP3STest) RunTest

func (s *POP3STest) RunTest(tst test.Test, target string, opts test.Options) error

RunTest is the part of our API which is invoked to actually execute a test against the given target.

In this case we make a POP3 connection to the specified host, and if a username + password were specified we then attempt to authenticate to the remote host too.

type POP3Test

type POP3Test struct {
}

POP3Test is our object

func (*POP3Test) Arguments

func (s *POP3Test) Arguments() map[string]string

Arguments returns the names of arguments which this protocol-test understands, along with corresponding regular-expressions to validate their values.

func (*POP3Test) Example

func (s *POP3Test) Example() string

Example returns sample usage-instructions for self-documentation purposes.

func (*POP3Test) RunTest

func (s *POP3Test) RunTest(tst test.Test, target string, opts test.Options) error

RunTest is the part of our API which is invoked to actually execute a test against the given target.

In this case we make a POP3 connection to the specified host, and if a username + password were specified we then attempt to authenticate to the remote host too.

type PSQLTest

type PSQLTest struct {
}

PSQLTest is our object

func (*PSQLTest) Arguments

func (s *PSQLTest) Arguments() map[string]string

Arguments returns the names of arguments which this protocol-test understands, along with corresponding regular-expressions to validate their values.

func (*PSQLTest) Example

func (s *PSQLTest) Example() string

Example returns sample usage-instructions for self-documentation purposes.

func (*PSQLTest) RunTest

func (s *PSQLTest) RunTest(tst test.Test, target string, opts test.Options) error

RunTest is the part of our API which is invoked to actually execute a test against the given target.

In this case we make a TCP connection to the database host and attempt to login with the specified username & password.

type ProtocolTest

type ProtocolTest interface {

	//
	// Arguments return the arguments which this protocol-test accepts, along
	// with a regular expression which will be used to validate a non-empty
	// argument.
	//
	Arguments() map[string]string

	// Example should return a string describing how your protocol-test
	// works and is invoked.
	//
	// Optional arguments will automatically be documented.
	Example() string

	//
	// RunTest actually invokes the protocol-handler to run its
	// tests.
	//
	// Return a suitable error if the test fails, or nil to indicate
	// it passed.
	//
	RunTest(tst test.Test, target string, opts test.Options) error
}

ProtocolTest interface is the core of our code, it defines the implementation methods which must be implemented to add a new protocol-test.

func ProtocolHandler

func ProtocolHandler(id string) (a ProtocolTest)

ProtocolHandler is the factory-method which looks up and returns an object of the given type - if possible.

type REDISTest

type REDISTest struct {
}

REDISTest is our object

func (*REDISTest) Arguments

func (s *REDISTest) Arguments() map[string]string

Arguments returns the names of arguments which this protocol-test understands, along with corresponding regular-expressions to validate their values.

func (*REDISTest) Example

func (s *REDISTest) Example() string

Example returns sample usage-instructions for self-documentation purposes.

func (*REDISTest) RunTest

func (s *REDISTest) RunTest(tst test.Test, target string, opts test.Options) error

RunTest is the part of our API which is invoked to actually execute a test against the given target.

In this case we make a Redis-test against the given target.

type RSYNCTest

type RSYNCTest struct {
}

RSYNCTest is our object.

func (*RSYNCTest) Arguments

func (s *RSYNCTest) Arguments() map[string]string

Arguments returns the names of arguments which this protocol-test understands, along with corresponding regular-expressions to validate their values.

func (*RSYNCTest) Example

func (s *RSYNCTest) Example() string

Example returns sample usage-instructions for self-documentation purposes.

func (*RSYNCTest) RunTest

func (s *RSYNCTest) RunTest(tst test.Test, target string, opts test.Options) error

RunTest is the part of our API which is invoked to actually execute a test against the given target.

In this case we make a TCP connection, defaulting to port 873, and look for a response which appears to be an rsync-server.

type SMTPTest

type SMTPTest struct {
}

SMTPTest is our object

func (*SMTPTest) Arguments

func (s *SMTPTest) Arguments() map[string]string

Arguments returns the names of arguments which this protocol-test understands, along with corresponding regular-expressions to validate their values.

func (*SMTPTest) Example

func (s *SMTPTest) Example() string

Example returns sample usage-instructions for self-documentation purposes.

func (*SMTPTest) RunTest

func (s *SMTPTest) RunTest(tst test.Test, target string, opts test.Options) error

RunTest is the part of our API which is invoked to actually execute a test against the given target.

In this case we make a TCP connection, defaulting to port 25, and look for a response which appears to be an SMTP-server.

type SSHTest

type SSHTest struct {
}

SSHTest is our object.

func (*SSHTest) Arguments

func (s *SSHTest) Arguments() map[string]string

Arguments returns the names of arguments which this protocol-test understands, along with corresponding regular-expressions to validate their values.

func (*SSHTest) Example

func (s *SSHTest) Example() string

Example returns sample usage-instructions for self-documentation purposes.

func (*SSHTest) RunTest

func (s *SSHTest) RunTest(tst test.Test, target string, opts test.Options) error

RunTest is the part of our API which is invoked to actually execute a test against the given target.

In this case we make a TCP connection, defaulting to port 22, and look for a response which appears to be an SSH-server.

type TCPTest

type TCPTest struct {
}

TCPTest is our object

func (*TCPTest) Arguments

func (s *TCPTest) Arguments() map[string]string

Arguments returns the names of arguments which this protocol-test understands, along with corresponding regular-expressions to validate their values.

func (*TCPTest) Example

func (s *TCPTest) Example() string

Example returns sample usage-instructions for self-documentation purposes.

func (*TCPTest) RunTest

func (s *TCPTest) RunTest(tst test.Test, target string, opts test.Options) error

RunTest is the part of our API which is invoked to actually execute a test against the given target.

In this case we make a TCP connection to the specified port, and assume that everything is OK if that succeeded.

type TELNETTest

type TELNETTest struct {
}

TELNETTest is our object

func (*TELNETTest) Arguments

func (s *TELNETTest) Arguments() map[string]string

Arguments returns the names of arguments which this protocol-test understands, along with corresponding regular-expressions to validate their values.

func (*TELNETTest) Example

func (s *TELNETTest) Example() string

Example returns sample usage-instructions for self-documentation purposes.

func (*TELNETTest) RunTest

func (s *TELNETTest) RunTest(tst test.Test, target string, opts test.Options) error

RunTest is the part of our API which is invoked to actually execute a test against the given target.

In this case we make a TCP connection to the specified port, and assume that everything is OK if that succeeded.

type TestCtor

type TestCtor func() ProtocolTest

TestCtor is the signature of a constructor-function.

type VNCTest

type VNCTest struct {
}

VNCTest is our object

func (*VNCTest) Arguments

func (s *VNCTest) Arguments() map[string]string

Arguments returns the names of arguments which this protocol-test understands, along with corresponding regular-expressions to validate their values.

func (*VNCTest) Example

func (s *VNCTest) Example() string

Example returns sample usage-instructions for self-documentation purposes.

func (*VNCTest) RunTest

func (s *VNCTest) RunTest(tst test.Test, target string, opts test.Options) error

RunTest is the part of our API which is invoked to actually execute a test against the given target.

In this case we make a TCP connection, defaulting to port 5900, and look for a response which appears to be an VNC-server.

type XMPPTest

type XMPPTest struct {
}

XMPPTest is our object

func (*XMPPTest) Arguments

func (s *XMPPTest) Arguments() map[string]string

Arguments returns the names of arguments which this protocol-test understands, along with corresponding regular-expressions to validate their values.

func (*XMPPTest) Example

func (s *XMPPTest) Example() string

Example returns sample usage-instructions for self-documentation purposes.

func (*XMPPTest) RunTest

func (s *XMPPTest) RunTest(tst test.Test, target string, opts test.Options) error

RunTest is the part of our API which is invoked to actually execute a test against the given target.

In this case we make a TCP connection, defaulting to port 5222, and look for a response which appears to be an XMPP-server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL