#ifndef SOCKS_MANAGER_H
#define SOCKS_MANAGER_H

#include <stdint.h>
#include <stddef.h>

/* ==== Estructura básica de mensaje SOCKS ==== */
typedef struct socks_msg_s {
    uint32_t server_id;
    int exit_flag;
    unsigned char *data;
    size_t data_len;
} socks_msg_t;

/* ==== Callbacks ==== */
typedef void (*socks_send_cb_t)(
    uint32_t server_id,
    int exit_flag,
    const unsigned char *data,
    size_t data_len,
    void *ctx
);

/* ==== Estado global ==== */
extern volatile int socks_proxy_active; // indica si el proxy SOCKS está activo

/* ==== API pública ==== */
void socks_manager_init(void);
void socks_manager_cleanup(void);

int socks_manager_process_incoming(
    uint32_t server_id,
    int exit_flag,
    const unsigned char *data,
    size_t data_len
);

void socks_manager_flush_outgoing(socks_send_cb_t cb, void *ctx);

int socks_manager_start_proxy(uint16_t local_port);
int socks_manager_stop_proxy(void);

#endif /* SOCKS_MANAGER_H */
