app

package
v0.29.1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 60 Imported by: 0

Documentation

Index

Constants

View Source
const SORT_GAP = 1000

Variables

View Source
var ProxyColors = []string{
	"#6d8086",
	"#519aba",
	"#8dc149",
	"#e37933",
	"#f55385",
	"#a074c4",
	"#EE6167",
	"#d19a66",
	"#cbcb41",
	"#e5c07b",
	"#e06c75",
	"#56b6c2",
	"#abb2bf",
	"#61afef",
	"#98c379",
	"#c678dd",
}

ProxyColors are the colors available for proxy instances, matching the frontend colors.ts

View Source
var ProxyMgr = &ProxyManager{
	instances: make(map[string]*ProxyInstance),
}

Global proxy manager instance

Functions

func DropReqResp

func DropReqResp(req *http.Request) *http.Response

func GetSortOrder

func GetSortOrder(items []*models.Record) int

func NextProxyColor added in v0.29.0

func NextProxyColor(existingCount int) string

NextProxyColor returns a color for a new proxy based on the current proxy count. Cycles through the list so colors repeat after all are used.

func NotifyInterceptUpdate

func NotifyInterceptUpdate(id string, update InterceptUpdate)

NotifyInterceptUpdate sends an update to the waiting goroutine

func RegisterInterceptChannel

func RegisterInterceptChannel(id string, ch chan InterceptUpdate)

RegisterInterceptChannel registers a channel for a specific intercept ID

func RequestDeleteKey

func RequestDeleteKey(requestData map[string]any, key string)

func RequestReplace

func RequestReplace(requestData map[string]any, search string, value string, isRegex bool)

func RequestUpdateKey

func RequestUpdateKey(requestData map[string]any, key string, value any)

func SendHTTP2RawRequest

func SendHTTP2RawRequest(data RawRequest) (string, string, error)

func SendHTTPRawRequest

func SendHTTPRawRequest(data RawRequest) (string, string, error)

func SendRawHTTPRequest

func SendRawHTTPRequest(host, port string, tls bool, request string, timeout time.Duration, http2 bool) (string, string, error)

SendRawHTTPRequest sends a raw HTTP request using the rawhttp client and returns response, time taken, and error

func UnregisterInterceptChannel

func UnregisterInterceptChannel(id string)

UnregisterInterceptChannel removes the channel for a specific intercept ID

Types

type Backend

type Backend struct {
	App              *pocketbase.PocketBase
	Config           *config.Config
	Cook             *cook.CookGenerator
	Wappalyzer       *wappalyzer.Wappalyze
	CmdChannel       chan process.RunCommandData
	CounterManager   *CounterManager
	XtermManager     *XtermManager
	MCP              *MCP
	Templates        *templates.Templates
	TemplatesEnabled bool
	// contains filtered or unexported fields
}

func (*Backend) ActivateTab

func (backend *Backend) ActivateTab(e *core.ServeEvent) error

ActivateTab endpoint - switches focus to a specific tab

func (*Backend) AddRequest

func (backend *Backend) AddRequest(e *core.ServeEvent) error

func (*Backend) BindFrontend

func (backend *Backend) BindFrontend(e *core.ServeEvent) error

func (*Backend) CWDBrowse added in v0.28.0

func (backend *Backend) CWDBrowse(e *core.ServeEvent) error

func (*Backend) CWDContent

func (backend *Backend) CWDContent(e *core.ServeEvent) error

func (*Backend) CWDReadFile added in v0.28.0

func (backend *Backend) CWDReadFile(e *core.ServeEvent) error

func (*Backend) ClickProxy

func (backend *Backend) ClickProxy(e *core.ServeEvent) error

func (*Backend) CloseTab

func (backend *Backend) CloseTab(e *core.ServeEvent) error

CloseTab endpoint - closes a specific tab

func (*Backend) CommandManager

func (backend *Backend) CommandManager()

loop over commandChannel

func (*Backend) CookApplyMethods

func (backend *Backend) CookApplyMethods(e *core.ServeEvent) error

func (*Backend) CookGenerate

func (backend *Backend) CookGenerate(e *core.ServeEvent) error

func (*Backend) CookSearch

func (backend *Backend) CookSearch(e *core.ServeEvent) error

func (*Backend) CreateCollection

func (backend *Backend) CreateCollection(collectionName string, dbSchema schema.Schema) error

Create Collection with schema in params

func (*Backend) DownloadCert

func (backend *Backend) DownloadCert(e *core.ServeEvent) error

DownloadCert serves the unified CA certificate (ca.crt) for download Certificate is generated once at app startup, always at the same location

func (*Backend) EvaluateProxy added in v0.28.0

func (backend *Backend) EvaluateProxy(e *core.ServeEvent) error

func (*Backend) ExecuteTemplateActions added in v0.29.0

func (backend *Backend) ExecuteTemplateActions(results []templates.Action, data map[string]any)

ExecuteTemplateActions processes the results from Templates.Run() and dispatches each action to its handler.

func (*Backend) ExtractData

func (backend *Backend) ExtractData(host string, fields []string, outputFile string) (string, error)

ExtractData extracts specified fields from database records matching the host and saves them to a file. Returns the file path and any error.

func (*Backend) ExtractDataEndpoint

func (backend *Backend) ExtractDataEndpoint(e *core.ServeEvent) error

ExtractDataEndpoint creates an API endpoint for data extraction

func (*Backend) FileWatcher

func (backend *Backend) FileWatcher(e *core.ServeEvent) error

func (*Backend) FiltersCheck

func (backend *Backend) FiltersCheck(e *core.ServeEvent) error

FiltersCheck registers the /api/filter/check endpoint. It evaluates the provided dadql filter against the given columns map.

func (*Backend) GetElementsProxy

func (backend *Backend) GetElementsProxy(e *core.ServeEvent) error

func (*Backend) GetFilePath

func (backend *Backend) GetFilePath(folder, fileName string) string

func (*Backend) GetOrCreatePlayground

func (backend *Backend) GetOrCreatePlayground(name string, typeVal string, parentId string) (*models.Record, error)

func (*Backend) GetRecord

func (backend *Backend) GetRecord(collectionName string, filter string) (*models.Record, error)

func (*Backend) GoBack

func (backend *Backend) GoBack(e *core.ServeEvent) error

GoBack endpoint - navigates back in browser history

func (*Backend) GoForward

func (backend *Backend) GoForward(e *core.ServeEvent) error

GoForward endpoint - navigates forward in browser history

func (*Backend) Info

func (backend *Backend) Info(e *core.ServeEvent) error

func (*Backend) InitializeProxy

func (backend *Backend) InitializeProxy() error

func (*Backend) InterceptEndpoints

func (backend *Backend) InterceptEndpoints(e *core.ServeEvent) error

InterceptEndpoints registers the HTTP endpoints for intercept management

func (*Backend) IntruderDelete

func (backend *Backend) IntruderDelete(id string) error

func (*Backend) IntruderNew

func (backend *Backend) IntruderNew(id string, data types.PlaygroundItem) error

func (*Backend) LabelAttach

func (backend *Backend) LabelAttach(e *core.ServeEvent) error

func (*Backend) LabelDelete

func (backend *Backend) LabelDelete(e *core.ServeEvent) error

func (*Backend) LabelNew

func (backend *Backend) LabelNew(e *core.ServeEvent) error

func (*Backend) ListChromeTabs

func (backend *Backend) ListChromeTabs(e *core.ServeEvent) error

ListChromeTabs endpoint - lists all open tabs in Chrome

func (*Backend) ListProxies

func (backend *Backend) ListProxies(e *core.ServeEvent) error

func (*Backend) LoadTemplatesEnabledFromLauncher added in v0.29.0

func (backend *Backend) LoadTemplatesEnabledFromLauncher(launcherAddr string)

LoadTemplatesEnabledFromLauncher checks both global (_configs) and per-project (_projects) settings

func (*Backend) LoadTemplatesFromLauncher added in v0.29.0

func (backend *Backend) LoadTemplatesFromLauncher(launcherAddr string) error

LoadTemplatesFromLauncher fetches templates from the launcher's API

func (*Backend) MCPEndpoint added in v0.27.0

func (backend *Backend) MCPEndpoint(e *core.ServeEvent) error

func (*Backend) ModifyRequest

func (backend *Backend) ModifyRequest(e *core.ServeEvent) error

func (*Backend) NavigateChromeTab

func (backend *Backend) NavigateChromeTab(e *core.ServeEvent) error

NavigateChromeTab endpoint - navigates a tab to a URL

func (*Backend) OpenChromeTab

func (backend *Backend) OpenChromeTab(e *core.ServeEvent) error

OpenChromeTab endpoint - opens a new tab in Chrome

func (*Backend) ParseRaw added in v0.28.0

func (backend *Backend) ParseRaw(e *core.ServeEvent) error

func (*Backend) PlaygroundAddChild

func (backend *Backend) PlaygroundAddChild(e *core.ServeEvent) error

func (*Backend) PlaygroundDelete

func (backend *Backend) PlaygroundDelete(e *core.ServeEvent) error

func (*Backend) PlaygroundNew

func (backend *Backend) PlaygroundNew(e *core.ServeEvent) error

func (*Backend) ReadFile

func (backend *Backend) ReadFile(e *core.ServeEvent) error

func (*Backend) RegisterProcessInDB

func (backend *Backend) RegisterProcessInDB(input, data any, name, typz, state string) string

func (*Backend) RegisterXtermRoutes

func (backend *Backend) RegisterXtermRoutes()

RegisterXtermRoutes registers all xterm-related routes

func (*Backend) ReloadTab

func (backend *Backend) ReloadTab(e *core.ServeEvent) error

ReloadTab endpoint - reloads a specific tab

func (*Backend) RepeaterDelete

func (backend *Backend) RepeaterDelete(id string) error

func (*Backend) RepeaterNew

func (backend *Backend) RepeaterNew(id string, data types.PlaygroundItem) error

func (*Backend) RestartProxy

func (backend *Backend) RestartProxy(e *core.ServeEvent) error

func (*Backend) RunCommand

func (backend *Backend) RunCommand(e *core.ServeEvent) error

func (*Backend) RunningCommand

func (backend *Backend) RunningCommand(id string, command string, filename string)

func (*Backend) RunningCommandSaveToCollection

func (backend *Backend) RunningCommandSaveToCollection(id, command, collectionName string)

func (*Backend) SaveFile

func (backend *Backend) SaveFile(e *core.ServeEvent) error

func (*Backend) SaveRecordToCollection

func (backend *Backend) SaveRecordToCollection(collectionName string, data map[string]any) (*models.Record, error)

func (*Backend) SaveRequestToBackend

func (backend *Backend) SaveRequestToBackend(reqBody types.AddRequestBodyType) (types.UserData, error)

SaveRequestToBackend saves the request and response to the backend database

func (*Backend) ScreenshotProxy

func (backend *Backend) ScreenshotProxy(e *core.ServeEvent) error

func (*Backend) SearchRegex

func (backend *Backend) SearchRegex(e *core.ServeEvent) error

func (*Backend) SendHttpRaw

func (backend *Backend) SendHttpRaw(e *core.ServeEvent) error

func (*Backend) SendRawRequest

func (backend *Backend) SendRawRequest(e *core.ServeEvent) error

func (*Backend) SendRepeater

func (backend *Backend) SendRepeater(e *core.ServeEvent) error

SendRepeater handles the /api/repeater/send endpoint

func (*Backend) Serve

func (backend *Backend) Serve()

func (*Backend) SetProcess

func (backend *Backend) SetProcess(id, state string)

func (*Backend) SetupCounterManager

func (backend *Backend) SetupCounterManager() error

SetupCounterManager initializes the counter manager and loads from database

func (*Backend) SetupFiltersHook

func (backend *Backend) SetupFiltersHook() error

SetupFiltersHook sets up the event hook for filter management Monitors the _ui collection for changes to proxy filters

func (*Backend) SetupInterceptHooks

func (backend *Backend) SetupInterceptHooks() error

SetupInterceptHooks sets up the event hook for monitoring intercept state changes

func (*Backend) SetupTemplateHooks added in v0.29.0

func (backend *Backend) SetupTemplateHooks() error

SetupTemplateHooks monitors run_templates changes on _proxies records

func (*Backend) SitemapFetch

func (backend *Backend) SitemapFetch(e *core.ServeEvent) error

func (*Backend) SitemapNew

func (backend *Backend) SitemapNew(e *core.ServeEvent) error

func (*Backend) StartProxy

func (backend *Backend) StartProxy(e *core.ServeEvent) error

func (*Backend) StopProxy

func (backend *Backend) StopProxy(e *core.ServeEvent) error

func (*Backend) TemplateActionButtons added in v0.29.0

func (backend *Backend) TemplateActionButtons(e *core.ServeEvent) error

TemplateActionButtons returns templates with request-action-button or response-action-button hooks

func (*Backend) TemplateGlobalToggle added in v0.29.0

func (backend *Backend) TemplateGlobalToggle(e *core.ServeEvent) error

func (*Backend) TemplateReload added in v0.29.0

func (backend *Backend) TemplateReload(e *core.ServeEvent) error

TemplateReload reloads all templates from the launcher

func (*Backend) TemplateRunAction added in v0.29.0

func (backend *Backend) TemplateRunAction(e *core.ServeEvent) error

TemplateRunAction executes a specific template's tasks on provided request data

func (*Backend) TemplateToggle added in v0.29.0

func (backend *Backend) TemplateToggle(e *core.ServeEvent) error

func (*Backend) TemplatesCheck added in v0.29.0

func (backend *Backend) TemplatesCheck(e *core.ServeEvent) error

func (*Backend) TemplatesDelete

func (backend *Backend) TemplatesDelete(e *core.ServeEvent) error

func (*Backend) TemplatesInfo added in v0.29.0

func (backend *Backend) TemplatesInfo(e *core.ServeEvent) error

func (*Backend) TemplatesList

func (backend *Backend) TemplatesList(e *core.ServeEvent) error

func (*Backend) TemplatesNew

func (backend *Backend) TemplatesNew(e *core.ServeEvent) error

func (*Backend) TextSQL

func (backend *Backend) TextSQL(e *core.ServeEvent) error

func (*Backend) Tools

func (backend *Backend) Tools(e *core.ServeEvent) error

func (*Backend) ToolsServer

func (backend *Backend) ToolsServer(e *core.ServeEvent) error

func (*Backend) TypeTextProxy added in v0.28.0

func (backend *Backend) TypeTextProxy(e *core.ServeEvent) error

func (*Backend) UpdateInterceptFilters

func (backend *Backend) UpdateInterceptFilters(filters string)

UpdateInterceptFilters updates the intercept filters for all proxies

func (*Backend) WaitForSelectorProxy added in v0.28.0

func (backend *Backend) WaitForSelectorProxy(e *core.ServeEvent) error

type CountResult

type CountResult struct {
	CountOfRows         int `db:"CountOfRows" json:"CountOfRows"`
	CountOfDistinctRows int `db:"CountOfDistinctRows" json:"CountOfDistinctRows"`
}

type Counter

type Counter struct {
	ID            string
	Key           string       // counter_key - the main identifier
	Collection    string       // optional metadata
	Filter        string       // optional metadata
	Count         atomic.Int64 // Use atomic for lock-free operations
	LoadOnStartup bool         // if true, recalculate from DB on startup, no immediate sync
	// contains filtered or unexported fields
}

Counter represents a counter entry with atomic operations

type CounterManager

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

CounterManager manages counters in memory with database sync

func (*CounterManager) Decrement

func (cm *CounterManager) Decrement(key, collection, filter string) int64

Decrement decrements the count for a given counter key (lock-free atomic operation) Parameters: key (counter_key - main identifier), collection (optional - updates metadata), filter (optional - updates metadata) If loadOnStartup=false, syncs immediately to DB for exact counts

func (*CounterManager) Delete

func (cm *CounterManager) Delete(key, collection, filter string)

Delete removes a counter from memory and database Parameters: key (counter_key - main identifier), collection (not used), filter (not used)

func (*CounterManager) Get

func (cm *CounterManager) Get(key, collection, filter string) int64

Get returns the count for a given counter key (lock-free read) Parameters: key (counter_key - main identifier), collection (optional - updates if exists), filter (optional - updates if exists)

func (*CounterManager) GetAll

func (cm *CounterManager) GetAll() map[string]*Counter

GetAll returns all counters (snapshot with current counts)

func (*CounterManager) GetDetails

func (cm *CounterManager) GetDetails(key string) (*Counter, bool)

GetDetails returns the full counter details (key, collection, filter, count) This makes it easy to find all the details: counters["my_key"] gives you everything!

func (*CounterManager) Increment

func (cm *CounterManager) Increment(key, collection, filter string) int64

Increment increments the count for a given counter key (lock-free atomic operation) Parameters: key (counter_key - main identifier), collection (optional - updates metadata), filter (optional - updates metadata) Default: loadOnStartup=false (immediate sync for exact counts)

func (*CounterManager) IncrementWithStartup

func (cm *CounterManager) IncrementWithStartup(key, collection, filter string, loadOnStartup bool) int64

IncrementWithStartup increments with explicit loadOnStartup flag

func (*CounterManager) LoadFromDB

func (cm *CounterManager) LoadFromDB() error

LoadFromDB loads all counters from the database into memory

func (*CounterManager) Reset

func (cm *CounterManager) Reset(key, collection, filter string)

Reset resets a specific counter to 0 (lock-free atomic operation) Parameters: key (counter_key - main identifier), collection (optional - updates metadata), filter (optional - updates metadata)

func (*CounterManager) Set

func (cm *CounterManager) Set(key, collection, filter string, count int64)

Set sets the count for a given counter key Parameters: key (counter_key - main identifier), collection (optional - updates if provided), filter (optional - updates if provided), count

func (*CounterManager) SyncOne

func (cm *CounterManager) SyncOne(key string) error

SyncOne syncs a single counter to database immediately (for load_on_startup=false counters)

func (*CounterManager) SyncToDB

func (cm *CounterManager) SyncToDB() error

SyncToDB syncs only load_on_startup counters to the database (load_on_startup=false counters are synced immediately via SyncOne)

type FilterCheckRequest

type FilterCheckRequest struct {
	Filter  string         `json:"filter"`
	Columns map[string]any `json:"columns"`
}

type GetHostInfoArgs added in v0.28.0

type GetHostInfoArgs struct {
	Host string `json:"host" jsonschema:"required" jsonschema_description:"the host ID to get the info for"`
}

type GetNoteForHostArgs added in v0.28.0

type GetNoteForHostArgs struct {
	Host string `json:"host" jsonschema:"required" jsonschema_description:"the host to get the note for"`
}

type GetRequestResponseArgs added in v0.27.0

type GetRequestResponseArgs struct {
	ActiveID string `json:"activeID" jsonschema:"required" jsonschema_description:"The active ID"`
}

type HostLabelAction added in v0.28.0

type HostLabelAction struct {
	Action string `json:"action" jsonschema:"required" jsonschema_description:"add, remove, or toggle"`
	Name   string `json:"name" jsonschema:"required" jsonschema_description:"the name of the label"`
	Color  string `json:"color,omitempty" jsonschema_description:"the color of the label (only for add/toggle)"`
	Type   string `json:"type,omitempty" jsonschema_description:"the type of the label (only for add/toggle)"`
}

type HostNoteAction added in v0.28.0

type HostNoteAction struct {
	Action string `json:"action" jsonschema:"required" jsonschema_description:"add, update, or remove"`
	Index  int    `json:"index,omitempty" jsonschema_description:"the index of the note to update/remove (not needed for add)"`
	Text   string `json:"text,omitempty" jsonschema_description:"the text of the note (for add/update actions)"`
	Author string `json:"author,omitempty" jsonschema_description:"the author of the note (for add action, defaults to you)"`
}

type HostPrintRowsArgs added in v0.27.0

type HostPrintRowsArgs struct {
	Host   string `json:"host" jsonschema:"required" jsonschema_description:"the host to get the table for"`
	Page   int    `json:"page" jsonschema:"required" jsonschema_description:"the page to get the data from, start from 1"`
	Filter string `json:"filter" jsonschema:"required" jsonschema_description:"filter the results for faster search"`
}

type HostPrintSitemapArgs added in v0.27.0

type HostPrintSitemapArgs struct {
	Host  string `json:"host" jsonschema:"required" jsonschema_description:"the host to get the sitemap for"`
	Path  string `` /* 132-byte string literal not displayed */
	Depth int    `` /* 139-byte string literal not displayed */
}

type InterceptActionArgs added in v0.28.0

type InterceptActionArgs struct {
	ID           string `json:"id" jsonschema:"required" jsonschema_description:"The intercept record ID (from interceptList)"`
	Action       string `json:"action" jsonschema:"required" jsonschema_description:"Action to take: forward (pass through) or drop (block)"`
	IsReqEdited  bool   `json:"isReqEdited,omitempty" jsonschema_description:"If true, the request has been edited"`
	IsRespEdited bool   `json:"isRespEdited,omitempty" jsonschema_description:"If true, the response has been edited"`
	ReqEdited    string `json:"reqEdited,omitempty" jsonschema_description:"Raw edited HTTP request string (only if isReqEdited is true)"`
	RespEdited   string `json:"respEdited,omitempty" jsonschema_description:"Raw edited HTTP response string (only if isRespEdited is true)"`
}

type InterceptActionRequest

type InterceptActionRequest struct {
	ID           string `json:"id"`
	Action       string `json:"action"` // "forward" or "drop"
	IsReqEdited  bool   `json:"is_req_edited,omitempty"`
	IsRespEdited bool   `json:"is_resp_edited,omitempty"`
	ReqEdited    string `json:"req_edited,omitempty"`  // Raw HTTP request string
	RespEdited   string `json:"resp_edited,omitempty"` // Raw HTTP response string
}

InterceptActionRequest represents the request body for intercept actions

type InterceptGetRawArgs added in v0.28.0

type InterceptGetRawArgs struct {
	ID string `json:"id" jsonschema:"required" jsonschema_description:"The intercept record ID (from interceptPrintRowsInDetails)"`
}

type InterceptReadArgs added in v0.28.0

type InterceptReadArgs struct {
	ProxyID string `json:"proxyId" jsonschema:"required" jsonschema_description:"The proxy ID to read intercepted rows from"`
}

type InterceptToggleArgs added in v0.28.0

type InterceptToggleArgs struct {
	ID     string `json:"id" jsonschema:"required" jsonschema_description:"The proxy ID to enable/disable interception on"`
	Enable bool   `` /* 129-byte string literal not displayed */
}

type InterceptUpdate

type InterceptUpdate struct {
	Action        string
	IsReqEdited   bool
	IsRespEdited  bool
	ReqEditedRaw  string // Raw HTTP request string (if edited)
	RespEditedRaw string // Raw HTTP response string (if edited)
}

InterceptUpdate represents an update to an intercept request

type ListHostsArgs added in v0.28.0

type ListHostsArgs struct {
	Search string `json:"search,omitempty" jsonschema_description:"the search to get the table for, use empty string to get all results"`
	Page   int    `json:"page" jsonschema:"required" jsonschema_description:"the page to get the data from, start from 1"`
}

type MCP added in v0.27.0

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

type ModifyHostLabelsArgs added in v0.28.0

type ModifyHostLabelsArgs struct {
	Host   string            `` /* 132-byte string literal not displayed */
	Labels []HostLabelAction `json:"labels" jsonschema:"required" jsonschema_description:"the labels to update for the host"`
}

type ModifyHostNotesArgs added in v0.28.0

type ModifyHostNotesArgs struct {
	Host  string           `` /* 131-byte string literal not displayed */
	Notes []HostNoteAction `json:"notes" jsonschema:"required" jsonschema_description:"the notes to update for the host"`
}

type ModifyRequestRequest

type ModifyRequestRequest struct {
	Request string                      `json:"request"`
	Url     string                      `json:"url"`
	Tasks   []map[string]map[string]any `json:"tasks"`
}

type NoteEditAction added in v0.28.0

type NoteEditAction struct {
	Index int    `json:"index" jsonschema:"required" jsonschema_description:"the index of the line to edit"`
	Line  string `json:"line,omitempty" jsonschema_description:"the content to edit the line with, to delete write [delete]"`
}

type ParseRawRequest added in v0.28.0

type ParseRawRequest struct {
	Request  string `json:"request"`
	Response string `json:"response"`
}

type Path

type Path struct {
	Name  string `json:"name"`
	Path  string `json:"path"`
	IsDir bool   `json:"is_dir"`
}

type ProxyActivateTabArgs added in v0.28.0

type ProxyActivateTabArgs struct {
	ProxyID  string `json:"proxyId" jsonschema:"required" jsonschema_description:"The proxy ID with Chrome browser attached"`
	TargetID string `json:"targetId" jsonschema:"required" jsonschema_description:"Chrome target ID of the tab to activate"`
}

type ProxyBody

type ProxyBody struct {
	HTTP    string `json:"http,omitempty"`
	Browser string `json:"browser,omitempty"`
	Name    string `json:"name,omitempty"` // Optional name for the proxy instance
}

type ProxyClickArgs added in v0.28.0

type ProxyClickArgs struct {
	ID                string `json:"id" jsonschema:"required" jsonschema_description:"The proxy ID with Chrome browser attached"`
	URL               string `` /* 127-byte string literal not displayed */
	Selector          string `json:"selector" jsonschema:"required" jsonschema_description:"CSS selector for the element to click"`
	WaitForNavigation bool   `json:"waitForNavigation,omitempty" jsonschema_description:"If true, waits for page navigation after click (default: false)"`
}

type ProxyCloseTabArgs added in v0.28.0

type ProxyCloseTabArgs struct {
	ProxyID  string `json:"proxyId" jsonschema:"required" jsonschema_description:"The proxy ID with Chrome browser attached"`
	TargetID string `json:"targetId" jsonschema:"required" jsonschema_description:"Chrome target ID of the tab to close"`
}

type ProxyElementsArgs added in v0.28.0

type ProxyElementsArgs struct {
	ID  string `json:"id" jsonschema:"required" jsonschema_description:"The proxy ID with Chrome browser attached"`
	URL string `` /* 135-byte string literal not displayed */
}

type ProxyEvalArgs added in v0.28.0

type ProxyEvalArgs struct {
	ID        string `json:"id" jsonschema:"required" jsonschema_description:"The proxy ID with Chrome browser attached"`
	Js        string `` /* 143-byte string literal not displayed */
	TimeoutMs int    `json:"timeoutMs,omitempty" jsonschema_description:"Timeout in milliseconds. Default: 15000"`
}

type ProxyGoBackArgs added in v0.28.0

type ProxyGoBackArgs struct {
	ProxyID  string `json:"proxyId" jsonschema:"required" jsonschema_description:"The proxy ID with Chrome browser attached"`
	TargetID string `json:"targetId,omitempty" jsonschema_description:"Chrome target ID of the tab. If empty, operates on the active tab"`
}

type ProxyGoForwardArgs added in v0.28.0

type ProxyGoForwardArgs struct {
	ProxyID  string `json:"proxyId" jsonschema:"required" jsonschema_description:"The proxy ID with Chrome browser attached"`
	TargetID string `json:"targetId,omitempty" jsonschema_description:"Chrome target ID of the tab. If empty, operates on the active tab"`
}

type ProxyInstance

type ProxyInstance struct {
	Proxy      *RawProxyWrapper
	Browser    string // `json:"browser"`
	BrowserCmd *exec.Cmd
	Label      string // `json:"label"`
	Chrome     *browser.ChromeRemote
}

ProxyInstance holds a proxy and its optional runtime attachments (browser, label, etc.)

type ProxyListTabsArgs added in v0.28.0

type ProxyListTabsArgs struct {
	ProxyID string `json:"proxyId" jsonschema:"required" jsonschema_description:"The proxy ID with Chrome browser attached"`
}

type ProxyManager

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

ProxyManager manages multiple proxy instances

func (*ProxyManager) AddProxy

func (pm *ProxyManager) AddProxy(id string, proxy *RawProxyWrapper)

AddProxy adds a proxy to the manager

func (*ProxyManager) AddProxyInstance

func (pm *ProxyManager) AddProxyInstance(id string, instance *ProxyInstance)

AddProxyInstance adds a complete proxy instance to the manager

func (*ProxyManager) ApplyToAllProxies

func (pm *ProxyManager) ApplyToAllProxies(fn func(proxy *RawProxyWrapper, proxyID string))

ApplyToAllProxies applies a function to all running proxies

func (*ProxyManager) ClickElement

func (pm *ProxyManager) ClickElement(proxyID string, url string, selector string, waitForNavigation bool) error

ClickElement clicks an element on the page using the Chrome browser attached to a proxy instance

func (*ProxyManager) Evaluate added in v0.28.0

func (pm *ProxyManager) Evaluate(proxyID string, jsExpr string, timeoutMs int) (any, error)

Evaluate runs arbitrary JavaScript in the page context

func (*ProxyManager) GetAllProxies

func (pm *ProxyManager) GetAllProxies() []string

GetAllProxies returns all proxy IDs

func (*ProxyManager) GetChromeRemote

func (pm *ProxyManager) GetChromeRemote(proxyID string) (*browser.ChromeRemote, error)

GetChromeRemote returns a ChromeRemote instance for a proxy, initializing it if necessary

func (*ProxyManager) GetElements

func (pm *ProxyManager) GetElements(proxyID string, url string) ([]browser.ElementInfo, error)

GetElements retrieves information about clickable elements on the page

func (*ProxyManager) GetInstance

func (pm *ProxyManager) GetInstance(id string) *ProxyInstance

GetInstance returns a proxy instance by ID

func (*ProxyManager) GetNextIndex

func (pm *ProxyManager) GetNextIndex() uint64

GetNextIndex returns the next unique index (thread-safe)

func (*ProxyManager) GetNextProxyID

func (pm *ProxyManager) GetNextProxyID() string

GetNextProxyID returns the next unique proxy ID (thread-safe)

func (*ProxyManager) GetProxy

func (pm *ProxyManager) GetProxy(id string) *RawProxyWrapper

GetProxy returns a proxy by ID (listen address)

func (*ProxyManager) RemoveProxy

func (pm *ProxyManager) RemoveProxy(id string)

RemoveProxy removes a proxy from the manager

func (*ProxyManager) SetGlobalIndex

func (pm *ProxyManager) SetGlobalIndex(value uint64)

SetGlobalIndex sets the global index from the database

func (*ProxyManager) StopAllProxies

func (pm *ProxyManager) StopAllProxies()

StopAllProxies stops all running proxies

func (*ProxyManager) StopProxy

func (pm *ProxyManager) StopProxy(id string) error

StopProxy stops a specific proxy

func (*ProxyManager) TakeScreenshot

func (pm *ProxyManager) TakeScreenshot(proxyID string, fullPage bool, savePath string) ([]byte, string, error)

TakeScreenshot captures a screenshot using the Chrome browser attached to a proxy instance Returns: screenshot bytes, file path (if saved), error

func (*ProxyManager) TypeText added in v0.28.0

func (pm *ProxyManager) TypeText(proxyID string, selector string, text string, clearFirst bool, timeoutMs int) error

TypeText types text into an element on the page using the Chrome browser attached to a proxy instance

func (*ProxyManager) WaitForSelector added in v0.28.0

func (pm *ProxyManager) WaitForSelector(proxyID string, selector string, timeoutMs int) error

WaitForSelector waits for a CSS selector to become visible on the page

type ProxyNavigateTabArgs added in v0.28.0

type ProxyNavigateTabArgs struct {
	ProxyID   string `json:"proxyId" jsonschema:"required" jsonschema_description:"The proxy ID with Chrome browser attached"`
	TargetID  string `` /* 126-byte string literal not displayed */
	URL       string `json:"url" jsonschema:"required" jsonschema_description:"URL to navigate to"`
	WaitUntil string `json:"waitUntil,omitempty" jsonschema_description:"Load state to wait for: domcontentloaded, load (default), or networkidle"`
	TimeoutMs int    `json:"timeoutMs,omitempty" jsonschema_description:"Timeout in milliseconds. Default: 30000"`
}

type ProxyOpenTabArgs added in v0.28.0

type ProxyOpenTabArgs struct {
	ProxyID string `json:"proxyId" jsonschema:"required" jsonschema_description:"The proxy ID with Chrome browser attached"`
	URL     string `json:"url,omitempty" jsonschema_description:"URL to open in the new tab. Defaults to about:blank if not provided"`
}

type ProxyReloadTabArgs added in v0.28.0

type ProxyReloadTabArgs struct {
	ProxyID     string `json:"proxyId" jsonschema:"required" jsonschema_description:"The proxy ID with Chrome browser attached"`
	TargetID    string `json:"targetId,omitempty" jsonschema_description:"Chrome target ID of the tab to reload. If empty, reloads the active tab"`
	BypassCache bool   `json:"bypassCache,omitempty" jsonschema_description:"If true, reloads ignoring cache (hard refresh). Default: false"`
}

type ProxyScreenshotArgs added in v0.28.0

type ProxyScreenshotArgs struct {
	ID string `json:"id" jsonschema:"required" jsonschema_description:"The proxy ID with Chrome browser attached"`
}

type ProxyStartArgs added in v0.28.0

type ProxyStartArgs struct {
	Name string `json:"name,omitempty" jsonschema_description:"Optional label for the proxy instance"`
}

type ProxyStats

type ProxyStats struct {
	RequestsTotal   atomic.Uint64
	ResponsesTotal  atomic.Uint64
	RequestsSaved   atomic.Uint64
	ResponsesSaved  atomic.Uint64
	RequestsFailed  atomic.Uint64
	ResponsesFailed atomic.Uint64
	BytesRequest    atomic.Uint64
	BytesResponse   atomic.Uint64
}

ProxyStats tracks proxy statistics

type ProxyStopArgs added in v0.28.0

type ProxyStopArgs struct {
	ID string `json:"id,omitempty" jsonschema_description:"The proxy ID to stop. If not provided, stops all running proxies"`
}

type ProxyTypeArgs added in v0.28.0

type ProxyTypeArgs struct {
	ID         string `json:"id" jsonschema:"required" jsonschema_description:"The proxy ID with Chrome browser attached"`
	Selector   string `json:"selector" jsonschema:"required" jsonschema_description:"CSS selector for the input element to type into"`
	Text       string `json:"text" jsonschema:"required" jsonschema_description:"The text to type into the element"`
	ClearFirst bool   `json:"clearFirst,omitempty" jsonschema_description:"If true, clears the existing value before typing (default: false)"`
	TimeoutMs  int    `json:"timeoutMs,omitempty" jsonschema_description:"Timeout in milliseconds. Default: 15000"`
}

type ProxyWaitForSelectorArgs added in v0.28.0

type ProxyWaitForSelectorArgs struct {
	ID        string `json:"id" jsonschema:"required" jsonschema_description:"The proxy ID with Chrome browser attached"`
	Selector  string `json:"selector" jsonschema:"required" jsonschema_description:"CSS selector to wait for"`
	TimeoutMs int    `json:"timeoutMs,omitempty" jsonschema_description:"Timeout in milliseconds. Default: 30000"`
}

type RawProxyWrapper

type RawProxyWrapper struct {
	Intercept    bool
	Filters      string
	RunTemplates bool
	// contains filtered or unexported fields
}

RawProxyWrapper wraps the rawproxy.Proxy to match our interface

var PROXY *RawProxyWrapper

DEPRECATED: Backward compatibility - returns first proxy or nil

func NewRawProxyWrapper

func NewRawProxyWrapper(listenAddr, configDir, outputDir string, backend *Backend, proxyID string) (*RawProxyWrapper, error)

NewRawProxyWrapper creates a new rawproxy wrapper with the given configuration Set outputDir to empty string ("") to disable file captures

func (*RawProxyWrapper) CleanupTempCaptures

func (rp *RawProxyWrapper) CleanupTempCaptures() error

CleanupTempCaptures removes temporary capture files (if using /tmp) Call this periodically or on shutdown to free up space

func (*RawProxyWrapper) GetCertPath

func (rp *RawProxyWrapper) GetCertPath() string

GetCertPath returns the path to the CA certificate

func (*RawProxyWrapper) GetConfig

func (rp *RawProxyWrapper) GetConfig() *rawproxy.Config

GetConfig returns the proxy configuration

func (*RawProxyWrapper) PrintStats

func (rp *RawProxyWrapper) PrintStats()

PrintStats logs the current proxy statistics

func (*RawProxyWrapper) RunProxy

func (rp *RawProxyWrapper) RunProxy() error

RunProxy starts the proxy server in a non-blocking manner

func (*RawProxyWrapper) SetRequestHandler

func (rp *RawProxyWrapper) SetRequestHandler(handler rawproxy.OnRequestHandler)

SetRequestHandler sets a custom request handler

func (*RawProxyWrapper) SetResponseHandler

func (rp *RawProxyWrapper) SetResponseHandler(handler rawproxy.OnResponseHandler)

SetResponseHandler sets a custom response handler

func (*RawProxyWrapper) Stop

func (rp *RawProxyWrapper) Stop() error

Stop gracefully stops the proxy server

type RawRequest

type RawRequest struct {
	TLS      bool
	Hostname string
	Port     string
	Request  string
	Timeout  time.Duration
}

type RepeaterSendRequest

type RepeaterSendRequest struct {
	Host        string  `json:"host"`
	Port        string  `json:"port"`
	TLS         bool    `json:"tls"`
	Request     string  `json:"request"`
	Timeout     float64 `json:"timeout"`
	HTTP2       bool    `json:"http2"`
	Index       float64 `json:"index"`
	Url         string  `json:"url"`
	GeneratedBy string  `json:"generated_by"`
	Note        string  `json:"note,omitempty"`
}

type RepeaterSendResponse

type RepeaterSendResponse struct {
	Response string         `json:"response"`
	Time     string         `json:"time"`
	UserData types.UserData `json:"userdata"`
}

type RequestContext

type RequestContext struct {
	UserData     map[string]any
	RawRequest   string
	RawResponse  string // Set in onResponse
	RequestStart time.Time
	DataRecord   *models.Record // Single record shared across all operations
}

RequestContext stores request data for correlation with response This data is passed from onRequest to onResponse via rawproxy.RequestData

type SendRequestArgs added in v0.27.0

type SendRequestArgs struct {
	TLS                     bool     `json:"tls" jsonschema:"required" jsonschema_description:"use https or http"`
	Host                    string   `json:"host" jsonschema:"required" jsonschema_description:"the host to send the request to"`
	Port                    int      `json:"port" jsonschema:"required" jsonschema_description:"the port to send the request to"`
	HttpVersion             int      `json:"httpVersion" jsonschema:"required" jsonschema_description:"1 or 2"`
	AttachToIndex           float64  `json:"attachToIndex" jsonschema:"required" jsonschema_description:"origin index of request you are modifying"`
	Request                 string   `json:"request" jsonschema:"required" jsonschema_description:"raw request"`
	Note                    string   `json:"note" jsonschema:"required" jsonschema_description:"the note to attach to the request"`
	Labels                  []string `json:"labels,omitempty" jsonschema_description:"the labels to attach to the request"`
	AutoUpdateContentLength bool     `json:"autoUpdateContentLength" jsonschema:"required" jsonschema_description:"auto update content length, default: true"`
}

type SetNoteForHostArgs added in v0.28.0

type SetNoteForHostArgs struct {
	Host string           `json:"host" jsonschema:"required" jsonschema_description:"the host to set the note for"`
	Edit []NoteEditAction `json:"edit,omitempty" jsonschema_description:"lines to be updated"`
}

type TEXTSQL

type TEXTSQL struct {
	SQL string `json:"sql"`
}

type TemplateCreateArgs added in v0.29.0

type TemplateCreateArgs struct {
	Name        string              `json:"name" jsonschema:"required" jsonschema_description:"Unique template ID/name"`
	Title       string              `json:"title" jsonschema:"required" jsonschema_description:"Human readable title"`
	Description string              `json:"description,omitempty" jsonschema_description:"What this template does"`
	Mode        string              `json:"mode,omitempty" jsonschema_description:"'any' = stop after first match, 'all' = run all matching tasks. Default: any"`
	Hooks       map[string][]string `json:"hooks" jsonschema:"required" jsonschema_description:"Hook config, e.g. {proxy: [request, response, before_request]}"`
	Tasks       []TemplateTaskArg   `json:"tasks" jsonschema:"required" jsonschema_description:"List of tasks with conditions and actions"`
	Enabled     bool                `json:"enabled,omitempty" jsonschema_description:"Enable template, default true"`
}

type TemplateGetInfoArgs added in v0.29.0

type TemplateGetInfoArgs struct{}

type TemplateGlobalToggleBody added in v0.29.0

type TemplateGlobalToggleBody struct {
	Enabled bool `json:"enabled"`
}

type TemplateListArgs added in v0.29.0

type TemplateListArgs struct{}

type TemplateReadArgs added in v0.29.0

type TemplateReadArgs struct {
	Id string `json:"id" jsonschema:"required" jsonschema_description:"Template ID to read"`
}

type TemplateTaskArg added in v0.29.0

type TemplateTaskArg struct {
	Id        string           `json:"id" jsonschema:"required" jsonschema_description:"Unique task ID"`
	Condition string           `` /* 218-byte string literal not displayed */
	Disabled  bool             `json:"disabled,omitempty" jsonschema_description:"Set true to skip this task"`
	Todo      []map[string]any `` /* 233-byte string literal not displayed */
}

type TemplateToggleBody added in v0.29.0

type TemplateToggleBody struct {
	ProxyID string `json:"proxy_id"`
	Enabled bool   `json:"enabled"`
}

type TemplateUpdateArgs added in v0.29.0

type TemplateUpdateArgs struct {
	Id      string              `json:"id" jsonschema:"required" jsonschema_description:"Template record ID to update"`
	Title   string              `json:"title,omitempty" jsonschema_description:"Update title"`
	Mode    string              `json:"mode,omitempty" jsonschema_description:"Update mode"`
	Hooks   map[string][]string `json:"hooks,omitempty" jsonschema_description:"Update hooks"`
	Tasks   []TemplateTaskArg   `json:"tasks,omitempty" jsonschema_description:"Update tasks"`
	Enabled *bool               `json:"enabled,omitempty" jsonschema_description:"Enable/disable template"`
}

type ToolsServerResponse

type ToolsServerResponse struct {
	Path        string `db:"path" json:"path"`
	HostAddress string `db:"hostAddress" json:"hostAddress"`
	ID          string `db:"id" json:"id"`
	Name        string `db:"name" json:"name"`
	Username    string `db:"username" json:"username"`
	Password    string `db:"password" json:"password"`
}

type XtermManager

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

XtermManager manages all terminal sessions

func NewXtermManager

func NewXtermManager() *XtermManager

NewXtermManager creates a new terminal manager

func (*XtermManager) CleanupAllSessions

func (m *XtermManager) CleanupAllSessions()

CleanupAllSessions closes all terminal sessions

func (*XtermManager) CloseSession

func (m *XtermManager) CloseSession(sessionID string) error

CloseSession closes a terminal session

func (*XtermManager) CreateSession

func (m *XtermManager) CreateSession(shell, workDir string, envVars map[string]string) (*XtermSession, error)

CreateSession creates a new terminal session

func (*XtermManager) GetSession

func (m *XtermManager) GetSession(sessionID string) (*XtermSession, error)

GetSession retrieves a session by ID

func (*XtermManager) HandleWebSocket

func (m *XtermManager) HandleWebSocket(ws *websocket.Conn, sessionID string)

HandleWebSocket handles WebSocket connections for terminal I/O

func (*XtermManager) ListSessions

func (m *XtermManager) ListSessions() []map[string]interface{}

ListSessions returns all active sessions

type XtermMessage

type XtermMessage struct {
	Type string      `json:"type"` // "input", "resize", "ping"
	Data interface{} `json:"data"`
}

XtermMessage represents WebSocket messages between client and server

type XtermResizeData

type XtermResizeData struct {
	Cols uint16 `json:"cols"`
	Rows uint16 `json:"rows"`
}

XtermResizeData represents terminal resize data

type XtermSession

type XtermSession struct {
	ID        string
	Cmd       *exec.Cmd
	Pty       *os.File
	CreatedAt time.Time
	Shell     string
	WorkDir   string
	Env       []string
	// contains filtered or unexported fields
}

XtermSession represents a single terminal session

type XtermStartRequest

type XtermStartRequest struct {
	Shell   string            `json:"shell"`   // e.g., "bash", "zsh", "sh", "powershell"
	WorkDir string            `json:"workdir"` // working directory
	Env     map[string]string `json:"env"`     // additional environment variables
}

XtermStartRequest represents the request to start a new terminal

type XtermStartResponse

type XtermStartResponse struct {
	SessionID string `json:"session_id"`
	Shell     string `json:"shell"`
	WorkDir   string `json:"workdir"`
}

XtermStartResponse represents the response after starting a terminal

Jump to

Keyboard shortcuts

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