chserver

package
v0.0.0-...-36fb464 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: MIT Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AIListenerRequest

type AIListenerRequest struct {
	Name         string `json:"name"`
	Port         int    `json:"port"`
	Mode         string `json:"mode"`
	AIProviderID string `json:"ai_provider_id"`
	OpenAPISpec  string `json:"openapi_spec"`
	SystemPrompt string `json:"system_prompt"`
	UseTLS       bool   `json:"use_tls"`
}

AIListenerRequest represents the request payload for creating AI listeners

type AIProviderRequest

type AIProviderRequest struct {
	Name         string  `json:"name"`
	ProviderType string  `json:"provider_type"`
	APIKey       string  `json:"api_key"`
	APIEndpoint  string  `json:"api_endpoint"`
	Model        string  `json:"model"`
	MaxTokens    int     `json:"max_tokens"`
	Temperature  float64 `json:"temperature"`
	Enabled      bool    `json:"enabled"`
}

AIProviderRequest represents the request payload for creating/updating AI providers

func DefaultAIProviderConfig

func DefaultAIProviderConfig(providerType string) AIProviderRequest

DefaultAIProviderConfig returns default configuration for different providers

type AIProviderTestResult

type AIProviderTestResult struct {
	Status  string `json:"status"` // "success" or "failed"
	Message string `json:"message"`
}

AIProviderTestResult represents the result of testing an AI provider

type ActiveListener

type ActiveListener struct {
	ID         string
	Config     *database.Listener
	Server     *http.Server
	Cancel     context.CancelFunc
	TapFactory tunnel.TapFactory
}

ActiveListener represents a running HTTP listener

type ActiveMulticast

type ActiveMulticast struct {
	ID     string
	Config *database.MulticastTunnel
	Server *http.Server
	Cancel context.CancelFunc
	// contains filtered or unexported fields
}

type Config

type Config struct {
	KeySeed   string
	KeyFile   string
	AuthFile  string
	Auth      string
	Proxy     string
	Reverse   bool
	KeepAlive time.Duration
	TLS       TLSConfig
	TlsConf   *tls.Config
	Database  *database.DatabaseConfig
	Auth0     *auth.Auth0Config
	Dashboard DashboardConfig
	LogDir    string
	// Security-related server settings
	Security SecurityConfig
}

Config is the configuration for the chisel service

type ConversationMessage

type ConversationMessage struct {
	Role      string    `json:"role"` // "user", "assistant", "system"
	Content   string    `json:"content"`
	Timestamp time.Time `json:"timestamp"`
}

ConversationMessage represents a message in the AI conversation

type DashboardConfig

type DashboardConfig struct {
	Enabled bool
	Path    string
}

DashboardConfig holds dashboard configuration

type EnhancedListener

type EnhancedListener struct {
	*database.Listener
	Active             bool   `json:"active"` // Computed from Status field
	AIGenerationStatus string `json:"ai_generation_status,omitempty"`
	AIProviderName     string `json:"ai_provider_name,omitempty"`
	AIProviderType     string `json:"ai_provider_type,omitempty"`
	AIGenerationError  string `json:"ai_generation_error,omitempty"`
}

EnhancedListener represents a listener with AI information

type IPRateLimitConfig

type IPRateLimitConfig struct {
	MaxPerMinute int `json:"max_per_minute"`
	BanMinutes   int `json:"ban_minutes"`
}

IPRateLimitConfig controls IP-level request caps independent of username

type ListenerManager

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

ListenerManager manages HTTP listeners/proxies

func NewListenerManager

func NewListenerManager(captureService *capture.Service, db database.Database, tlsConfig *tls.Config) *ListenerManager

NewListenerManager creates a new listener manager

func (*ListenerManager) GetActiveListener

func (lm *ListenerManager) GetActiveListener(listenerID string) (*ActiveListener, bool)

GetActiveListener returns an active listener by ID

func (*ListenerManager) ListActiveListeners

func (lm *ListenerManager) ListActiveListeners() []*ActiveListener

ListActiveListeners returns all active listeners

func (*ListenerManager) StartListener

func (lm *ListenerManager) StartListener(config *database.Listener, tapFactory tunnel.TapFactory) error

StartListener starts a new HTTP listener

func (*ListenerManager) StopListener

func (lm *ListenerManager) StopListener(listenerID string) error

StopListener stops a running listener

func (*ListenerManager) UpdateTLSConfig

func (lm *ListenerManager) UpdateTLSConfig(tlsConfig *tls.Config)

UpdateTLSConfig updates the TLS configuration for the listener manager

type LogEntry

type LogEntry struct {
	Timestamp time.Time `json:"timestamp"`
	Level     string    `json:"level"`
	Message   string    `json:"message"`
	Source    string    `json:"source,omitempty"`
}

LogEntry represents a single log entry

type LogFileContentResponse

type LogFileContentResponse struct {
	Filename string   `json:"filename"`
	Lines    []string `json:"lines"`
	Total    int      `json:"total"`
}

LogFileContentResponse represents the response for log file content

type LogFileInfo

type LogFileInfo struct {
	Name         string `json:"name"`
	Size         int64  `json:"size"`
	ModifiedTime string `json:"modified_time"`
}

LogFileInfo represents information about a log file

type LogFilesResponse

type LogFilesResponse struct {
	Files []LogFileInfo `json:"files"`
}

LogFilesResponse represents the response for log files API

type LogManager

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

LogManager handles log storage and retrieval

func NewLogManager

func NewLogManager(logDir string) (*LogManager, error)

NewLogManager creates a new log manager

func (*LogManager) Close

func (lm *LogManager) Close() error

Close closes the log manager

func (*LogManager) GetLogFiles

func (lm *LogManager) GetLogFiles() ([]string, error)

GetLogFiles returns available log files

func (*LogManager) GetRecentLogs

func (lm *LogManager) GetRecentLogs(limit int) []LogEntry

GetRecentLogs returns recent log entries

func (*LogManager) ReadLogFile

func (lm *LogManager) ReadLogFile(filename string, lines int) ([]string, error)

ReadLogFile reads a specific log file

func (*LogManager) WriteLog

func (lm *LogManager) WriteLog(level, message, source string)

WriteLog writes a log entry to file and memory

type LogWriter

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

LogWriter implements io.Writer interface for integration with standard loggers

func NewLogWriter

func NewLogWriter(logManager *LogManager, level, source string) *LogWriter

NewLogWriter creates a new log writer

func (*LogWriter) Write

func (lw *LogWriter) Write(p []byte) (n int, err error)

Write implements io.Writer

type LoginBackoffConfig

type LoginBackoffConfig struct {
	BaseDelayMS      int  `json:"base_delay_ms"`
	MaxDelayMS       int  `json:"max_delay_ms"`
	MaxExponent      int  `json:"max_exponent"`
	HardLockFailures int  `json:"hard_lock_failures"`
	HardLockMinutes  int  `json:"hard_lock_minutes"`
	PerIPEnabled     bool `json:"per_ip_enabled"`
}

LoginBackoffConfig controls login rate limiting/backoff behavior Durations are expressed as milliseconds/minutes for easy JSON handling.

type LogsResponse

type LogsResponse struct {
	Logs       []LogEntry `json:"logs"`
	TotalCount int        `json:"total_count"`
	HasMore    bool       `json:"has_more"`
}

LogsResponse represents the response for logs API

type MulticastManager

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

MulticastManager manages persistent HTTPS endpoints that broadcast inbound requests to all subscribers via capture SSE.

func NewMulticastManager

func NewMulticastManager(captureSvc *capture.Service, db database.Database, tlsConf *tls.Config) *MulticastManager

func (*MulticastManager) AddSubscriber

func (m *MulticastManager) AddSubscriber(port int, sub *subscriber) error

func (*MulticastManager) RemoveSubscriber

func (m *MulticastManager) RemoveSubscriber(port int, subID string)

func (*MulticastManager) StartMulticast

func (m *MulticastManager) StartMulticast(cfg *database.MulticastTunnel) error

StartMulticast starts an HTTPS server for the given config (webhook mode only in phase 1)

func (*MulticastManager) StopMulticast

func (m *MulticastManager) StopMulticast(id string) error

func (*MulticastManager) UpdateTLSConfig

func (m *MulticastManager) UpdateTLSConfig(tlsConf *tls.Config)

type OpenAIMessage

type OpenAIMessage struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

OpenAIMessage represents a message in the OpenAI conversation

type OpenAIRequest

type OpenAIRequest struct {
	Model       string          `json:"model"`
	Messages    []OpenAIMessage `json:"messages"`
	MaxTokens   int             `json:"max_tokens,omitempty"`
	Temperature float64         `json:"temperature,omitempty"`
}

OpenAIRequest represents the request structure for OpenAI API

type OpenAIResponse

type OpenAIResponse struct {
	Choices []struct {
		Message struct {
			Content string `json:"content"`
		} `json:"message"`
	} `json:"choices"`
	Error *struct {
		Message string `json:"message"`
		Type    string `json:"type"`
	} `json:"error,omitempty"`
}

OpenAIResponse represents the response from OpenAI API

type SSOConfigRequest

type SSOConfigRequest struct {
	Provider database.SSOProvider `json:"provider"`
	Enabled  bool                 `json:"enabled"`
	Config   json.RawMessage      `json:"config"`
}

SSOConfigRequest represents SSO configuration request

type SSOConfigResponse

type SSOConfigResponse struct {
	*database.SSOConfig
	TestURL string `json:"test_url,omitempty"`
}

SSOConfigResponse represents SSO configuration response

type SecurityConfig

type SecurityConfig struct {
	LoginBackoff      LoginBackoffConfig `json:"login_backoff"`
	IPRate            IPRateLimitConfig  `json:"ip_rate"`
	SessionTTLMinutes int                `json:"session_ttl_minutes"`
}

SecurityConfig groups security-related settings

type SecurityEvent

type SecurityEvent struct {
	Type     string    `json:"type"`
	Severity string    `json:"severity"`
	Username string    `json:"username"`
	IP       string    `json:"ip"`
	At       time.Time `json:"at"`
	Message  string    `json:"message"`
}

SecurityEvent captures notable security actions

type Server

type Server struct {
	*cio.Logger
	// contains filtered or unexported fields
}

Server respresent a chisel service

func NewServer

func NewServer(c *Config) (*Server, error)

NewServer creates and returns a new chisel server

func (*Server) AddUser

func (s *Server) AddUser(user, pass string, addrs ...string) error

func (*Server) BasicAuthMiddleware

func (s *Server) BasicAuthMiddleware(next http.HandlerFunc) http.HandlerFunc

BasicAuthMiddleware is an exported version of basicAuthMiddleware for testing

func (*Server) Close

func (s *Server) Close() error

Close forcibly closes the http server

func (*Server) CombinedAuthMiddleware

func (s *Server) CombinedAuthMiddleware(next http.HandlerFunc) http.HandlerFunc

CombinedAuthMiddleware is an exported version of combinedAuthMiddleware for testing

func (*Server) Debugf

func (s *Server) Debugf(f string, args ...interface{})

func (*Server) DeleteUser

func (s *Server) DeleteUser(user string)

DeleteUser removes a user from the server user index

func (*Server) Errorf

func (s *Server) Errorf(f string, args ...interface{}) error

func (*Server) GetFingerprint

func (s *Server) GetFingerprint() string

GetFingerprint is used to access the server fingerprint

func (*Server) HTTPHandler

func (s *Server) HTTPHandler() http.Handler

HTTPHandler exposes the main HTTP handler for testing

func (*Server) HandleDeleteUser

func (s *Server) HandleDeleteUser(w http.ResponseWriter, r *http.Request)

HandleDeleteUser is an exported version of handleDeleteUser for testing

func (*Server) Infof

func (s *Server) Infof(f string, args ...interface{})

Override logging methods to also write to log manager

func (*Server) ResetUsers

func (s *Server) ResetUsers(users []*settings.User)

ResetUsers in the server user index. Use nil to remove all.

func (*Server) Run

func (s *Server) Run(host, port string) error

Run is responsible for starting the chisel service. Internally this calls Start then Wait.

func (*Server) Shutdown

func (s *Server) Shutdown() error

Shutdown gracefully closes the HTTP server, database, and log manager

func (*Server) Start

func (s *Server) Start(host, port string) error

Start is responsible for kicking off the http server

func (*Server) StartContext

func (s *Server) StartContext(ctx context.Context, host, port string) error

StartContext is responsible for kicking off the http server, and can be closed by cancelling the provided context

func (*Server) UserAuthMiddleware

func (s *Server) UserAuthMiddleware(next http.HandlerFunc) http.HandlerFunc

UserAuthMiddleware is an exported version of userAuthMiddleware for testing

func (*Server) Wait

func (s *Server) Wait() error

Wait waits for the http server to close

type TLSConfig

type TLSConfig struct {
	Key     string
	Cert    string
	Domains []string
	CA      string
}

TLSConfig enables configures TLS

type UpdateUserRequest

type UpdateUserRequest struct {
	Name    string           `json:"username"`
	Pass    string           `json:"password,omitempty"`
	Addrs   []*regexp.Regexp `json:"addresses,omitempty"`
	IsAdmin bool             `json:"is_admin"`
}

type UserInfo

type UserInfo struct {
	Username       string `json:"username"`
	Email          string `json:"email,omitempty"`
	DisplayName    string `json:"display_name,omitempty"`
	IsAdmin        bool   `json:"admin"`
	SSOEnabled     bool   `json:"sso_enabled"`
	CanEditProfile bool   `json:"can_edit_profile"`
	AuthMethod     string `json:"auth_method,omitempty"`
}

UserInfo represents user information for the frontend

type UserToken

type UserToken struct {
	ID        string     `json:"id"`
	Name      string     `json:"name"`
	Token     string     `json:"token,omitempty"` // Only included when creating
	CreatedAt time.Time  `json:"created_at"`
	LastUsed  *time.Time `json:"last_used,omitempty"`
	ExpiresAt *time.Time `json:"expires_at,omitempty"`
}

UserToken represents an API token

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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