Enable the HTTP log based on the full payload option
Some checks failed
Debug build / build (push) Has been cancelled
Validate Gradle Wrapper / Validation (push) Has been cancelled
Test native code / test (push) Has been cancelled
Windows build / build (push) Has been cancelled

This commit is contained in:
emanuele-f 2026-01-12 19:39:38 +01:00
parent 1640cb749c
commit 8afea6b1ef
4 changed files with 14 additions and 9 deletions

View File

@ -361,7 +361,7 @@ public class CaptureService extends VpnService implements Runnable {
last_connections = 0;
mLowMemory = false;
conn_reg = new ConnectionsRegister(this, CONNECTIONS_LOG_SIZE);
mHttpLog = new HttpLog();
mHttpLog = mSettings.full_payload ? new HttpLog() : null;
mDumper = null;
mDumpQueue = null;
mPendingUpdates.clear();

View File

@ -53,8 +53,6 @@ public class HTTPReassembly {
private boolean mInvalidHttp;
private PayloadChunk mFirstChunk;
public static final boolean TODO_ENABLED = true;
/**
* @param reassembleChunks if false, all the chunks will be considered as RAW chunks
* @param listener a listener for the reassembly

View File

@ -37,6 +37,7 @@ import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Lifecycle;
import com.emanuelef.remote_capture.CaptureService;
import com.emanuelef.remote_capture.R;
import com.emanuelef.remote_capture.Utils;
import com.emanuelef.remote_capture.model.FilterDescriptor;
@ -138,13 +139,15 @@ public class DataViewContainerFragment extends Fragment implements MenuProvider
@Override
public void onCreateMenu(@NonNull Menu menu, @NonNull MenuInflater menuInflater) {
if (mCurrentView == VIEW_CONNECTIONS && mConnectionsFragment != null) {
if ((mCurrentView == VIEW_CONNECTIONS) && (mConnectionsFragment != null)) {
if (mConnectionsFragment instanceof ConnectionsFragment) {
((ConnectionsFragment) mConnectionsFragment).onCreateMenu(menu, menuInflater);
}
menu.add(Menu.NONE, R.id.switch_to_http_log, 25, R.string.switch_to_http)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
} else if (mCurrentView == VIEW_HTTP_LOG && mHttpLogFragment != null) {
if (CaptureService.getHttpLog() != null)
menu.add(Menu.NONE, R.id.switch_to_http_log, 25, R.string.switch_to_http)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
} else if ((mCurrentView == VIEW_HTTP_LOG) && (mHttpLogFragment != null)) {
if (mHttpLogFragment instanceof HttpLogFragment) {
((HttpLogFragment) mHttpLogFragment).onCreateMenu(menu, menuInflater);
}

View File

@ -201,7 +201,7 @@ public class ConnectionDescriptor implements HTTPReassembly.ReassemblyListener {
assert(decryption_ignored || isNotDecryptable() || PCAPdroid.getInstance().isDecryptingPcap());
synchronized (this) {
if (HTTPReassembly.TODO_ENABLED && (update.payload_chunks != null)) {
if ((CaptureService.getHttpLog() != null) && (update.payload_chunks != null)) {
int chunk_pos = payload_chunks.size();
for (PayloadChunk chunk: update.payload_chunks) {
@ -224,9 +224,13 @@ public class ConnectionDescriptor implements HTTPReassembly.ReassemblyListener {
}
}
// See HttpLog
private void logHttpChunk(PayloadChunk chunk, int chunk_pos) {
assert (chunk.type == PayloadChunk.ChunkType.HTTP);
if (CaptureService.getHttpLog() == null)
return;
if (mHttpReqReassembly == null) {
// use a lightweight reassembly, without dumping the payload
mHttpReqReassembly = new HTTPReassembly(true, this, false);
@ -371,7 +375,7 @@ public class ConnectionDescriptor implements HTTPReassembly.ReassemblyListener {
}
public synchronized void addPayloadChunkMitm(PayloadChunk chunk) {
if (HTTPReassembly.TODO_ENABLED && (chunk.type == PayloadChunk.ChunkType.HTTP))
if (chunk.type == PayloadChunk.ChunkType.HTTP)
logHttpChunk(chunk, payload_chunks.size());
payload_chunks.add(chunk);