mobile

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package mobile provides the gomobile bindings for honey.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearDeviceMTLS

func ClearDeviceMTLS()

ClearDeviceMTLS removes the registered device mTLS credential (e.g. on logout).

func Exec

func Exec(requestJSON string) (string, error)

Exec runs a shell command on all hosts matching the backends filter. requestJSON: {"config_path":"...","backends":"prod-*","command":"uptime","ssh_user":"ubuntu"} Returns: {"results":[{"host":"...","output":"...","exit_code":0,"error":"..."}]}

func ExecuteRecipe

func ExecuteRecipe(requestJSON string, cb LogCallback) (string, error)

ExecuteRecipe is the gomobile entrypoint.

func GetVersion

func GetVersion() string

GetVersion returns the honey binary version embedded at build time.

func InitDefaultConfig

func InitDefaultConfig(homeDir, configDir, cacheDir, recordDir, recipesDir string) error

InitDefaultConfig initializes the config.yaml file with default paths if they are not set.

func KeyFingerprint

func KeyFingerprint(pemKey, passphrase string) (string, error)

KeyFingerprint validates an SSH private key and returns JSON describing it: {"type":"ED25519","fingerprint":"SHA256:..."}. A passphrase may be supplied for encrypted keys. Returns an error for invalid keys or a wrong passphrase.

func ListBackends

func ListBackends(requestJSON string) (string, error)

ListBackends takes a JSON serialized config path request and returns a JSON serialized hostapi.ListBackendsOutput.

func LoadConfig

func LoadConfig(configDir string) (string, error)

LoadConfig reads the honey config from configDir/config.yaml and returns it as JSON. Returns a minimal empty-config JSON if the file does not exist (first-run case).

func MeshStatus added in v0.3.7

func MeshStatus() string

MeshStatus reports this process's libp2p mesh connectivity as JSON: {"peer_id":"...","connected":true,"relays":["..."]}, or {"error":"..."} when mesh was never started (disabled, or startMeshIfConfigured hasn't run yet). Optional/diagnostic — nothing in pkg/mobile requires a caller to check this before using a mesh-routed honey backend.

func ResolveExitNode

func ResolveExitNode(requestJSON string) (string, error)

ResolveExitNode resolves the SSH exit host so the Android VpnService can build its route table (excluding the exit IP) before establish() yields the TUN fd. requestJSON: {"config_path","backends","name","ssh_user"} returns: {"name","ip","ssh_port","tunnel_routes":["a.b.c.d/32",...]} tunnel_routes is every CIDR EXCEPT the exit IP — i.e. the set the caller must addRoute() into the TUN so SSH-carrier traffic to the exit stays on the physical interface and does not loop through the tunnel.

func SaveConfig

func SaveConfig(configDir string, configJSON string) error

SaveConfig writes a JSON-encoded honey config to configDir/config.yaml. Creates the directory if it does not exist.

func SearchHosts

func SearchHosts(requestJSON string) (string, error)

SearchHosts takes a JSON serialized hostapi.SearchHostsInput and returns a JSON serialized hostapi.SearchHostsOutput.

func SetDeviceMTLS

func SetDeviceMTLS(chainPEM, caPEM string, signer MTLSSigner)

SetDeviceMTLS registers the device client-certificate chain (PEM), the gateway server CA (PEM; empty falls back to system roots), and the signer callback. After this, honey backends marked mtls are reached over the device client cert by the in-process engine (search, backend listing, and WS exec/tunnel).

func StartVPN

func StartVPN(tunFd int, requestJSON string, cb VPNCallback) error

StartVPN attaches the tun2socks engine to an existing VpnService TUN fd and pumps it through a fresh SOCKS5-over-SSH tunnel to the requested exit host. Non-blocking; lifecycle and traffic are streamed via cb. Returns an error if a VPN session is already running or initial connect fails.

func StopVPN

func StopVPN() error

StopVPN tears down the active VPN session. Safe to call when none is running.

Types

type LogCallback

type LogCallback interface {
	OnLog(msg string)
	OnProgress(progressJSON string)
}

LogCallback is implemented by Kotlin to receive real-time updates.

type MTLSSigner

type MTLSSigner interface {
	Sign(digest []byte) ([]byte, error)
}

MTLSSigner is implemented on the mobile side (Android Keystore). Sign returns an ASN.1 DER ECDSA signature over the given already-hashed digest. The private key stays in the device TEE; only signatures cross the boundary.

type VPNCallback

type VPNCallback interface {
	OnState(state string)
	OnStats(statsJSON string)
}

VPNCallback is implemented by Kotlin to receive VPN lifecycle and traffic updates. State is one of: "resolving", "connecting", "connected", "stopping", "disconnected", "error". statsJSON carries cumulative and live throughput: {"up_total","down_total","up_rate","down_rate","uptime_s"}.

Jump to

Keyboard shortcuts

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