rpc

package
v0.0.0-...-bd43069 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoCheckpoint = errors.New("rpc: no checkpoint file for task")

ErrNoCheckpoint is returned when a checkpoint does not exist for the task

Functions

func GetDevicesInUse

func GetDevicesInUse(d shared.DeviceMap) storage.CLDevices

GetDevicesInUse returns a list of CLDevices inuse from a DeviceMap object

func WrapCallError

func WrapCallError(f RPCAPI) gin.HandlerFunc

Types

type BeaconPayloadType

type BeaconPayloadType uint8

BeaconPayloadType describes the type of payload being sent to the worker

const (
	// BeaconNewTask indicates the BeaconResponse.Payload is a "NewTask"
	BeaconNewTask BeaconPayloadType = 1 << iota
	// BeaconChangeTaskStatus indicates that the payload should be parsed as a task status change
	BeaconChangeTaskStatus
)

type BeaconRequest

type BeaconRequest shared.Beacon

BeaconRequest describes the payload sent by the worker to the server

type BeaconResponse

type BeaconResponse struct {
	Payloads   []PayloadItem
	ServerTime time.Time
}

BeaconResponse describes the payload sent to the worker on a beacon

type ChangeTaskStatus

type ChangeTaskStatus struct {
	TaskID    string
	NewStatus storage.TaskStatus
}

ChangeTaskStatus describes the payload sent to the worker

type ChangeTaskStatusRequest

type ChangeTaskStatusRequest struct {
	TaskID    string
	NewStatus storage.TaskStatus
	Error     *string
}

type Config

type Config struct {
	Listener shared.ServerCfg `yaml:"listener"`
}

Config describes the configuration used by the GoCrack RPC Listener.

func (*Config) Validate

func (s *Config) Validate() error

Validate the config and set any default options

type CrackedPasswordRequest

type CrackedPasswordRequest struct {
	TaskID    string
	Hash      string
	Value     string
	CrackedAt time.Time
}

type FileType

type FileType uint8
const (
	FileTypeTask FileType = 1 << iota
	FileTypeEngine
)

type GoCrackRPC

type GoCrackRPC interface {
	Beacon(BeaconRequest) (*BeaconResponse, error)
	ChangeTaskStatus(ChangeTaskStatusRequest) error
	GetTask(RequestTaskPayload) (*NewTaskPayloadResponse, error)
	GetFile(TaskFileGetRequest) (io.ReadCloser, string, error)
	SavedCrackedPassword(CrackedPasswordRequest) error
	SendTaskStatus(TaskStatusUpdate) error
	GetCheckpointFile(string) ([]byte, error)
	SendCheckpointFile(TaskCheckpointSaveRequest) error
}

GoCrackRPC describes all the methods that a worker uses to send updates to the server

type NewTask

type NewTask struct {
	ID       string
	Engine   storage.WorkerCrackEngine
	Priority storage.WorkerPriority
	Devices  storage.CLDevices
}

NewTask describes the payload sent to the worker when a task should be executed

type NewTaskPayloadResponse

type NewTaskPayloadResponse struct {
	TaskID        string
	FileID        string
	Engine        storage.WorkerCrackEngine
	Priority      storage.WorkerPriority
	EnginePayload json.RawMessage
	TaskDuration  int
}

type PayloadItem

type PayloadItem struct {
	Type BeaconPayloadType
	Data json.RawMessage
}

PayloadItem is an item that contains data for a BeaconResponse where the data is unmarshalled based on it's Type

type RPCAPI

type RPCAPI func(c *gin.Context) *RPCError

type RPCError

type RPCError struct {
	StatusCode int
	Err        error
}

type RPCServer

type RPCServer struct {
	*http.Server
	// contains filtered or unexported fields
}

func NewRPCServer

func NewRPCServer(cfg Config, stor storage.Backend, wmgr *workmgr.WorkerManager) (*RPCServer, error)

NewRPCServer creates an RPC server that workers connect to

func (*RPCServer) Address

func (s *RPCServer) Address() string

Address returns the listening address of the RPC server

func (*RPCServer) ServeHTTP

func (s *RPCServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*RPCServer) Start

func (s *RPCServer) Start() error

Start the RPC server and handle requests from workers

func (*RPCServer) Stop

func (s *RPCServer) Stop() error

Stop the RPC server gracefully

type RequestTaskPayload

type RequestTaskPayload struct {
	TaskID string
}

type TaskCheckpointSaveRequest

type TaskCheckpointSaveRequest struct {
	TaskID string
	Data   []byte
}

type TaskFileGetRequest

type TaskFileGetRequest struct {
	FileID string
	Type   FileType
}

type TaskStatusUpdate

type TaskStatusUpdate struct {
	Engine  storage.WorkerCrackEngine
	TaskID  string
	Final   bool
	Payload interface{}
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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