Add Tailscale API probe action
All checks were successful
Gitea Smoke / smoke (push) Successful in 0s
Gitea Android APK / build (push) Successful in 11m40s

This commit is contained in:
Codex 2026-07-06 07:14:01 +00:00
parent e077fa5d14
commit b64ef21831
2 changed files with 55 additions and 19 deletions

View File

@ -9,6 +9,8 @@ APIs directly:
- server URL management for Tailscale `100.x.y.z:3000` APIs - server URL management for Tailscale `100.x.y.z:3000` APIs
- quick server selectors for `100.89.0.2`, `100.89.0.4`, `100.89.0.9`, - quick server selectors for `100.89.0.2`, `100.89.0.4`, `100.89.0.9`,
`100.89.0.11`, and `100.89.0.116` `100.89.0.11`, and `100.89.0.116`
- one-tap probe for the preset Tailscale APIs, showing health/version and
session counts
- native tmux session list - native tmux session list
- create, rename, send command, split pane, select pane, kill pane, pin, mute, - create, rename, send command, split pane, select pane, kill pane, pin, mute,
and kill session through HTTP API and kill session through HTTP API

View File

@ -447,6 +447,7 @@ public final class MainActivity extends Activity {
private void showMainActions() { private void showMainActions() {
String[] items = { String[] items = {
"Health", "Health",
"Probe Tailscale APIs",
"Server status", "Server status",
"Timeline", "Timeline",
"Preferences", "Preferences",
@ -476,63 +477,66 @@ public final class MainActivity extends Activity {
showRaw("Health", () -> api.health()); showRaw("Health", () -> api.health());
break; break;
case 1: case 1:
showRaw("Server status", () -> api.serverStatus()); probeServerProfiles();
break; break;
case 2: case 2:
showRaw("Timeline", () -> api.timeline(50)); showRaw("Server status", () -> api.serverStatus());
break; break;
case 3: case 3:
showRaw("Preferences", () -> api.preferences()); showRaw("Timeline", () -> api.timeline(50));
break; break;
case 4: case 4:
showRaw("All session details", () -> api.sessionsAll()); showRaw("Preferences", () -> api.preferences());
break; break;
case 5: case 5:
showRaw("Pane details", () -> api.sessionsPanes()); showRaw("All session details", () -> api.sessionsAll());
break; break;
case 6: case 6:
showRaw("Kanban projects", () -> api.kanbanProjects()); showRaw("Pane details", () -> api.sessionsPanes());
break; break;
case 7: case 7:
promptCreateKanbanProject(); showRaw("Kanban projects", () -> api.kanbanProjects());
break; break;
case 8: case 8:
promptDeleteKanbanProject(); promptCreateKanbanProject();
break; break;
case 9: case 9:
promptRemoveKanbanSession(); promptDeleteKanbanProject();
break; break;
case 10: case 10:
promptGroupMessages(); promptRemoveKanbanSession();
break; break;
case 11: case 11:
promptSendGroupMessage(); promptGroupMessages();
break; break;
case 12: case 12:
promptScanGroupMessage(); promptSendGroupMessage();
break; break;
case 13: case 13:
promptPostHookEvent(); promptScanGroupMessage();
break; break;
case 14: case 14:
promptUploadImageFile(); promptPostHookEvent();
break; break;
case 15: case 15:
promptUploadImageUrl(); promptUploadImageFile();
break; break;
case 16: case 16:
promptImagePreviewInfo(); promptUploadImageUrl();
break; break;
case 17: case 17:
promptOpenImagePreview(); promptImagePreviewInfo();
break; break;
case 18: case 18:
openExternalUrl(BuildConfig.DEFAULT_APK_URL); promptOpenImagePreview();
break; break;
case 19: case 19:
showUpdateSourcePicker(); openExternalUrl(BuildConfig.DEFAULT_APK_URL);
break; break;
case 20: case 20:
showUpdateSourcePicker();
break;
case 21:
showPermissionsAndUpdateStatus(); showPermissionsAndUpdateStatus();
break; break;
default: default:
@ -1020,6 +1024,36 @@ public final class MainActivity extends Activity {
showMessage("Update source: " + url); showMessage("Update source: " + url);
} }
private void probeServerProfiles() {
progressBar.setVisibility(View.VISIBLE);
setStatus("Probing Tailscale APIs...");
executor.execute(() -> {
StringBuilder text = new StringBuilder();
for (String url : SERVER_PROFILES) {
text.append(url).append('\n');
try {
SessionApiClient client = new SessionApiClient(url);
JSONObject health = new JSONObject(client.health());
List<SessionSummary> sessions = client.getSessions();
text.append(" ok: true\n");
text.append(" version: ")
.append(health.optString("version", "unknown"))
.append(" ")
.append(health.optString("commit", ""))
.append('\n');
text.append(" sessions: ").append(sessions.size()).append('\n');
} catch (Exception error) {
text.append(" failed: ").append(error.getMessage()).append('\n');
}
text.append('\n');
}
runOnUiThread(() -> {
progressBar.setVisibility(View.GONE);
showTextDialog("Tailscale APIs", text.toString());
});
});
}
private void openInstallPermissionSettings() { private void openInstallPermissionSettings() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
showMessage("Install permission is allowed on this Android version"); showMessage("Install permission is allowed on this Android version");