scan

package
v0.0.0-...-c711863 Latest Latest
Warning

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

Go to latest
Published: May 16, 2025 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HostPortMap = make(map[string]map[string]bool)

Functions

func DetectBadHost

func DetectBadHost(netAddress string, log *zap.Logger) bool

func RPCSettings

func RPCSettings(ctx context.Context, t *rhpv2.Transport) (settings rhpv2.HostSettings, err error)

func ScanPriceTable

func ScanPriceTable(v3Session *Session) (rhpv3.HostPriceTable, error)

Types

type ChainManager

type ChainManager interface {
	TipState() consensus.State
}

A ChainManager is used to get the current consensus state

type Check

type Check struct {
	CreatedAt   time.Time
	PublicKey   string  `json:"publicKey"`
	V4Addr      string  `json:"v4Addr"`
	V6Addr      string  `json:"v6Addr"`
	Rhp2Port    string  `json:"rhp2Port"`
	Rhp2V4Delay float64 `json:"rhp2V4Delay"`
	Rhp2V6Delay float64 `json:"rhp2V6Delay"`
	Rhp2V4      bool    `json:"rhp2V4"`
	Rhp2V6      bool    `json:"rhp2V6"`
	Rhp3Port    string  `json:"rhp3Port"`
	Rhp3V4      bool    `json:"rhp3V4"`
	Rhp3V6      bool    `json:"rhp3V6"`
	Rhp3V4Delay float64 `json:"rhp3V4Delay"`
	Rhp3V6Delay float64 `json:"rhp3V6Delay"`
	Rhp4Port    string  `json:"rhp4Port"`
	Rhp4V4      bool    `json:"rhp4V4"`
	Rhp4V6      bool    `json:"rhp4V6"`
	Rhp4V4Delay float64 `json:"rhp4V4Delay"`
	Rhp4V6Delay float64 `json:"rhp4V6Delay"`
}

A Check is a port scan of a host

func (*Check) ToBSON

func (c *Check) ToBSON() bson.M

type Checker

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

func (*Checker) CheckDNSRecords

func (nc *Checker) CheckDNSRecords(hostname string) (bool, bool, []net.IP, []net.IP)

func (*Checker) CheckPortOpen

func (nc *Checker) CheckPortOpen(address, port string) (bool, float64)

func (*Checker) CheckVersion

func (nc *Checker) CheckVersion(publicKey string) (string, error)

func (*Checker) ClassifyNetAddress

func (nc *Checker) ClassifyNetAddress(address string) string

func (*Checker) PortScan

func (nc *Checker) PortScan(scanned HostScan)

func (*Checker) ScanV1Host

func (nc *Checker) ScanV1Host(host UnscannedHost) (HostScan, error)

func (*Checker) ScanV2Host

func (nc *Checker) ScanV2Host(host UnscannedHost) (HostScan, error)

func (*Checker) SplitAddressPort

func (nc *Checker) SplitAddressPort(address string) (string, string, error)

type HostScan

type HostScan struct {
	// Location  geoip.Location  `json:"location"`
	PublicKey          string             `json:"publicKey"`
	V2                 bool               `json:"v2"`
	V2NetAddresses     []chain.NetAddress `json:"v2NetAddresses,omitempty"`
	NetAddress         string             `json:"netAddress"`
	Success            bool               `json:"success"`
	Timestamp          time.Time          `json:"timestamp"`
	NextScan           time.Time          `json:"nextScan"`
	AcceptingContracts bool               `json:"acceptingContracts"`

	Error        string    `json:"error"`
	OnlineSince  time.Time `json:"onlineSince"`
	OfflineSince time.Time `json:"offlineSince"`

	TotalStorage     uint64 `json:"totalStorage"`
	RemainingStorage uint64 `json:"remainingStorage"`

	Settings   rhpv2.HostSettings   `json:"settings"`
	PriceTable rhpv3.HostPriceTable `json:"priceTable"`

	RHPV4Settings rhpv4.HostSettings `json:"rhpV4Settings"`
}

HostScan represents the results of a host scan.

func RunRhpScan

func RunRhpScan(host explored.Host, checker *Checker) (HostScan, error)

func (*HostScan) ToBSON

func (h *HostScan) ToBSON() bson.M

type NetworkChecker

type NetworkChecker interface {
	CheckPortOpen(address string, port string) (bool, time.Duration)
	CheckDNSRecords(hostname string) (hasA, hasAAAA bool, v4, v6 []net.IP)
	ClassifyNetAddress(address string) string
	SplitAddressPort(address string) (host, port string, err error)
	PortScan(hostId string, scanned Scan)
	ScanV1Host(host UnscannedHost) (HostScan, error)
	ScanV2Host(host UnscannedHost) (HostScan, error)
}

type PaymentMethod

type PaymentMethod interface {
}

A PaymentMethod facilitates payments to the host using either a contract or an ephemeral account

type Scan

type Scan struct {
	Settings   rhpv2.HostSettings
	PriceTable rhpv3.HostPriceTable
}

type Session

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

A Session is an RHP3 session with the host

func NewSession

func NewSession(ctx context.Context, hostKey types.PublicKey, hostAddr string, cm ChainManager, w Wallet) (*Session, error)

NewSession creates a new session with a host

type TaskCheckDoc

type TaskCheckDoc struct {
	ID      int
	Job     string
	CheckID string
	Check   Check
}

type UnscannedHost

type UnscannedHost struct {
	PublicKey                types.PublicKey    `json:"publicKey"`
	V2                       bool               `json:"v2"`
	NetAddress               string             `json:"netAddress"`
	V2NetAddresses           []chain.NetAddress `json:"v2NetAddresses,omitempty"`
	FailedInteractionsStreak uint64             `json:"failedInteractionsStreak"`
}

UnscannedHost represents the metadata needed to scan a host.

func (UnscannedHost) IsV2

func (h UnscannedHost) IsV2() bool

IsV2 returns whether a host supports V2 or not.

func (UnscannedHost) V2SiamuxAddr

func (h UnscannedHost) V2SiamuxAddr() (string, bool)

V2SiamuxAddr returns the `Address` of the first TCP siamux `NetAddress` it finds in the host's list of net addresses. The protocol for this address is // ProtocolTCPSiaMux.

type Wallet

type Wallet interface {
	Address() types.Address
	FundTransaction(txn *types.Transaction, amount types.Currency) ([]types.Hash256, func(), error)
	SignTransaction(cs consensus.State, txn *types.Transaction, toSign []types.Hash256, cf types.CoveredFields) error
}

A Wallet funds and signs transactions

Jump to

Keyboard shortcuts

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