Documentation ¶
Index ¶
- Variables
- func NetError(err error) string
- func Rollback(txn *sql.Tx)
- type Client
- type DBClient
- func (c *DBClient) Close() error
- func (c *DBClient) FetchDueOpenSessions(ctx context.Context) (models.SessionsOpenSlice, error)
- func (c *DBClient) FetchUnresolvedMultiAddresses(ctx context.Context, limit int) (models.MultiAddressSlice, error)
- func (c *DBClient) GetOrCreateAgentVersionID(ctx context.Context, exec boil.ContextExecutor, agentVersion string) (*int, error)
- func (c *DBClient) GetOrCreateProtocol(ctx context.Context, exec boil.ContextExecutor, protocol string) (*int, error)
- func (c *DBClient) GetOrCreateProtocolsSetID(ctx context.Context, exec boil.ContextExecutor, protocols []string) (*int, error)
- func (c *DBClient) Handle() *sql.DB
- func (c *DBClient) InitCrawl(ctx context.Context, version string) (*models.Crawl, error)
- func (c *DBClient) PersistCrawlProperties(ctx context.Context, crawl *models.Crawl, properties map[string]map[string]int) error
- func (c *DBClient) PersistCrawlVisit(ctx context.Context, crawlID int, peerID peer.ID, maddrs []ma.Multiaddr, ...) (*InsertVisitResult, error)
- func (c *DBClient) PersistDialVisit(ctx context.Context, peerID peer.ID, maddrs []ma.Multiaddr, ...) (*InsertVisitResult, error)
- func (c *DBClient) PersistNeighbors(ctx context.Context, crawl *models.Crawl, dbPeerID *int, peerID peer.ID, ...) error
- func (c *DBClient) QueryBootstrapPeers(ctx context.Context, limit int) ([]peer.AddrInfo, error)
- func (c *DBClient) UpdateCrawl(ctx context.Context, crawl *models.Crawl) error
- func (c *DBClient) UpsertPeer(mh string, agentVersionID null.Int, protocolSetID null.Int, ...) (int, error)
- type InsertVisitResult
- type JSONClient
- func (n *JSONClient) Close() error
- func (c *JSONClient) InitCrawl(ctx context.Context, version string) (*models.Crawl, error)
- func (c *JSONClient) PersistCrawlProperties(ctx context.Context, crawl *models.Crawl, properties map[string]map[string]int) error
- func (c *JSONClient) PersistCrawlVisit(ctx context.Context, crawlID int, peerID peer.ID, maddrs []ma.Multiaddr, ...) (*InsertVisitResult, error)
- func (c *JSONClient) PersistNeighbors(ctx context.Context, crawl *models.Crawl, dbPeerID *int, peerID peer.ID, ...) error
- func (c *JSONClient) QueryBootstrapPeers(ctx context.Context, limit int) ([]peer.AddrInfo, error)
- func (c *JSONClient) UpdateCrawl(ctx context.Context, crawl *models.Crawl) error
- type JSONNeighbors
- type JSONVisit
- type NoopClient
- func (n *NoopClient) Close() error
- func (n *NoopClient) InitCrawl(ctx context.Context, version string) (*models.Crawl, error)
- func (n *NoopClient) PersistCrawlProperties(ctx context.Context, crawl *models.Crawl, properties map[string]map[string]int) error
- func (n *NoopClient) PersistCrawlVisit(ctx context.Context, crawlID int, peerID peer.ID, maddrs []ma.Multiaddr, ...) (*InsertVisitResult, error)
- func (n *NoopClient) PersistNeighbors(ctx context.Context, crawl *models.Crawl, dbPeerID *int, peerID peer.ID, ...) error
- func (n *NoopClient) QueryBootstrapPeers(ctx context.Context, limit int) ([]peer.AddrInfo, error)
- func (n *NoopClient) UpdateCrawl(ctx context.Context, crawl *models.Crawl) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrEmptyAgentVersion = fmt.Errorf("empty agent version") ErrEmptyProtocol = fmt.Errorf("empty protocol") ErrEmptyProtocolsSet = fmt.Errorf("empty protocols set") )
var ErrorStr = map[string]string{}
var KnownErrors = map[string]string{ "i/o timeout": models.NetErrorIoTimeout, "RPC timeout": models.NetErrorIoTimeout, "no recent network activity": models.NetErrorIoTimeout, "handshake did not complete in time": models.NetErrorIoTimeout, "connection refused": models.NetErrorConnectionRefused, "connection reset by peer": models.NetErrorConnectionResetByPeer, "protocol not supported": models.NetErrorProtocolNotSupported, "protocols not supported": models.NetErrorProtocolNotSupported, "peer id mismatch": models.NetErrorPeerIDMismatch, "peer IDs don't match": models.NetErrorPeerIDMismatch, "no route to host": models.NetErrorNoRouteToHost, "network is unreachable": models.NetErrorNetworkUnreachable, "no good addresses": models.NetErrorNoGoodAddresses, "context deadline exceeded": models.NetErrorIoTimeout, "no public IP address": models.NetErrorNoIPAddress, "max dial attempts exceeded": models.NetErrorMaxDialAttemptsExceeded, "host is down": models.NetErrorHostIsDown, "stream reset": models.NetErrorStreamReset, "stream closed": models.NetErrorStreamReset, "failed to negotiate security protocol: EOF": models.NetErrorNegotiateSecurityProtocol, "failed to negotiate stream multiplexer": models.NetErrorNegotiateStreamMultiplexer, "resource limit exceeded": models.NetErrorResourceLimitExceeded, "Write on stream": models.NetErrorWriteOnStream, "can't assign requested address": models.NetErrorCantAssignRequestedAddress, "cannot assign requested address": models.NetErrorCantAssignRequestedAddress, "connection gated": models.NetErrorConnectionGated, "RESOURCE_LIMIT_EXCEEDED (201)": models.NetErrorCantConnectOverRelay, "NO_RESERVATION (204)": models.NetErrorCantConnectOverRelay, "no good ip address": models.NetErrorNoIPAddress, "disconnect requested": models.NetErrorDevp2pDisconnectRequested, "network error": models.NetErrorDevp2pNetworkError, "breach of protocol": models.NetErrorDevp2pBreachOfProtocol, "useless peer": models.NetErrorDevp2pUselessPeer, "too many peers": models.NetErrorDevp2pTooManyPeers, "already connected": models.NetErrorDevp2pAlreadyConnected, "incompatible p2p protocol version": models.NetErrorDevp2pIncompatibleP2PProtocolVersion, "invalid node identity": models.NetErrorDevp2pInvalidNodeIdentity, "client quitting": models.NetErrorDevp2pClientQuitting, "unexpected identity": models.NetErrorDevp2pUnexpectedIdentity, "connected to self": models.NetErrorDevp2pConnectedToSelf, "read timeout": models.NetErrorDevp2pReadTimeout, "subprotocol error": models.NetErrorDevp2pSubprotocolError, "could not negotiate eth protocol": models.NetErrorDevp2pEthprotocolError, "handshake failed: EOF": models.NetErrorDevp2pHandshakeEOF, "malformed disconnect message": models.NetErrorDevp2pMalformedDisconnectMessage, }
KnownErrors contains a list of known errors. Property key + string to match for
Functions ¶
Types ¶
type Client ¶
type Client interface { io.Closer InitCrawl(ctx context.Context, version string) (*models.Crawl, error) UpdateCrawl(ctx context.Context, crawl *models.Crawl) error QueryBootstrapPeers(ctx context.Context, limit int) ([]peer.AddrInfo, error) PersistCrawlProperties(ctx context.Context, crawl *models.Crawl, properties map[string]map[string]int) error PersistCrawlVisit(ctx context.Context, crawlID int, peerID peer.ID, maddrs []ma.Multiaddr, protocols []string, agentVersion string, connectDuration time.Duration, crawlDuration time.Duration, visitStartedAt time.Time, visitEndedAt time.Time, connectErrorStr string, crawlErrorStr string, properties null.JSON) (*InsertVisitResult, error) PersistNeighbors(ctx context.Context, crawl *models.Crawl, dbPeerID *int, peerID peer.ID, errorBits uint16, dbNeighborsIDs []int, neighbors []peer.ID) error }
func NewClient ¶
NewClient will initialize the right database client based on the given configuration. This can either be a Postgres, JSON, or noop client. The noop client is a dummy implementation of the Client interface that does nothing when the methods are called. That's the one used if the user specifies `--dry-run` on the command line. The JSON client is used when the user specifies a JSON output directory. Then JSON files with crawl information are written to that directory. In any other case, the Postgres client is used.
type DBClient ¶
type DBClient struct {
// contains filtered or unexported fields
}
func InitDBClient ¶
InitDBClient establishes a database connection with the provided configuration and applies any pending migrations.
func (*DBClient) FetchDueOpenSessions ¶
FetchDueOpenSessions fetches all open sessions from the database that are due.
func (*DBClient) FetchUnresolvedMultiAddresses ¶
func (c *DBClient) FetchUnresolvedMultiAddresses(ctx context.Context, limit int) (models.MultiAddressSlice, error)
FetchUnresolvedMultiAddresses fetches all multi addresses that were not resolved yet.
func (*DBClient) GetOrCreateAgentVersionID ¶
func (*DBClient) GetOrCreateProtocol ¶
func (*DBClient) GetOrCreateProtocolsSetID ¶
func (*DBClient) InitCrawl ¶
InitCrawl inserts a crawl instance into the database in the state `started`. This is done to receive a database ID that all subsequent database entities can be linked to.
func (*DBClient) PersistCrawlProperties ¶
func (*DBClient) PersistCrawlVisit ¶
func (c *DBClient) PersistCrawlVisit( ctx context.Context, crawlID int, peerID peer.ID, maddrs []ma.Multiaddr, protocols []string, agentVersion string, connectDuration time.Duration, crawlDuration time.Duration, visitStartedAt time.Time, visitEndedAt time.Time, connectErrorStr string, crawlErrorStr string, properties null.JSON, ) (*InsertVisitResult, error)
func (*DBClient) PersistDialVisit ¶
func (*DBClient) PersistNeighbors ¶
func (*DBClient) QueryBootstrapPeers ¶
func (*DBClient) UpdateCrawl ¶
UpdateCrawl takes the crawl model an updates it in the database.
type InsertVisitResult ¶
func (*InsertVisitResult) Scan ¶
func (ivr *InsertVisitResult) Scan(value interface{}) error
type JSONClient ¶
type JSONClient struct {
// contains filtered or unexported fields
}
func (*JSONClient) Close ¶
func (n *JSONClient) Close() error
func (*JSONClient) PersistCrawlProperties ¶
func (*JSONClient) PersistCrawlVisit ¶
func (c *JSONClient) PersistCrawlVisit(ctx context.Context, crawlID int, peerID peer.ID, maddrs []ma.Multiaddr, protocols []string, agentVersion string, connectDuration time.Duration, crawlDuration time.Duration, visitStartedAt time.Time, visitEndedAt time.Time, connectErrorStr string, crawlErrorStr string, properties null.JSON) (*InsertVisitResult, error)
func (*JSONClient) PersistNeighbors ¶
func (*JSONClient) QueryBootstrapPeers ¶
func (*JSONClient) UpdateCrawl ¶
type JSONNeighbors ¶
type NoopClient ¶
type NoopClient struct{}
func InitNoopClient ¶
func InitNoopClient() *NoopClient
func (*NoopClient) Close ¶
func (n *NoopClient) Close() error
func (*NoopClient) PersistCrawlProperties ¶
func (*NoopClient) PersistCrawlVisit ¶
func (n *NoopClient) PersistCrawlVisit(ctx context.Context, crawlID int, peerID peer.ID, maddrs []ma.Multiaddr, protocols []string, agentVersion string, connectDuration time.Duration, crawlDuration time.Duration, visitStartedAt time.Time, visitEndedAt time.Time, connectErrorStr string, crawlErrorStr string, properties null.JSON) (*InsertVisitResult, error)