Class ApiCaptureProxyServer
java.lang.Object
com.shaft.capture.proxy.ApiCaptureProxyServer
- All Implemented Interfaces:
AutoCloseable
Embedded, loopback-only MITM HTTP(S) proxy for recording native mobile API traffic. Every
request/response pair that passes through is delivered to
sink as a raw
ProxyTransaction; safe, non-sensitive operational issues (a transaction that could not
be captured, a host with a pinned/unimpersonable certificate) are delivered to warn.
Binds to 127.0.0.1 only -- this proxy is meant to be reached either directly (an
emulator on the same machine) or via adb reverse/port-forwarding from a device, never by
exposing it on a LAN-routable address.
-
Constructor Summary
ConstructorsConstructorDescriptionApiCaptureProxyServer(CaptureCertificateAuthority certificateAuthority, int requestedPort, Consumer<ProxyTransaction> sink, Consumer<String> warn) Starts the proxy on a loopback port. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPinnedHost(String host) Adds a hostname to the pinned set so its traffic is tunneled without MITM interception.voidclose()Known-pinned hostnames tunneled without MITM interception (Tier-3, seeCapturingHttpFilters) rather than having capture attempted and failing.intport()Returns the loopback port this proxy is actually listening on (resolved even whenrequestedPortwas0).voidremovePinnedHost(String host) Removes a hostname from the pinned set, resuming MITM interception for it.voidstop()Stops the proxy, closing all active connections.
-
Constructor Details
-
ApiCaptureProxyServer
public ApiCaptureProxyServer(CaptureCertificateAuthority certificateAuthority, int requestedPort, Consumer<ProxyTransaction> sink, Consumer<String> warn) Starts the proxy on a loopback port.- Parameters:
certificateAuthority- CA used to impersonate HTTPS hostsrequestedPort- port to bind, or0to let the OS choose a free portsink- destination for each captured transactionwarn- destination for safe operational warnings
-
-
Method Details
-
pinnedHosts
Known-pinned hostnames tunneled without MITM interception (Tier-3, seeCapturingHttpFilters) rather than having capture attempted and failing. Returns an immutable snapshot -- useaddPinnedHost(String)/removePinnedHost(String)to mutate the underlying set rather than exposing it directly.- Returns:
- immutable snapshot of currently pinned hostnames
-
addPinnedHost
Adds a hostname to the pinned set so its traffic is tunneled without MITM interception.- Parameters:
host- hostname, without port
-
removePinnedHost
Removes a hostname from the pinned set, resuming MITM interception for it.- Parameters:
host- hostname, without port
-
port
public int port()Returns the loopback port this proxy is actually listening on (resolved even whenrequestedPortwas0).- Returns:
- bound port
-
stop
public void stop()Stops the proxy, closing all active connections. -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-