Documentation
¶
Index ¶
- type AgentTx
- type Config
- type ConfigResponse
- type EthConnectionValidator
- type FD
- type HTTPAuthConfig
- func (cfg *HTTPAuthConfig) AddUser(username string, plaintextPassword string, perms []string) error
- func (cfg *HTTPAuthConfig) CheckAuth(method string) gin.HandlerFunc
- func (cfg *HTTPAuthConfig) CheckFilePermissions() error
- func (cfg *HTTPAuthConfig) ConfirmAgentUser(username string) error
- func (cfg *HTTPAuthConfig) ConfirmOrDeclineAllowanceRequest(username string, token string, isConfirmed bool) error
- func (cfg *HTTPAuthConfig) DeclineAgentUser(username string) error
- func (cfg *HTTPAuthConfig) DecreaseAllowance(username string, token string, amount lib.BigInt) error
- func (cfg *HTTPAuthConfig) EnsureConfigFilesExist() error
- func (cfg *HTTPAuthConfig) GetAgentTxs(username string, cursor []byte, limit uint) ([]string, []byte, error)
- func (cfg *HTTPAuthConfig) GetAgentUsers() ([]*storages.AgentUser, error)
- func (cfg *HTTPAuthConfig) GetAllowanceRequests() ([]*storages.AllowanceRequest, error)
- func (cfg *HTTPAuthConfig) IsAllowanceEnough(username string, token string, amount *big.Int) (bool, error)
- func (cfg *HTTPAuthConfig) IsMethodAllowed(username, method string) bool
- func (cfg *HTTPAuthConfig) ParseBasicAuthHeader(header string) (string, string)
- func (cfg *HTTPAuthConfig) ReadConfig() error
- func (cfg *HTTPAuthConfig) ReadCookieFile() (string, string, error)
- func (cfg *HTTPAuthConfig) RemoveAgentUser(username string) error
- func (cfg *HTTPAuthConfig) RemoveUser(username string) error
- func (cfg *HTTPAuthConfig) RequestAgentUser(username, password string, perms []string, allowances map[string]string) error
- func (cfg *HTTPAuthConfig) RequestAllowance(username string, token string, allowance lib.BigInt) error
- func (cfg *HTTPAuthConfig) RevokeAllowance(username string, token string) error
- func (cfg *HTTPAuthConfig) UpdateCookieContent(cookieLine string) error
- func (cfg *HTTPAuthConfig) ValidatePassword(username, password string) bool
- func (cfg *HTTPAuthConfig) WriteConfig() error
- type HTTPAuthEntry
- type HealthCheckResponse
- type IEthConnectionValidator
- type LinuxConfigurator
- type SetEthNodeURLReq
- type StatusRes
- type SystemConfigurator
- type SystemController
- func (s *SystemController) GetConfig(ctx *gin.Context)
- func (s *SystemController) GetFiles(ctx *gin.Context)
- func (s *SystemController) HealthCheck(ctx *gin.Context)
- func (s *SystemController) RegisterRoutes(r i.Router)
- func (c *SystemController) RemoveEthNode(ctx *gin.Context)
- func (s *SystemController) SetEthNode(ctx *gin.Context)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigResponse ¶
type EthConnectionValidator ¶
type EthConnectionValidator struct {
// contains filtered or unexported fields
}
func NewEthConnectionValidator ¶
func NewEthConnectionValidator(chainId big.Int) *EthConnectionValidator
func (*EthConnectionValidator) ValidateEthResourse ¶
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 (*HTTPAuthConfig) EnsureConfigFilesExist ¶
func (cfg *HTTPAuthConfig) EnsureConfigFilesExist() error
EnsureConfigFilesExist checks if cookie file exists; if not, creates it with admin credentials.
func (*HTTPAuthConfig) GetAgentTxs ¶
func (*HTTPAuthConfig) GetAgentUsers ¶
func (cfg *HTTPAuthConfig) GetAgentUsers() ([]*storages.AgentUser, error)
func (*HTTPAuthConfig) GetAllowanceRequests ¶
func (cfg *HTTPAuthConfig) GetAllowanceRequests() ([]*storages.AllowanceRequest, error)
func (*HTTPAuthConfig) IsAllowanceEnough ¶
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 (*HTTPAuthConfig) RequestAllowance ¶
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 ¶
HTTPAuthEntry holds the parsed username, salt, and hash from rpcauth lines.
type HealthCheckResponse ¶
type IEthConnectionValidator ¶
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 ¶
type SetEthNodeURLReq ¶
type SetEthNodeURLReq struct {
URLs []string `json:"urls" binding:"required" validate:"required,url"`
}
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 (*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]