2017-07-29 22:00:34 +02:00
|
|
|
#ifndef HANDLE_H
|
|
|
|
#define HANDLE_H
|
2020-08-25 16:40:24 +02:00
|
|
|
|
|
|
|
#include <time.h>
|
|
|
|
|
2017-07-29 22:00:34 +02:00
|
|
|
#include "list.h"
|
2020-08-25 16:40:24 +02:00
|
|
|
#include "dictionary.h"
|
2024-03-13 18:07:07 +01:00
|
|
|
#include "plugin.h"
|
2020-08-25 16:40:24 +02:00
|
|
|
|
2018-10-05 19:01:39 +02:00
|
|
|
#define SERVER_NAME "Antd"
|
2020-09-13 01:29:55 +02:00
|
|
|
#define IS_POST(method) (strcmp(method, "POST") == 0)
|
|
|
|
#define IS_GET(method) (strcmp(method, "GET") == 0)
|
|
|
|
#define R_STR(d, k) ((char *)dvalue(d, k))
|
|
|
|
#define R_INT(d, k) (atoi(dvalue(d, k)))
|
|
|
|
#define R_FLOAT(d, k) ((double)atof(dvalue(d, k)))
|
|
|
|
#define R_PTR(d, k) (dvalue(d, k))
|
2017-07-29 22:00:34 +02:00
|
|
|
#define __RESULT__ "{\"result\":%d,\"msg\":\"%s\"}"
|
2020-09-13 01:29:55 +02:00
|
|
|
#define FORM_URL_ENCODE "application/x-www-form-urlencoded"
|
|
|
|
#define FORM_MULTI_PART "multipart/form-data"
|
2019-12-21 15:02:33 +01:00
|
|
|
#define MAX_IO_WAIT_TIME 5 // second
|
2019-12-20 16:49:41 +01:00
|
|
|
|
2020-09-13 01:29:55 +02:00
|
|
|
#define ANTD_CLIENT_ACCEPT 0x0
|
|
|
|
#define ANTD_CLIENT_HANDSHAKE 0x1
|
|
|
|
#define ANTD_CLIENT_HEADER_DECODE 0x2
|
|
|
|
#define ANTD_CLIENT_PLUGIN_EXEC 0x3
|
|
|
|
#define ANTD_CLIENT_PROTO_CHECK 0x4
|
|
|
|
#define ANTD_CLIENT_RESOLVE_REQUEST 0x5
|
|
|
|
#define ANTD_CLIENT_SERVE_FILE 0x6
|
2021-02-24 18:12:36 +01:00
|
|
|
#define ANTD_CLIENT_RQ_DATA_DECODE 0x7
|
|
|
|
#define ANTD_CLIENT_PROXY_MONITOR 0x8
|
2020-01-08 19:17:51 +01:00
|
|
|
|
2023-01-15 18:21:42 +01:00
|
|
|
#define MAX_PATH_LEN 256
|
2023-01-11 22:18:45 +01:00
|
|
|
|
2020-09-13 01:29:55 +02:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
ANTD_CGZ,
|
|
|
|
ANTD_CDEFL,
|
|
|
|
ANTD_CNONE
|
|
|
|
} antd_compress_t;
|
2020-01-08 19:17:51 +01:00
|
|
|
|
2024-03-12 21:59:50 +01:00
|
|
|
|
2024-03-11 22:35:35 +01:00
|
|
|
typedef enum {
|
|
|
|
ANTD_PROTO_IP_4,
|
|
|
|
ANTD_PROTO_IP_6,
|
|
|
|
ANTD_PROTO_ALL
|
|
|
|
} antd_proto_t;
|
|
|
|
|
2020-09-13 01:29:55 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
2018-10-05 19:01:39 +02:00
|
|
|
int sock;
|
2020-09-13 01:29:55 +02:00
|
|
|
void *ssl;
|
|
|
|
int state;
|
2019-07-31 15:11:59 +02:00
|
|
|
time_t last_io;
|
2020-01-08 19:17:51 +01:00
|
|
|
// compress
|
|
|
|
antd_compress_t z_level;
|
2020-09-13 01:29:55 +02:00
|
|
|
void *zstream;
|
|
|
|
int z_status;
|
2018-10-05 19:01:39 +02:00
|
|
|
} antd_client_t;
|
|
|
|
|
2020-09-13 01:29:55 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
antd_client_t *client;
|
2019-12-15 12:10:06 +01:00
|
|
|
dictionary_t request;
|
2024-03-13 18:07:07 +01:00
|
|
|
antd_plugin_ctx_t * context;
|
2018-10-05 19:01:39 +02:00
|
|
|
} antd_request_t;
|
|
|
|
|
2019-12-15 12:10:06 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
dictionary_t header;
|
|
|
|
list_t cookie;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
} antd_response_header_t;
|
|
|
|
|
2018-10-07 01:03:05 +02:00
|
|
|
void set_nonblock(int socket);
|
2018-10-07 14:20:36 +02:00
|
|
|
//void set_block(int socket);
|
2024-03-13 18:07:07 +01:00
|
|
|
#ifdef USE_ZLIB
|
|
|
|
int compressable(char *ctype);
|
|
|
|
void set_gzip_types(list_t list);
|
|
|
|
#endif
|
2020-09-13 01:29:55 +02:00
|
|
|
void antd_send_header(void *, antd_response_header_t *);
|
|
|
|
const char *get_status_str(int stat);
|
|
|
|
int __t(void *, const char *, ...);
|
|
|
|
int __b(void *, const unsigned char *, int);
|
|
|
|
int __f(void *, const char *);
|
2019-12-15 12:10:06 +01:00
|
|
|
|
2020-09-13 01:29:55 +02:00
|
|
|
int upload(const char *, const char *);
|
2017-07-29 22:00:34 +02:00
|
|
|
|
|
|
|
/*Default function for plugin*/
|
2020-09-13 01:29:55 +02:00
|
|
|
void antd_error(void *client, int status, const char *msg);
|
2019-12-15 12:10:06 +01:00
|
|
|
|
|
|
|
int ws_enable(dictionary_t);
|
2020-09-13 01:29:55 +02:00
|
|
|
int read_buf(void *sock, char *buf, int i);
|
|
|
|
int antd_send(void *source, const void *data, int len);
|
|
|
|
int antd_recv(void *source, void *data, int len);
|
2021-01-22 01:12:26 +01:00
|
|
|
int antd_recv_upto(void* src, void* data, int len);
|
2020-09-13 01:29:55 +02:00
|
|
|
int antd_close(void *source);
|
2018-10-19 12:37:26 +02:00
|
|
|
void destroy_request(void *data);
|
2017-07-29 22:00:34 +02:00
|
|
|
#endif
|