funnel

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidFunnelPath = errors.New("invalid path format for funnel request")
	ErrFunnelNotFound    = errors.New("funnel not found")
	ErrFunnelNotReady    = errors.New("funnel has no local target configured")
	ErrTargetURLParse    = errors.New("failed to parse funnel target URL")
)

Error variables for common failure modes

View Source
var HttpServerPath = fmt.Sprintf("/%s/", util.ProgramName)

Functions

func GenerateFunnelID

func GenerateFunnelID(remoteTarget string, localTarget string) string

Types

type CaptureRequest

type CaptureRequest struct {
	Method  string
	URL     string
	Body    []byte
	Headers map[string]string
}

type CaptureRequestResponse

type CaptureRequestResponse struct {
	ID        string
	FunnelID  string
	Timestamp time.Time
	Request   CaptureRequest
	Response  CaptureResponse
	Duration  time.Duration
}

func (*CaptureRequestResponse) Method

func (r *CaptureRequestResponse) Method() string

func (*CaptureRequestResponse) Path

func (r *CaptureRequestResponse) Path() string

func (*CaptureRequestResponse) RoundedDuration added in v0.0.2

func (r *CaptureRequestResponse) RoundedDuration() string

func (*CaptureRequestResponse) StatusCode

func (r *CaptureRequestResponse) StatusCode() int

func (*CaptureRequestResponse) Type added in v0.0.2

func (r *CaptureRequestResponse) Type() string

func (*CaptureRequestResponse) URL

func (r *CaptureRequestResponse) URL() string

type CaptureResponse

type CaptureResponse struct {
	StatusCode int
	Body       []byte
	Headers    map[string]string
}

type ClientRequestDetails added in v0.0.2

type ClientRequestDetails struct {
	FunnelID        string
	UUID            string
	Path            string
	Method          string
	Status          int
	Duration        string
	Time            string
	ClientIP        string
	RequestHeaders  []HeaderEntry
	ResponseHeaders []HeaderEntry
	RequestBody     string
	ResponseBody    string
	QueryParams     []QueryParamEntry
}

ClientRequestDetails is the structure passed to the _request_detail_content.html template.

type DisplayFunnel added in v0.0.2

type DisplayFunnel struct {
	ID          string
	LocalTarget string
	RemoteURL   string
}

DisplayFunnel is used for displaying funnel information in the inspector.

type Funnel

type Funnel struct {
	HTTPFunnel *HTTPFunnel
	Client     *TailscaleClient
	Requests   *RequestList
}

func CreateEphemeralFunnel

func CreateEphemeralFunnel(name string, target string, logger *stdlog.Logger) (Funnel, error)

func (*Funnel) Destroy

func (f *Funnel) Destroy() error

func (*Funnel) ID

func (f *Funnel) ID() string

ID returns the unique identifier for the funnel.

func (*Funnel) LocalTarget

func (f *Funnel) LocalTarget() string

LocalTarget returns the local URL that traffic is ultimately proxied to.

func (*Funnel) Name

func (f *Funnel) Name() string

func (*Funnel) RemoteTarget

func (f *Funnel) RemoteTarget() string

RemoteTarget returns the public URL exposed by the Tailscale funnel.

type FunnelIdAndRest

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

FunnelIdAndRest holds the extracted funnel ID and the rest of the path.

type FunnelRegistry

type FunnelRegistry struct {
	Funnels map[string]Funnel
}

func NewFunnelRegistry

func NewFunnelRegistry() *FunnelRegistry

func (*FunnelRegistry) AddFunnel

func (f *FunnelRegistry) AddFunnel(funnel Funnel)

func (*FunnelRegistry) GetFunnel

func (f *FunnelRegistry) GetFunnel(id string) (Funnel, error)

func (*FunnelRegistry) RemoveFunnel

func (f *FunnelRegistry) RemoveFunnel(id string)

type HTTPFunnel

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

type HTTPFunnelOptions

type HTTPFunnelOptions struct {
	ID         string // id of the funnel
	LocalPort  uint16 // local port to use
	RemotePort uint16 // remote port to tunnel to use.  one of 443, 8443, 10000
	HTTPS      bool   // local server uses TLS
	Insecure   bool   // ignore TLS certificate errors for local server
	// Mount      string // mount point for the local server, almost always "/" unless you want to serve a subdirectory
	Inspect bool // hijack to local tsgrok server
}

HTTPFunnelOptions holds configuration for creating an HTTP funnel.

type HeaderEntry added in v0.0.2

type HeaderEntry struct {
	Name  string
	Value string
}

HeaderEntry is used for displaying request/response headers.

type HttpServer

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

func NewHttpServer

func NewHttpServer(port int, messageBus util.MessageBus, funnelRegistry *FunnelRegistry, logger *stdlog.Logger) (*HttpServer, error)

func (*HttpServer) GetFunnelById

func (s *HttpServer) GetFunnelById(id string) (Funnel, error)

func (*HttpServer) Start

func (s *HttpServer) Start() error

type ProxyRequestMsg

type ProxyRequestMsg struct {
	FunnelId string
}

type QueryParamEntry added in v0.0.2

type QueryParamEntry struct {
	Name  string
	Value string
}

QueryParamEntry is used for displaying URL query parameters.

type RequestList

type RequestList struct {
	Head   *RequestListNode
	Tail   *RequestListNode
	Length int
	// contains filtered or unexported fields
}

func (*RequestList) Add

func (r *RequestList) Add(request CaptureRequestResponse)

type RequestListNode

type RequestListNode struct {
	Request CaptureRequestResponse
	Next    *RequestListNode
	Prev    *RequestListNode
}

type RequestResponse

type RequestResponse struct {
	Request  CaptureRequest
	Response CaptureResponse
	Duration time.Duration
}

type TailscaleClient

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

func (*TailscaleClient) CreateHTTPFunnel

func (c *TailscaleClient) CreateHTTPFunnel(opts HTTPFunnelOptions) (HTTPFunnel, error)

func (*TailscaleClient) Logout

func (c *TailscaleClient) Logout() error

func (*TailscaleClient) UpdateStatus

func (c *TailscaleClient) UpdateStatus() (*ipnstate.Status, error)

Jump to

Keyboard shortcuts

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