From f07b89842a5c09823aa140ec8766f14713171ed4 Mon Sep 17 00:00:00 2001 From: NanamiAdmin Date: Thu, 5 Mar 2026 18:29:58 +0800 Subject: [PATCH] docs(api): update API documentation with new session listing endpoint feat(session): add API endpoint to list active sessions --- docs/api.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ session.go | 2 +- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/docs/api.md b/docs/api.md index 48ba3aa..d00813c 100644 --- a/docs/api.md +++ b/docs/api.md @@ -250,6 +250,55 @@ X-Timestamp: 1704067200000 --- +## List Active Sessions + +**Endpoint**: `/sessionMgr/list` +**Method**: GET +**Auth Required**: Yes (token) +**Permission Level**: Superuser, Admin + +**Request Headers**: +``` +X-Token: your_token +X-Timestamp: 1704067200000 +``` + +| Header | Type | Required | Description | +|--------|------|----------|-------------| +| X-Token | string | Yes | Authentication token | +| X-Timestamp | int64 | Yes | Client timestamp in milliseconds | + +**Response**: +```json +{ + "success": true, + "message": "Active sessions listed", + "data": [ + { + "ID": "session-5f4dcc3b5aa765d61d8327deb882cf99-1704067200000", + "userID": 1, + "username": "admin", + "expireAt": "2024-01-01T01:00:00Z" + }, + { + "ID": "session-7c6a180b36896a0a8c010710c0780347-1704067210000", + "userID": 2, + "username": "new_user", + "expireAt": "2024-01-01T01:00:10Z" + } + ] +} +``` + +| Field | Type | Description | +|-------|------|-------------| +| ID | string | Unique session ID | +| userID | int | User ID | +| username | string | Username | +| expireAt | string | Session expiration time (ISO 8601 format) | + +--- + ## Create frpc Instance **Endpoint:** `/frpcAct/instanceMgr/create` @@ -541,6 +590,7 @@ X-Timestamp: 1704067200000 | Modify instance | ✓ | ✓ | ✗ | | List instances | ✓ | ✓ | ✓ (limited) | | Manage users | ✓ | ✗ | ✗ | +| List active sessions | ✓ | ✓ | ✗ | ## Timestamp Validation diff --git a/session.go b/session.go index e97ceb8..2cc463f 100644 --- a/session.go +++ b/session.go @@ -271,7 +271,7 @@ func JoinSession(userID int, userName string, token string) error { } sessionMap[sessionID] = session - postLog.Info(fmt.Sprintf("[JoinSession] User [%d]%s joined session %s with token %s", userID, userName, sessionID, token)) + postLog.Debug(fmt.Sprintf("[JoinSession] User [%d]%s joined session %s with token %s", userID, userName, sessionID, token)) return nil }