nginx

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadReleaseAsset

func DownloadReleaseAsset(id int, filename string) error

Download a specific asset (the prebuilt module) to a temporary file

func FindNginxModuleDir

func FindNginxModuleDir() optionals.Optional[string]

func FindNginxVersion

func FindNginxVersion() (string, error)

Determine which version of NGINX is installed; for now we'll just use the version command.

func FindPlatform

func FindPlatform() (arch string, os string, err error)

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

func RunDevelopmentServer(listenPort uint16) error

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

func RunServer

func RunServer(args *Args) error

Types

type Args

type Args struct {
	Domain      string
	ClientID    akid.ClientID
	ServiceName string
	ListenPort  uint16

	MaxWitnessSize_bytes int
	Plugins              []plugin.AkitaPlugin
	StatsLogDelay        int
	TelemetryInterval    int
}

type GithubAsset

type GithubAsset struct {
	Name string `json:"name"`
	ID   int    `json:"id"`
}

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 InstallArgs struct {
	DryRun bool

	// Destination directory for the module
	DestDir optionals.Optional[string]
}

type InstallationError

type InstallationError struct {
	Wrapped error
	Remedy  string
}

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

type MirroredHeader struct {
	Header string `json:"header"`
	Value  string `json:"value"`
}

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

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.

Jump to

Keyboard shortcuts

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