mirror of
https://oauth2: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@github.com/m1ngsama/TNT.git
synced 2026-05-10 19:00:57 +08:00
- Whisper: copy target client ref out of room lock before calling client_send, preventing lock-ordering inversion deadlock - Channel callbacks: call ssh_remove_channel_callbacks before releasing refs to prevent use-after-free if a callback fires during cleanup - Log rotation: rotate messages.log to messages.log.1 when it exceeds 10 MiB, preventing unbounded growth on public servers - tail -nN: accept both "tail -n5" and "tail -n 5" forms, matching standard Unix tail behavior Closes #36
56 lines
1.2 KiB
C
56 lines
1.2 KiB
C
#ifndef COMMON_H
|
|
#define COMMON_H
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <stdatomic.h>
|
|
#include <time.h>
|
|
#include <limits.h>
|
|
#include <pthread.h>
|
|
|
|
/* Project Metadata */
|
|
#define TNT_VERSION "1.0.0"
|
|
|
|
/* Configuration constants */
|
|
#define DEFAULT_PORT 2222
|
|
#define MAX_MESSAGES 100
|
|
#define MAX_USERNAME_LEN 64
|
|
#define MAX_MESSAGE_LEN 1024
|
|
#define MAX_EXEC_COMMAND_LEN 1024
|
|
#define MAX_CLIENTS 64
|
|
#define LOG_FILE "messages.log"
|
|
#define MAX_LOG_SIZE (10 * 1024 * 1024) /* 10 MiB */
|
|
#define HOST_KEY_FILE "host_key"
|
|
#define TNT_DEFAULT_STATE_DIR "."
|
|
|
|
/* ANSI color codes */
|
|
#define ANSI_RESET "\033[0m"
|
|
#define ANSI_BOLD "\033[1m"
|
|
#define ANSI_REVERSE "\033[7m"
|
|
#define ANSI_CLEAR "\033[2J"
|
|
#define ANSI_HOME "\033[H"
|
|
#define ANSI_CLEAR_LINE "\033[K"
|
|
|
|
/* Operating modes */
|
|
typedef enum {
|
|
MODE_INSERT,
|
|
MODE_NORMAL,
|
|
MODE_COMMAND,
|
|
MODE_HELP
|
|
} client_mode_t;
|
|
|
|
/* Help language */
|
|
typedef enum {
|
|
LANG_EN,
|
|
LANG_ZH
|
|
} help_lang_t;
|
|
|
|
/* Runtime helpers */
|
|
const char* tnt_state_dir(void);
|
|
int tnt_ensure_state_dir(void);
|
|
int tnt_state_path(char *buffer, size_t buf_size, const char *filename);
|
|
|
|
#endif /* COMMON_H */
|