system

package
v0.0.0-...-5b1178b Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2025 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentTx

type AgentTx struct {
	TxHash   string
	Username string
}

type Config

type Config struct {
	LocalPortRange   string
	TcpMaxSynBacklog string
	Somaxconn        string
	NetdevMaxBacklog string
	RlimitSoft       uint64
	RlimitHard       uint64
}

type ConfigResponse

type ConfigResponse struct {
	Version       string
	Commit        string
	DerivedConfig interface{}
	Config        interface{}
}

type EthConnectionValidator

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

func NewEthConnectionValidator

func NewEthConnectionValidator(chainId big.Int) *EthConnectionValidator

func (*EthConnectionValidator) ValidateEthResourse

func (v *EthConnectionValidator) ValidateEthResourse(ctx context.Context, url string, timeout time.Duration) error

type FD

type FD struct {
	ID   string
	Path string
}

type HTTPAuthConfig

type HTTPAuthConfig struct {
	FilePath         string
	CookieFilePath   string
	CookieContent    string
	AuthEntries      map[string]*HTTPAuthEntry // keyed by username
	Whitelists       map[string][]string       // keyed by username
	WhitelistDefault bool                      // true => methods allowed if not listed

	AuthStorage *storages.AuthStorage
}

HTTPAuthConfig is our main struct to manage the config file and (optionally) a cookie file.

func NewAuthConfig

func NewAuthConfig(configFilePath, cookieFilePath string, cookieContent string, authStorage *storages.AuthStorage) *HTTPAuthConfig

NewAuthConfig initializes an empty RPCConfig struct, pointing to config + cookie paths.

func (*HTTPAuthConfig) AddUser

func (cfg *HTTPAuthConfig) AddUser(username string, plaintextPassword string, perms []string) error

func (*HTTPAuthConfig) CheckAuth

func (cfg *HTTPAuthConfig) CheckAuth(method string) gin.HandlerFunc

func (*HTTPAuthConfig) CheckFilePermissions

func (cfg *HTTPAuthConfig) CheckFilePermissions() error

CheckFilePermissions ensures the config file is only readable by the owner (chmod 600).

func (*HTTPAuthConfig) ConfirmAgentUser

func (cfg *HTTPAuthConfig) ConfirmAgentUser(username string) error

func (*HTTPAuthConfig) ConfirmOrDeclineAllowanceRequest

func (cfg *HTTPAuthConfig) ConfirmOrDeclineAllowanceRequest(username string, token string, isConfirmed bool) error

func (*HTTPAuthConfig) DeclineAgentUser

func (cfg *HTTPAuthConfig) DeclineAgentUser(username string) error

func (*HTTPAuthConfig) DecreaseAllowance

func (cfg *HTTPAuthConfig) DecreaseAllowance(username string, token string, amount lib.BigInt) error

func (*HTTPAuthConfig) EnsureConfigFilesExist

func (cfg *HTTPAuthConfig) EnsureConfigFilesExist() error

EnsureConfigFilesExist checks if cookie file exists; if not, creates it with admin credentials.

func (*HTTPAuthConfig) GetAgentTxs

func (cfg *HTTPAuthConfig) GetAgentTxs(username string, cursor []byte, limit uint) ([]string, []byte, error)

func (*HTTPAuthConfig) GetAgentUsers

func (cfg *HTTPAuthConfig) GetAgentUsers() ([]*storages.AgentUser, error)

func (*HTTPAuthConfig) GetAllowanceRequests

func (cfg *HTTPAuthConfig) GetAllowanceRequests() ([]*storages.AllowanceRequest, error)

func (*HTTPAuthConfig) IsAllowanceEnough

func (cfg *HTTPAuthConfig) IsAllowanceEnough(username string, token string, amount *big.Int) (bool, error)

func (*HTTPAuthConfig) IsMethodAllowed

func (cfg *HTTPAuthConfig) IsMethodAllowed(username, method string) bool

IsMethodAllowed checks if a given user is allowed to call a specific RPC method.

func (*HTTPAuthConfig) ParseBasicAuthHeader

func (cfg *HTTPAuthConfig) ParseBasicAuthHeader(header string) (string, string)

func (*HTTPAuthConfig) ReadConfig

func (cfg *HTTPAuthConfig) ReadConfig() error

ReadConfig reads and parses the config file from disk.

func (*HTTPAuthConfig) ReadCookieFile

func (cfg *HTTPAuthConfig) ReadCookieFile() (string, string, error)

func (*HTTPAuthConfig) RemoveAgentUser

func (cfg *HTTPAuthConfig) RemoveAgentUser(username string) error

func (*HTTPAuthConfig) RemoveUser

func (cfg *HTTPAuthConfig) RemoveUser(username string) error

func (*HTTPAuthConfig) RequestAgentUser

func (cfg *HTTPAuthConfig) RequestAgentUser(username, password string, perms []string, allowances map[string]string) error

func (*HTTPAuthConfig) RequestAllowance

func (cfg *HTTPAuthConfig) RequestAllowance(username string, token string, allowance lib.BigInt) error

func (*HTTPAuthConfig) RevokeAllowance

func (cfg *HTTPAuthConfig) RevokeAllowance(username string, token string) error

func (*HTTPAuthConfig) UpdateCookieContent

func (cfg *HTTPAuthConfig) UpdateCookieContent(cookieLine string) error

func (*HTTPAuthConfig) ValidatePassword

func (cfg *HTTPAuthConfig) ValidatePassword(username, password string) bool

ValidatePassword checks a user's plaintext password against the HMAC-based hash.

func (*HTTPAuthConfig) WriteConfig

func (cfg *HTTPAuthConfig) WriteConfig() error

WriteConfig writes the current in-memory config to disk with file perms 0600.

type HTTPAuthEntry

type HTTPAuthEntry struct {
	Username string
	Salt     string
	Hash     string
}

HTTPAuthEntry holds the parsed username, salt, and hash from rpcauth lines.

type HealthCheckResponse

type HealthCheckResponse struct {
	Status  string
	Version string
	Uptime  string
}

type IEthConnectionValidator

type IEthConnectionValidator interface {
	ValidateEthResourse(ctx context.Context, url string, timeout time.Duration) error
}

type LinuxConfigurator

type LinuxConfigurator struct {
}

func NewOSConfigurator

func NewOSConfigurator() *LinuxConfigurator

func (*LinuxConfigurator) ApplyConfig

func (c *LinuxConfigurator) ApplyConfig(cfg *Config) error

func (*LinuxConfigurator) GetConfig

func (c *LinuxConfigurator) GetConfig() (*Config, error)

func (*LinuxConfigurator) GetFileDescriptors

func (*LinuxConfigurator) GetFileDescriptors(ctx context.Context, pid int) ([]FD, error)

type SetEthNodeURLReq

type SetEthNodeURLReq struct {
	URLs []string `json:"urls" binding:"required" validate:"required,url"`
}

type StatusRes

type StatusRes struct {
	Status string `json:"status"`
}

func OkRes

func OkRes() StatusRes

type SystemConfigurator

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

func CreateConfigurator

func CreateConfigurator(log lib.ILogger) *SystemConfigurator

func NewConfigurator

func NewConfigurator(osConfigurator osConfigurator, log lib.ILogger) *SystemConfigurator

func (*SystemConfigurator) ApplyConfig

func (c *SystemConfigurator) ApplyConfig(cfg *Config) error

func (*SystemConfigurator) GetConfig

func (c *SystemConfigurator) GetConfig() (*Config, error)

func (*SystemConfigurator) GetFileDescriptors

func (c *SystemConfigurator) GetFileDescriptors(ctx context.Context, pid int) ([]FD, error)

func (*SystemConfigurator) RestoreConfig

func (c *SystemConfigurator) RestoreConfig() error

type SystemController

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

func NewSystemController

func NewSystemController(config *config.Config, wallet i.Wallet, ethRPC i.RPCEndpoints, sysConfig *SystemConfigurator, appStartTime time.Time, chainID *big.Int, log lib.ILogger, ethConnectionValidator IEthConnectionValidator, authConfig HTTPAuthConfig) *SystemController

func (*SystemController) GetConfig

func (s *SystemController) GetConfig(ctx *gin.Context)

GetConfig godoc

@Summary		Get Config
@Description	Return the current config of proxy router
@Tags			system
@Produce		json
@Success		200	{object}	ConfigResponse
@Security		BasicAuth
@Router			/config [get]

func (*SystemController) GetFiles

func (s *SystemController) GetFiles(ctx *gin.Context)

GetFiles godoc

@Summary		Get files
@Description	Returns opened files
@Tags			system
@Produce		json
@Success		200	{object}	[]FD
@Security		BasicAuth
@Router			/files [get]

func (*SystemController) HealthCheck

func (s *SystemController) HealthCheck(ctx *gin.Context)

HealthCheck godoc

@Summary		Healthcheck example
@Description	do ping
@Tags			system
@Produce		json
@Success		200	{object}	HealthCheckResponse
@Router			/healthcheck [get]

func (*SystemController) RegisterRoutes

func (s *SystemController) RegisterRoutes(r i.Router)

func (*SystemController) RemoveEthNode

func (c *SystemController) RemoveEthNode(ctx *gin.Context)

DeleteEthNode godoc

@Summary		Delete Eth Node URLs
@Description	Delete the Eth Node URLs
@Tags			system
@Produce		json
@Success		200	{object}	StatusRes
@Security		BasicAuth
@Router			/config/ethNode [delete]

func (*SystemController) SetEthNode

func (s *SystemController) SetEthNode(ctx *gin.Context)

SetEthNode godoc

@Summary		Set Eth Node URLs
@Description	Set the Eth Node URLs
@Tags			system
@Accept			json
@Produce		json
@Param			urls	body		SetEthNodeURLReq	true	"URLs"
@Success		200		{object}	StatusRes
@Security		BasicAuth
@Router			/config/ethNode [post]

Jump to

Keyboard shortcuts

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