Fix includes
This commit is contained in:
@ -5,9 +5,8 @@
|
|||||||
* Lorenz Stechauner, 2020-12-19
|
* Lorenz Stechauner, 2020-12-19
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <zlib.h>
|
|
||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
#include "uri.h"
|
|
||||||
|
|
||||||
int magic_init() {
|
int magic_init() {
|
||||||
magic = magic_open(MAGIC_MIME);
|
magic = magic_open(MAGIC_MIME);
|
||||||
|
@ -8,10 +8,14 @@
|
|||||||
#ifndef NECRONDA_SERVER_CACHE_H
|
#ifndef NECRONDA_SERVER_CACHE_H
|
||||||
#define NECRONDA_SERVER_CACHE_H
|
#define NECRONDA_SERVER_CACHE_H
|
||||||
|
|
||||||
|
#include "uri.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <zlib.h>
|
||||||
#include <magic.h>
|
#include <magic.h>
|
||||||
#include <sys/ipc.h>
|
#include <sys/ipc.h>
|
||||||
#include <sys/shm.h>
|
#include <sys/shm.h>
|
||||||
#include "uri.h"
|
|
||||||
|
|
||||||
magic_t magic;
|
magic_t magic;
|
||||||
|
|
||||||
|
11
src/client.c
11
src/client.c
@ -5,18 +5,9 @@
|
|||||||
* Lorenz Stechauner, 2020-12-03
|
* Lorenz Stechauner, 2020-12-03
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "necronda-server.h"
|
#include "client.h"
|
||||||
#include "utils.h"
|
|
||||||
#include "uri.h"
|
|
||||||
#include "http.h"
|
|
||||||
#include "fastcgi.h"
|
|
||||||
|
|
||||||
|
|
||||||
int server_keep_alive = 1;
|
|
||||||
char *log_client_prefix, *log_conn_prefix, *log_req_prefix, *client_geoip;
|
|
||||||
|
|
||||||
struct timeval client_timeout = {.tv_sec = CLIENT_TIMEOUT, .tv_usec = 0};
|
|
||||||
|
|
||||||
host_config *get_host_config(const char *host) {
|
host_config *get_host_config(const char *host) {
|
||||||
for (int i = 0; i < MAX_HOST_CONFIG; i++) {
|
for (int i = 0; i < MAX_HOST_CONFIG; i++) {
|
||||||
host_config *hc = &config[i];
|
host_config *hc = &config[i];
|
||||||
|
23
src/client.h
Normal file
23
src/client.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Necronda Web Server
|
||||||
|
* Client connection and request handlers (header file)
|
||||||
|
* src/client.h
|
||||||
|
* Lorenz Stechauner, 2021-01-17
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NECRONDA_SERVER_CLIENT_H
|
||||||
|
#define NECRONDA_SERVER_CLIENT_H
|
||||||
|
|
||||||
|
#include "necronda-server.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "uri.h"
|
||||||
|
#include "http.h"
|
||||||
|
#include "fastcgi.h"
|
||||||
|
|
||||||
|
|
||||||
|
int server_keep_alive = 1;
|
||||||
|
char *log_client_prefix, *log_conn_prefix, *log_req_prefix, *client_geoip;
|
||||||
|
|
||||||
|
struct timeval client_timeout = {.tv_sec = CLIENT_TIMEOUT, .tv_usec = 0};
|
||||||
|
|
||||||
|
#endif //NECRONDA_SERVER_CLIENT_H
|
@ -6,9 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "uri.h"
|
|
||||||
#include <sys/ipc.h>
|
|
||||||
#include <sys/shm.h>
|
|
||||||
|
|
||||||
int config_init() {
|
int config_init() {
|
||||||
int shm_id = shmget(SHM_KEY_CONFIG, MAX_HOST_CONFIG * sizeof(host_config), IPC_CREAT | IPC_EXCL | 0640);
|
int shm_id = shmget(SHM_KEY_CONFIG, MAX_HOST_CONFIG * sizeof(host_config), IPC_CREAT | IPC_EXCL | 0640);
|
||||||
|
@ -13,6 +13,12 @@
|
|||||||
#define CONFIG_TYPE_LOCAL 1
|
#define CONFIG_TYPE_LOCAL 1
|
||||||
#define CONFIG_TYPE_REVERSE_PROXY 2
|
#define CONFIG_TYPE_REVERSE_PROXY 2
|
||||||
|
|
||||||
|
#include "uri.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/ipc.h>
|
||||||
|
#include <sys/shm.h>
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int type;
|
int type;
|
||||||
|
@ -6,9 +6,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "fastcgi.h"
|
#include "fastcgi.h"
|
||||||
#include "necronda-server.h"
|
|
||||||
|
|
||||||
#include <sys/un.h>
|
|
||||||
|
|
||||||
|
|
||||||
char *fastcgi_add_param(char *buf, const char *key, const char *value) {
|
char *fastcgi_add_param(char *buf, const char *key, const char *value) {
|
||||||
@ -205,7 +202,7 @@ int fastcgi_close_stdin(fastcgi_conn *conn) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fastcgi_php_error(char *msg, int msg_len, char *err_msg) {
|
int fastcgi_php_error(const char *msg, int msg_len, char *err_msg) {
|
||||||
char *msg_str = malloc(msg_len + 1);
|
char *msg_str = malloc(msg_len + 1);
|
||||||
char *ptr0 = msg_str;
|
char *ptr0 = msg_str;
|
||||||
strncpy(msg_str, msg, msg_len);
|
strncpy(msg_str, msg, msg_len);
|
||||||
@ -248,7 +245,7 @@ int fastcgi_php_error(char *msg, int msg_len, char *err_msg) {
|
|||||||
if (ptr3 != NULL && (ptr3 - ptr2) < len2) {
|
if (ptr3 != NULL && (ptr3 - ptr2) < len2) {
|
||||||
len2 = (int) (ptr3 - ptr2);
|
len2 = (int) (ptr3 - ptr2);
|
||||||
}
|
}
|
||||||
print("%s%.*s%s", msg_type == 1 ? WRN_STR : msg_type == 2 ? ERR_STR: "", len2, ptr2, msg_type != 0 ? CLR_STR : "");
|
print("%s%.*s%s", msg_type == 1 ? WRN_STR : msg_type == 2 ? ERR_STR : "", len2, ptr2, msg_type != 0 ? CLR_STR : "");
|
||||||
if (msg_type == 2 && ptr2 == ptr0) {
|
if (msg_type == 2 && ptr2 == ptr0) {
|
||||||
sprintf(err_msg, "%.*s", len2, ptr2);
|
sprintf(err_msg, "%.*s", len2, ptr2);
|
||||||
err = 1;
|
err = 1;
|
||||||
@ -265,6 +262,7 @@ int fastcgi_php_error(char *msg, int msg_len, char *err_msg) {
|
|||||||
}
|
}
|
||||||
ptr0 = ptr1 + 13;
|
ptr0 = ptr1 + 13;
|
||||||
}
|
}
|
||||||
|
free(msg_str);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,15 @@
|
|||||||
#define FASTCGI_CHUNKED 1
|
#define FASTCGI_CHUNKED 1
|
||||||
#define FASTCGI_COMPRESS 2
|
#define FASTCGI_COMPRESS 2
|
||||||
|
|
||||||
|
#include "necronda-server.h"
|
||||||
|
#include "http.h"
|
||||||
|
#include "uri.h"
|
||||||
|
#include "client.h"
|
||||||
|
|
||||||
|
#include <sys/un.h>
|
||||||
|
#include <zlib.h>
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int socket;
|
int socket;
|
||||||
unsigned short req_id;
|
unsigned short req_id;
|
||||||
@ -26,6 +35,8 @@ int fastcgi_init(fastcgi_conn *conn, unsigned int client_num, unsigned int req_n
|
|||||||
|
|
||||||
int fastcgi_close_stdin(fastcgi_conn *conn);
|
int fastcgi_close_stdin(fastcgi_conn *conn);
|
||||||
|
|
||||||
|
int fastcgi_php_error(const char *msg, int msg_len, char *err_msg);
|
||||||
|
|
||||||
int fastcgi_header(fastcgi_conn *conn, http_res *res, char *err_msg);
|
int fastcgi_header(fastcgi_conn *conn, http_res *res, char *err_msg);
|
||||||
|
|
||||||
int fastcgi_send(fastcgi_conn *conn, sock *client, int flags);
|
int fastcgi_send(fastcgi_conn *conn, sock *client, int flags);
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
#include "utils.h"
|
|
||||||
|
|
||||||
|
|
||||||
void http_to_camel_case(char *str, int mode) {
|
void http_to_camel_case(char *str, int mode) {
|
||||||
|
@ -16,6 +16,10 @@
|
|||||||
#define HTTP_REMOVE_ALL 1
|
#define HTTP_REMOVE_ALL 1
|
||||||
#define HTTP_REMOVE_LAST 2
|
#define HTTP_REMOVE_LAST 2
|
||||||
|
|
||||||
|
#include "sock.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned short code;
|
unsigned short code;
|
||||||
char type[16];
|
char type[16];
|
||||||
|
@ -8,6 +8,13 @@
|
|||||||
#ifndef NECRONDA_SERVER_SOCK_H
|
#ifndef NECRONDA_SERVER_SOCK_H
|
||||||
#define NECRONDA_SERVER_SOCK_H
|
#define NECRONDA_SERVER_SOCK_H
|
||||||
|
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/pem.h>
|
||||||
|
#include <openssl/ssl.h>
|
||||||
|
#include <openssl/conf.h>
|
||||||
|
#include <openssl/engine.h>
|
||||||
|
#include <openssl/dh.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int enc:1;
|
unsigned int enc:1;
|
||||||
int socket;
|
int socket;
|
||||||
|
@ -8,13 +8,14 @@
|
|||||||
#ifndef NECRONDA_SERVER_URI_H
|
#ifndef NECRONDA_SERVER_URI_H
|
||||||
#define NECRONDA_SERVER_URI_H
|
#define NECRONDA_SERVER_URI_H
|
||||||
|
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
#define URI_DIR_MODE_NO_VALIDATION 0
|
#define URI_DIR_MODE_NO_VALIDATION 0
|
||||||
#define URI_DIR_MODE_FORBIDDEN 1
|
#define URI_DIR_MODE_FORBIDDEN 1
|
||||||
#define URI_DIR_MODE_LIST 2
|
#define URI_DIR_MODE_LIST 2
|
||||||
#define URI_DIR_MODE_INFO 3
|
#define URI_DIR_MODE_INFO 3
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char etag[64];
|
char etag[64];
|
||||||
char type[24];
|
char type[24];
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
|
||||||
char *format_duration(unsigned long micros, char *buf) {
|
char *format_duration(unsigned long micros, char *buf) {
|
||||||
if (micros < 10000) {
|
if (micros < 10000) {
|
||||||
sprintf(buf, "%.1f ms", (double) micros / 1000);
|
sprintf(buf, "%.1f ms", (double) micros / 1000);
|
||||||
|
Reference in New Issue
Block a user