android

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package android configures a USB-connected Android device for HTTPS interception via adb. Every action runs only when the operator explicitly requests it — nothing is applied automatically on startup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Available

func Available() bool

Available reports whether adb is on PATH.

func DisableProxy

func DisableProxy(d Device, port int) error

DisableProxy clears the device global proxy and removes adb reverse for port.

func EnableProxyUSB

func EnableProxyUSB(d Device, port int) error

EnableProxyUSB sets adb reverse and points the device global proxy at 127.0.0.1:port.

func EnableProxyWiFi

func EnableProxyWiFi(d Device, host string, port int) error

EnableProxyWiFi points the device global proxy at host:port (no adb reverse).

func InstallSystemCA

func InstallSystemCA(d Device, certPEM []byte) error

InstallSystemCA installs the CA into the system trust store (rooted device or emulator).

func InstallUserCA

func InstallUserCA(d Device, certPEM []byte) error

InstallUserCA pushes the CA to the device and opens the system install prompt.

func IsEmulator

func IsEmulator(serial string) bool

IsEmulator reports whether serial looks like an Android emulator (emulator-5554).

func LANHost

func LANHost() (string, error)

LANHost returns a likely private LAN IPv4 for this machine.

func ProxyValue

func ProxyValue(d Device) (string, error)

ProxyValue reads the device global HTTP proxy setting.

func RemoveSystemCA

func RemoveSystemCA(d Device, certPEM []byte) error

RemoveSystemCA deletes the Interceptor CA from the system trust store (rooted/emulator).

func ResolveSerial

func ResolveSerial(serial string, devices []Device) (string, error)

ResolveSerial picks the target device serial for display/API responses.

Types

type Device

type Device struct {
	Serial          string `json:"serial"`
	State           string `json:"state"`
	Model           string `json:"model,omitempty"`
	TransportID     int    `json:"transportId,omitempty"`
	Emulator        bool   `json:"emulator,omitempty"`
	SuggestedCAMode string `json:"suggestedCAMode,omitempty"`
}

Device is a connected Android device reported by adb.

func Devices

func Devices() ([]Device, error)

Devices lists adb-attached devices in the "device" or "unauthorized" state.

func EnrichDevice

func EnrichDevice(d Device) Device

EnrichDevice adds emulator detection and suggested CA mode.

func ResolveDevice

func ResolveDevice(serial string, devices []Device) (Device, error)

ResolveDevice picks the target device: an explicit serial or the sole authorized device.

type SetupOpts

type SetupOpts struct {
	ProxyMode string // usb (default) or wifi
	CAMode    string // user, system, or auto
	WiFiHost  string
	Port      int
}

SetupOpts configures a one-click Android intercept setup.

type SetupResult

type SetupResult struct {
	Serial          string   `json:"serial"`
	Proxy           string   `json:"proxy,omitempty"`
	CAMode          string   `json:"caMode,omitempty"`
	Steps           []string `json:"steps"`
	NeedsUserAction bool     `json:"needsUserAction,omitempty"`
	Message         string   `json:"message"`
	Warning         string   `json:"warning,omitempty"`
}

SetupResult is returned from Setup and Teardown.

func Setup

func Setup(d Device, certPEM []byte, opts SetupOpts) (*SetupResult, error)

Setup enables proxy (USB or Wi‑Fi) and installs the CA in one explicit action.

func Teardown

func Teardown(d Device, port int, certPEM []byte, removeSystemCA bool) (*SetupResult, error)

Teardown clears proxy and optionally removes the system CA.

Jump to

Keyboard shortcuts

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