Documentation ¶
Index ¶
- func DownloadReleaseAsset(id int, filename string) error
- func FindNginxModuleDir() optionals.Optional[string]
- func FindNginxVersion() (string, error)
- func FindPlatform() (arch string, os string, err error)
- func InstallModule(args *InstallArgs) error
- func RunDevelopmentServer(listenPort uint16) error
- func RunServer(args *Args) error
- type Args
- type GithubAsset
- type GithubRelease
- type InstallArgs
- type InstallationError
- type MirroredHeader
- type MirroredRequest
- type MirroredResponse
- type NginxBackend
- func (b *NginxBackend) ReportSuccess(host string)
- func (b *NginxBackend) SendErrorTelemetry(errorType api_schema.ApidumpErrorType, err error)
- func (b *NginxBackend) SendInitialTelemetry()
- func (b *NginxBackend) SendPacketTelemetry(observedDuration int)
- func (b *NginxBackend) SendTelemetry(req *kgxapi.PostClientPacketCaptureStatsRequest)
- func (b *NginxBackend) TelemetryWorker(done <-chan struct{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DownloadReleaseAsset ¶
Download a specific asset (the prebuilt module) to a temporary file
func FindNginxModuleDir ¶
func FindNginxVersion ¶
Determine which version of NGINX is installed; for now we'll just use the version command.
func FindPlatform ¶
Determine the current platform: architecture, OS, release The operating system should be given in a form that matches the names we use for official releases.
func InstallModule ¶
func InstallModule(args *InstallArgs) error
Install the precompiled NGINX module from the latest release on GitHub. If we can't find the Nginx version or platform, Return an error to show to the user.
func RunDevelopmentServer ¶
Open a web server that dumps the output to the console and returns 200 for everything. Used for NGINX module development as a sink for its HTTP calls. TODO: a way to inject errors
Types ¶
type GithubAsset ¶
The Github API asset type, with most fields missing
func GetLatestReleaseAssets ¶
func GetLatestReleaseAssets() ([]GithubAsset, error)
Return a list of all the assets available in the latest release
type GithubRelease ¶
type GithubRelease struct { TagName string `json:"tag_name"` Assets []GithubAsset `json:"assets"` }
The Github API release type, with most fields missing
type InstallArgs ¶
type InstallationError ¶
Top-level error to report to the user.
func (*InstallationError) Error ¶
func (e *InstallationError) Error() string
func (*InstallationError) Unwrap ¶
func (e *InstallationError) Unwrap() error
type MirroredHeader ¶
Header name and value
type MirroredRequest ¶
type MirroredRequest struct { // Request metadata -- unique ID, time when request processing // started and ended, and whether the request is Nginx-internal. // Because of internal redirects, the same request_id might appear // multiple times. We should probably take just the first (by start time.) RequestID string `json:"request_id"` RequestStart time.Time `json:"request_start"` RequestArrived time.Time `json:"request_arrived"` NginxInternal bool `json:"nginx_internal"` // HTTP header information Method string `json:"method"` Host string `json:"host"` Path string `json:"path"` Headers []MirroredHeader `json:"headers"` // HTTP body; may be empty. Optionally includes the 'truncated' // field specifying the length Body string `json:"body"` Truncated optionals.Optional[int] `json:"truncated"` }
An incoming request to Nginx.
type MirroredResponse ¶
type MirroredResponse struct { // Response metadata; has the same unique ID as the request. // Times measure when header was first sent and when last byte of body was sent. RequestID string `json:"request_id"` ResponseStart time.Time `json:"response_start"` ResponseComplete time.Time `json:"response_complete"` // HTTP header information ResponseCode int `json:"response_code"` Headers []MirroredHeader `json:"headers"` // HTTP body; may be empty. Optionally includes the 'truncated' // field specifying the length Body string `json:"body"` Truncated optionals.Optional[int] `json:"truncated"` }
A response sent by Nginx.
type NginxBackend ¶
type NginxBackend struct {
// contains filtered or unexported fields
}
func NewNginxBackend ¶
func NewNginxBackend(args *Args) (*NginxBackend, error)
func (*NginxBackend) ReportSuccess ¶
func (b *NginxBackend) ReportSuccess(host string)
Log the first successful request
func (*NginxBackend) SendErrorTelemetry ¶
func (b *NginxBackend) SendErrorTelemetry(errorType api_schema.ApidumpErrorType, err error)
Send a message to the backend indicating failure to start and a cause
func (*NginxBackend) SendInitialTelemetry ¶
func (b *NginxBackend) SendInitialTelemetry()
Send the initial message to the backend indicating successful start TODO: refactor to share this telemetry infrastructure with apidump?
func (*NginxBackend) SendPacketTelemetry ¶
func (b *NginxBackend) SendPacketTelemetry(observedDuration int)
Update the backend with new current capture stats.
func (*NginxBackend) SendTelemetry ¶
func (b *NginxBackend) SendTelemetry(req *kgxapi.PostClientPacketCaptureStatsRequest)
Fill in the client ID and start time and send telemetry to the backend.
func (*NginxBackend) TelemetryWorker ¶
func (b *NginxBackend) TelemetryWorker(done <-chan struct{})
Goroutine for sending telemetry. Show on the console after StatsLogDelay seconds, then send packet telemetry.