cli

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const KeylogFlag = "--tls-keylog"

KeylogFlag is pcaptui's own spelling of the option; tshark has no such flag and needs the preference below instead.

View Source
const KeylogPref = "tls.keylog_file"

KeylogPref is the Wireshark preference that points at a TLS key log. It was called ssl.keylog_file before Wireshark 3.0, and current releases print a conversion warning if given the old name.

View Source
const TwoPassArg = "-2"

TwoPassArg is what tshark calls it.

View Source
const TwoPassFlag = "--two-pass"

TwoPassFlag is pcaptui's spelling of tshark's -2. It has its own name because it is not simply forwarded: pcaptui applies it to a file and not to a live capture, and says so when asked for the impossible one.

Variables

View Source
var PcaptuiOnly = []string{
	"--pass-thru", "--profile", "--log-tty", "--debug", "--tail",
	"--screenshot", "--screenshot-size", "--screenshot-keys", "--screencast",
}

If args are passed through to tshark (e.g. stdout not a tty), then strip these out so tshark doesn't fail.

The screenshot flags are here because they are pcaptui's own tooling and tshark rejects them outright: `pcaptui --screencast -r x.pcap | cat` handed --screencast straight to tshark.

View Source
var PcaptuiOnlyWithValue = []string{
	"--profile", "--tail", "--screenshot", "--screenshot-size", "--screenshot-keys",
}

PcaptuiOnlyWithValue are the ones whose value is a separate argument, so that dropping the flag has to drop what follows it too. Without this, `pcaptui --profile foo -r x.pcap | cat` left "foo" in tshark's argv, where a bare word is a read filter.

The flags with an optional value are deliberately not here: --pass-thru and --debug can be written bare, and nothing in the argument itself says whether the next word belongs to them.

Functions

func CheckDisplayFilter added in v1.1.0

func CheckDisplayFilter(tsharkBin, emptyPcap, filter string) error

CheckDisplayFilter reports why tshark will not accept filter.

A display filter given on the command line is not checked anywhere else. tshark rejects it, writes to stderr and stops - and because errors from tshark are not shown by default, what the user sees is a program with no filename in the title, an empty filter box, three empty panes and an exit status of zero. The expression they mistyped is not even echoed back for them to correct.

The filter box in the interface has always validated as you type, using exactly this method. This applies the same check to the flag.

emptyPcap is a capture with no packets, which pcaptui writes into its cache directory at startup; tshark needs a file to read before it will parse a filter.

func CheckKeylog

func CheckKeylog(path string) error

CheckKeylog reports why path cannot serve as a TLS key log file.

tshark does not do this itself. Given a path that does not exist, an empty path, or a directory, it starts normally, exits zero, decrypts nothing and says nothing - so a mistyped path is indistinguishable from traffic whose keys are genuinely absent. That silence is the reason this option exists as something more than a documented config key.

An existing but empty file is fine: a browser creates the log when it starts and appends to it as sessions are negotiated.

func FlagIsTrue

func FlagIsTrue(val string) bool

func KeylogArg

func KeylogArg(path string) []string

KeylogArg renders a keylog path as the argument pair tshark expects.

func TsharkArgs

func TsharkArgs(args []string) []string

TsharkArgs converts pcaptui's own command line into one tshark accepts, for the pass-thru case where pcaptui simply becomes tshark.

Pcaptui-only flags are dropped. The two that mean something to tshark are translated rather than dropped, so that a pipeline behaves the way the terminal does: --tls-keylog becomes the preference that turns on decryption, and --two-pass becomes -2.

Types

type Pcaptui

type Pcaptui struct {
	Ifaces          []string       `value-name:"<interfaces>" short:"i" description:"Interface(s) to read."`
	Pcap            flags.Filename `value-name:"<infile/fifo>" short:"r" description:"Pcap file/fifo to read. Use - for stdin."`
	WriteTo         flags.Filename `value-name:"<outfile>" short:"w" description:"Write raw packet data to outfile."`
	DecodeAs        []string       `short:"d" description:"Specify dissection of layer type." value-name:"<layer type>==<selector>,<decode-as protocol>"`
	PrintIfaces     bool           `short:"D" optional:"true" optional-value:"true" description:"Print a list of the interfaces on which pcaptui can capture."`
	DisplayFilter   string         `short:"Y" description:"Apply display filter." value-name:"<displaY filter>"`
	CaptureFilter   string         `short:"f" description:"Apply capture filter." value-name:"<capture filter>"`
	TimestampFormat string         `` /* 239-byte string literal not displayed */
	TLSKeylog       string         `` /* 133-byte string literal not displayed */
	TwoPass         bool           `long:"two-pass" description:"Read the file twice, so fields that depend on later packets are right. Slower to first packet."`
	Screenshot      string         `` /* 138-byte string literal not displayed */
	ScreenshotSize  string         `long:"screenshot-size" hidden:"true" default:"120x36" description:"Screen size for --screenshot." value-name:"<WxH>"`
	ScreenshotKeys  string         `` /* 128-byte string literal not displayed */
	Screencast      bool           `long:"screencast" hidden:"true" description:"Record a frame per keystroke and write an animated SVG (documentation tooling)."`
	PlatformSwitches
	Profile  string   `long:"profile" short:"C" description:"Start with this configuration profile." value-name:"<profile>"`
	PassThru string   `` /* 179-byte string literal not displayed */
	LogTty   bool     `long:"log-tty" optional:"true" optional-value:"true" choice:"true" choice:"false" description:"Log to the terminal."`
	Debug    TriState `` /* 190-byte string literal not displayed */
	Help     bool     `long:"help" short:"h" optional:"true" optional-value:"true" description:"Show this help message."`
	Version  []bool   `long:"version" short:"v" optional:"true" optional-value:"true" description:"Show version information."`

	Args struct {
		FilterOrPcap string `value-name:"<filter-or-file>" description:"Filter (capture for iface, display for pcap), or pcap to read."`
	} `positional-args:"yes"`
}

Pcaptui's own command line arguments. Used if we don't pass through to tshark.

type PlatformSwitches

type PlatformSwitches struct {
	Tty string `long:"tty" description:"Display the UI on this terminal." value-name:"<tty>"`
}

Embedded in the CLI options struct.

func (PlatformSwitches) TtyValue

func (p PlatformSwitches) TtyValue() string

type TailSwitch

type TailSwitch struct{}

func (TailSwitch) TailFileValue

func (t TailSwitch) TailFileValue() string

type TriState

type TriState struct {
	Set bool
	Val bool
}

func (TriState) MarshalFlag

func (b TriState) MarshalFlag() string

func (*TriState) UnmarshalFlag

func (b *TriState) UnmarshalFlag(value string) error

type Tshark

type Tshark struct {
	PassThru       string `` /* 204-byte string literal not displayed */
	Profile        string `long:"profile" short:"C" description:"Start with this configuration profile." value-name:"<profile>"`
	PrintIfaces    bool   `short:"D" optional:"true" optional-value:"true" description:"Print a list of the interfaces on which pcaptui can capture."`
	TLSKeylog      string `` /* 133-byte string literal not displayed */
	TwoPass        bool   `long:"two-pass" description:"Read the file twice, so fields that depend on later packets are right. Slower to first packet."`
	Screenshot     string `` /* 138-byte string literal not displayed */
	ScreenshotSize string `long:"screenshot-size" hidden:"true" default:"120x36" description:"Screen size for --screenshot." value-name:"<WxH>"`
	ScreenshotKeys string `` /* 128-byte string literal not displayed */
	Screencast     bool   `long:"screencast" hidden:"true" description:"Record a frame per keystroke and write an animated SVG (documentation tooling)."`
	TailSwitch
}

Used to determine if we should run tshark instead e.g. stdout is not a tty

Jump to

Keyboard shortcuts

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