feat(frpLogger): add real-time instance log streaming functionality
Implement cross-platform log streaming for frpc instances with support for Windows, systemd, and init.d systems. Includes WebSocket API endpoint for real-time log streaming, token validation, and instance ownership checks. Update README and API documentation to reflect new functionality. The implementation handles: - Platform-specific log collection (Windows Event Log, journalctl, log files) - WebSocket-based real-time streaming - Token validation and instance access control - Log level parsing and formatting - Historical log retrieval since service start
This commit is contained in:
+15
@@ -331,3 +331,18 @@ func ListActiveSessions() []*Session {
|
||||
}
|
||||
return activeSessions
|
||||
}
|
||||
|
||||
func ValidateTokenFromMap(token string) (int, error) {
|
||||
tokenMux.RLock()
|
||||
defer tokenMux.RUnlock()
|
||||
|
||||
for userID, tokenInfo := range tokenMap {
|
||||
if tokenInfo.Token == token {
|
||||
if time.Since(tokenInfo.CreatedAt) > tokenTTL {
|
||||
return 0, fmt.Errorf("token expired")
|
||||
}
|
||||
return userID, nil
|
||||
}
|
||||
}
|
||||
return 0, fmt.Errorf("invalid token")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user