ipv4

package
v0.0.0-...-b0e10ae Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2016 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Log = logging.Log.New("pkg", "network/ipv4")

Log is used to log messages for the example package. Logs are disabled by default; use sift/logging.SetLevel() to set log levels for all packages, or Log.SetHandler() to set a custom handler for this package (see: https://godoc.org/gopkg.in/inconshreveable/log15.v2)

Functions

func KillContext

func KillContext(context *ServiceContext)

KillContext kills the specified context. Subsequent calls on the Context will return errors

Types

type AdapterStatus

type AdapterStatus int

AdapterStatus describes the status of an Adapter

const (
	AdapterStatusIncorrectService AdapterStatus = iota // Context pointed to a service that the Adapter does not control
	AdapterStatusHandling                              // Adapter is handling the Context
	AdapterStatusDone                                  // Adapter is done handling the Context
	AdapterStatusError                                 // Adapter received an error
)

Possible Adapter statuses

type ContinuousScanner

type ContinuousScanner struct {
	*Scanner
	// contains filtered or unexported fields
}

ContinuousScanner implements IContinuousScanner. It scans continuously, putting results into the channel provided by FoundServices().

func NewContinousScanner

func NewContinousScanner(period time.Duration) *ContinuousScanner

NewContinousScanner properly instantiates a ContinuousScanner. The new Scanner will wait between scans for a time defined by `period`.

func (*ContinuousScanner) FoundServices

func (s *ContinuousScanner) FoundServices() chan ServiceFoundNotification

FoundServices returns a channel which will be populated with services found by the ContinuousScanner

func (*ContinuousScanner) Serve

func (s *ContinuousScanner) Serve()

Serve begins serving the ContinuousScanner.

func (*ContinuousScanner) Stop

func (s *ContinuousScanner) Stop()

Stop stops the ContinousScanner

type IContinuousScanner

type IContinuousScanner interface {
	suture.Service
	IScanner
	FoundServices() chan ServiceFoundNotification
}

An IContinuousScanner is a Scanner that scans continuously. Scan results are passed to the channel provided by FoundServices()

type IScanner

type IScanner interface {
	// Add a description to search for; return the ID used if a match is returned
	AddDescription(desc ServiceDescription) string

	// Scan the IPv4 network for services matching given descriptions.
	// Returns a map of IPs (string encoded) pointing to the IDs of those descriptions which matched
	Scan() map[string][]string

	// By default, after an IP is found with Scan it is ignored in future searches.
	// Unlock instructs the scanner to include responses for that IP address in future scans.
	Unlock(ip net.IP)
}

An IScanner searches the IPv4 network for services matching given descriptions. Once services are found, they are locked and returned to the caller. It is up to the caller to unlock IPs (via Unlock()) if they are no longer in use.

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

Scanner implements IScanner. It searches the IPv4 network for services matching given descriptions. Once services are found, they are locked and returned to the caller. It is up to the caller to unlock IPs (via Unlock()) if they are no longer in use.

func NewScanner

func NewScanner() *Scanner

NewScanner properly instantiates a Scanner.

func (*Scanner) AddDescription

func (s *Scanner) AddDescription(desc ServiceDescription) string

AddDescription adds a ServiceDescription to the Scanner. On following scans, the Scanner will find services which match the description.

func (*Scanner) Scan

func (s *Scanner) Scan() map[string][]string

Scan the IPv4 network for services matching given descriptions. Returns a map of IPs (string encoded) pointing to the IDs of those descriptions which matched

func (*Scanner) Unlock

func (s *Scanner) Unlock(ip net.IP)

Unlock unlocks the provided IP, such that it will no longer be ignored in future scans.

type ServiceContext

type ServiceContext struct {
	IP          net.IP            // the IP of the service
	Port        *uint16           // TODO REMOVE (prev: optionally specify the port of the running service)
	Credentials map[string]string //TODO REMOVE
	// contains filtered or unexported fields
}

ServiceContext describes (and grants access to) a particular IPv4 service.

func BuildContext

func BuildContext(ip net.IP, dbpath, adapterName string) (*ServiceContext, <-chan AdapterStatus)

BuildContext builds a new ServiceContext with the given IP. The second return value is a channel which will receive status updates from calls to context.SendStatus() until the Context is killed.

func (ServiceContext) GetData

func (s ServiceContext) GetData(key string) (string, error)

GetData retrieves the string data which has been stored for this context.

Note that Adapters with different names (e.g. "google chromecast" vs "amazon fire") are segregated from eachother and will not be able to read or write over eachother's data.

func (ServiceContext) SendStatus

func (s ServiceContext) SendStatus(ds AdapterStatus) error

SendStatus sends a status to the creator of the Context. Will return an error if the Context has been killed, otherwise nil.

func (ServiceContext) StoreData

func (s ServiceContext) StoreData(key, value string) (err error)

StoreData will store a string of data with the Context, which is retrievable with the given key.

Note that Adapters with different names (e.g. "google chromecast" vs "amazon fire") are segregated from eachother and will not be able to read or write over eachother's data.

type ServiceDescription

type ServiceDescription struct {
	OpenPorts []uint16
}

ServiceDescription describes ipv4 characteristics of a networked service

type ServiceFoundNotification

type ServiceFoundNotification struct {
	IP                     net.IP
	MatchingDescriptionIDs []string
}

A ServiceFoundNotification indicates that a service was found at ip IP which matched all of MatchingDescriptionIDs.

Jump to

Keyboard shortcuts

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