all:
- @echo "rat-chat: dev, release"
+ @echo "chat: dev, release"
deps:
-# rat-chat
+# chat
-the old but only beautiful way to have a chat is on terminal
\ No newline at end of file
+chat on terminal is the only way to truly socialize
\ No newline at end of file
-#include "rat-chat/cli/cli.h"
-#include "rat-chat/utils.h"
+#include "chat/cli/cli.h"
+#include "chat/utils.h"
int cli_done = 0;
int TEST_CASE = -1;
-#include "rat-chat/sock/sock.h"
-#include "rat-chat/front/front.h"
+#include "chat/sock/sock.h"
+#include "chat/front/front.h"
-#include "rat-chat/utils.h"
+#include "chat/utils.h"
FILE* LOGFP;
pthread_mutex_t G_MTX;
--- /dev/null
+#ifndef _FRANK_CLI_H_
+#define _FRANK_CLI_H_
+
+#include "chat/core.h"
+
+
+#ifndef VERIFICATION_LOCATION
+# define VERIFICATION_LOCATION "tls/ca.crt.pem"
+#endif
+
+
+# define ASSERT(x) { \
+ if(!(x)) { \
+ fprintf(stderr, "Assertion: %s: function %s, line %d\n", (char*)(__FILE__), (char*)(__func__), (int)__LINE__); \
+ exit(SIGTRAP); \
+ } \
+}
+
+
+
+
+void run_cli(char* addr);
+
+
+void run_cli_test(char* addr, int tc);
+
+
+int connect_to_engine(char* addr, long timeout);
+
+int auth();
+
+int join();
+
+void chat();
+
+void* reader();
+
+
+
+int verify_callback(int preverify, X509_STORE_CTX* x509_ctx);
+
+void init_openssl_library(void);
+void print_cn_name(const char* label, X509_NAME* const name);
+void print_san_name(const char* label, X509* const cert);
+void print_error_string(unsigned long err, const char* const label);
+
+extern int cli_done;
+extern char* PREFERRED_CIPHERS;
+
+
+extern int TEST_CASE;
+
+extern SSL_CTX* ctx;
+extern SSL *ssl ;
+
+extern uint8_t header[HUB_HEADER_BYTELEN];
+extern uint8_t body_len[HUB_BODY_BYTELEN];
+extern uint64_t body_len_new;
+extern uint8_t *body;
+
+#endif
--- /dev/null
+#ifndef _FRANK_HUB_H_
+#define _FRANK_HUB_H_
+
+
+
+#include <stdio.h>
+#include <netinet/in.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <unistd.h>
+#include <time.h>
+#include <endian.h>
+#include <pthread.h>
+#include <stdarg.h>
+#include <sys/time.h>
+#include <poll.h>
+#include <signal.h>
+#include <fcntl.h>
+#include <sys/epoll.h>
+#include <errno.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+
+#include <openssl/ssl.h>
+#include <openssl/err.h>
+#include <openssl/bio.h>
+#include <openssl/pem.h>
+#include <openssl/conf.h>
+#include <openssl/x509.h>
+#include <openssl/buffer.h>
+#include <openssl/x509v3.h>
+#include <openssl/opensslconf.h>
+
+#include "mongoose/mongoose.h"
+#include "cJSON/cJSON.h"
+
+#define DEBUG_THIS 0
+
+#define HUB_WORD 8
+#define HUB_HEADER_BYTELEN HUB_WORD * 3
+#define HUB_BODY_BYTELEN HUB_WORD * 1
+#define HUB_BODY_BYTEMAX HUB_WORD * 1280 //10KB
+#define HUB_TIMEOUT_MS 5000
+
+#define HUB_HEADER_AUTHSOCK "AUTHSOCK"
+#define HUB_HEADER_REGSOCK_CREATE "REGSOCK_CREATE"
+#define HUB_HEADER_REGSOCK_JOIN "REGSOCK_JOIN"
+
+
+#define HUB_HEADER_AUTHFRONT "AUTHFRONT"
+#define HUB_HEADER_AUTHFRANK "AUTHFRANK"
+#define HUB_HEADER_SENDSOCK "SENDSOCK"
+#define HUB_HEADER_RECVSOCK "RECVSOCK"
+#define HUB_HEADER_SENDFRONT "SENDFRONT"
+#define HUB_HEADER_RECVFRONT "RECVFRONT"
+#define HUB_HEADER_SENDFRANK "SENDFRANK"
+#define HUB_HEADER_RECVFRANK "RECVFRANK"
+
+
+
+#define TRUE 1
+#define FALSE 0
+#define MAX_BUFF HUB_BODY_BYTEMAX
+#define MAX_CONN 80
+#define MAX_ID_LEN 1024
+#define MAX_PW_LEN 4096
+#define PORT_FRONT 3000
+#define PORT_SOCK 3001
+
+
+#define ISSOCK 1
+#define ISFRONT 2
+#define CHAN_ISSOCK 3
+#define CHAN_ISFRONT 4
+
+
+
+#define MAX_DEVICE_NAME 40
+#define MAX_EVENTS_NO 400
+#define MAX_EVENT_TEXT_SIZE 10
+#define EVENTS_PER_PAGE 20
+
+#define MAX_USER_NAME 1024
+#define MAX_USER_PASS 2048
+#define MAX_USER_ACCESS_TOKEN 1024
+
+#define MAX_COOKIE_LEN 1024
+#define MAX_COOKIE_KEYLEN 32
+
+#define MAX_USERS 10
+
+#define MAX_PUBLIC_URI_LEN 512
+
+#define MAX_REQUEST_URI_LEN 1024 * 10
+#define MAX_CLIENT_ID_LEN 1024
+#define MAX_CLIENT_SECRET_LEN 1024
+#define MAX_POST_FIELDS_LEN 1024 * 10
+
+#define MAX_CODELEN 256
+#define GOAUTH_TOKENLEN 512
+
+#define MAX_REST_BUFF 1024 * 10
+#define MAX_WS_BUFF 1024 * 10
+
+#define WS_MAX_COMMAND_LEN 32
+#define WS_MAX_COMMAND_DATA_LEN WS_MAX_COMMAND_LEN * 8
+#define WS_MAX_COMMAND_RECV_LEN WS_MAX_COMMAND_LEN * 8 * 8
+
+#define WS_COMMAND_REQ_KEY "reqkey"
+#define WS_COMMAND_ROUNDTRIP "roundtrip"
+
+#define DEFAULT_RANDLEN 64
+
+
+
+#ifndef HTTP_URL
+#define HTTP_URL "http://0.0.0.0:3000"
+#endif
+
+
+#ifndef HTTPS_URL
+#define HTTPS_URL "https://0.0.0.0:3443"
+#endif
+
+
+#define IS_BIG_ENDIAN (!*(unsigned char *)&(uint16_t){1})
+
+#if __BIG_ENDIAN__
+# define htonll(x) (x)
+# define ntohll(x) (x)
+#else
+# define htonll(x) (((uint64_t)htonl((x) & 0xFFFFFFFF) << 32) | htonl((x) >> 32))
+# define ntohll(x) (((uint64_t)ntohl((x) & 0xFFFFFFFF) << 32) | ntohl((x) >> 32))
+#endif
+
+#ifndef SERVER_KEY
+# define SERVER_KEY "tls/server_priv.pem"
+#endif
+
+#ifndef SERVER_CERT
+# define SERVER_CERT "tls/server.crt.pem"
+#endif
+
+#ifndef HUB_CA_CERT
+# define HUB_CA_CERT "tls/ca.crt.pem"
+#endif
+
+#ifndef HUB_CA_PRIV
+# define HUB_CA_PRIV "tls/ca_priv.pem"
+#endif
+
+#ifndef HUB_CA_PUB
+# define HUB_CA_PUB "tls/ca_pub.pem"
+#endif
+
+
+#ifndef SUB1_CERT
+# define SUB1_CERT "tls/sub1.crt.pem"
+#endif
+
+
+#ifndef SUB2_CERT
+# define SUB2_CERT "tls/sub2.crt.pem"
+#endif
+
+
+#define DEFAULT_RANDLEN 64
+//#define WAIT 7
+
+
+
+
+
+struct user {
+ char name[MAX_USER_NAME];
+ char pass[MAX_USER_PASS];
+};
+
+
+struct CHANNEL_CONTEXT {
+ int allocated;
+ int sockfd;
+ int frontfd;
+ char id[MAX_ID_LEN];
+ char pw[MAX_PW_LEN];
+ SSL *ssl;
+ SSL_CTX *ctx;
+ int fd_ptr;
+ int fds[MAX_CONN];
+
+};
+
+struct SOCK_CONTEXT {
+ int allocated;
+ int sockfd;
+ SSL *ssl;
+ SSL_CTX *ctx;
+ int auth;
+ char id[MAX_ID_LEN];
+ int chan_idx;
+};
+
+
+
+
+struct HUB_PACKET {
+
+ int ctx_type;
+ char id[MAX_ID_LEN];
+ int fd;
+ uint8_t header[HUB_HEADER_BYTELEN];
+ uint64_t body_len;
+ uint8_t wbuff[MAX_BUFF];
+ uint8_t* rbuff;
+
+ int flag;
+
+};
+
+struct settings {
+ bool log_enabled;
+ int log_level;
+ long brightness;
+ char *device_name;
+ };
+
+
+
+extern char CA_CERT[MAX_PW_LEN];
+
+extern char CA_PRIV[MAX_PW_LEN];
+
+extern char CA_PUB[MAX_PW_LEN];
+
+
+extern int s_sig_num;
+
+
+extern struct settings s_settings;
+
+extern uint64_t s_boot_timestamp;
+
+extern char *s_json_header;
+
+extern struct mg_mgr mgr;
+
+
+extern struct CHANNEL_CONTEXT CHAN_CTX[MAX_CONN];
+
+extern struct SOCK_CONTEXT SOCK_CTX[MAX_CONN];
+
+
+
+extern FILE* LOGFP;
+extern pthread_mutex_t G_MTX;
+
+extern int SOCK_FD;
+extern int SOCK_SERVLEN;
+extern int SOCK_EPLFD;
+extern struct epoll_event SOCK_EVENT;
+extern struct epoll_event *SOCK_EVENTARRAY;
+
+
+extern int FRONT_FD;
+extern int FRONT_SERVLEN;
+extern int FRONT_EPLFD;
+extern struct epoll_event FRONT_EVENT;
+extern struct epoll_event *FRONT_EVENTARRAY;
+
+extern int MAX_SD;
+
+extern int OPT;
+
+
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _FRANK_HUB_CTL_H_
+#define _FRANK_HUB_CTL_H_
+
+#include "chat/core.h"
+
+int make_socket_non_blocking (int sfd);
+
+SSL_CTX *create_context();
+
+void configure_context(SSL_CTX *ctx);
+
+
+int sig_verify(const char* cert_pem, const char* intermediate_pem);
+
+int extract_common_name(uint8_t* common_name, const char* cert);
+
+int idpw_verify(char* idpw);
+
+int update_chanctx_from_userinfo(char* id, char* pw);
+
+int update_chanctx_from_sockctx(int fd, char* id);
+
+
+
+
+int set_sockctx_by_fd(int fd);
+
+int get_sockctx_by_fd(int fd);
+
+int set_sockctx_id_by_fd(int fd, char* id);
+
+int get_sockctx_id_by_fd(int fd, char* id);
+
+int set_chanctx_by_id(char* id, int create, int fd);
+
+int get_chanctx_by_id(char* id);
+
+int set_sockctx_chan_id_by_fd(int fd, int chan_id);
+
+int get_sockctx_chan_id_by_fd(int fd);
+
+
+
+int calloc_chanctx();
+
+int free_chanctx(int idx);
+
+int calloc_sockctx();
+
+int free_sockctx(int idx, int memfree);
+
+
+
+
+int chanctx_write(int type, char* id, int write_len, uint8_t* wbuff);
+
+int chanctx_read(int type, char* id, int read_len, uint8_t* rbuff);
+
+int sockctx_write(int fd, int write_len, uint8_t* wbuff);
+
+int sockctx_read(int fd, int read_len, uint8_t* rbuff);
+
+
+
+
+void ctx_write_packet(struct HUB_PACKET* hp);
+
+
+void ctx_read_packet(struct HUB_PACKET* hp);
+
+
+
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _FRANK_HUB_FRONT_H_
+#define _FRANK_HUB_FRONT_H_
+
+#include "chat/core.h"
+
+
+
+
+
+
+void* front_listen_and_serve(void* varg);
+
+
+void sntp_fn(struct mg_connection *c, int ev, void *ev_data);
+
+void timer_sntp_fn(void *param);
+
+void route(struct mg_connection *c, int ev, void *ev_data);
+
+
+void front_handler(struct mg_connection *c, struct mg_ws_message *wm);
+
+
+void handle_healtiness_probe(struct mg_connection *c, struct mg_http_message *hm);
+
+
+int front_authenticate(struct mg_connection* c, struct mg_ws_message *wm, int* initial, char* command, char* data);
+
+void front_communicate(int chan_idx, char* command, char* data);
+
+
+
+
+
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _FRANK_HUB_SOCK_H_
+#define _FRANK_HUB_SOCK_H_
+
+
+
+#include "chat/core.h"
+
+
+
+void sock_listen_and_serve(void* varg);
+
+
+void sock_handle_conn();
+
+
+void sock_handle_client(int cfd);
+
+void sock_authenticate(int cfd);
+
+void sock_register(int cfd);
+
+void sock_communicate(int chan_idx, int sock_idx);
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _FRANK_HUB_UTILS_H_
+#define _FRANK_HUB_UTILS_H_
+
+
+
+#include "chat/core.h"
+
+
+#define MAX_TIMESTR_LEN 80
+#define MAX_LOG_TXT_LEN 1024
+#define MAX_FMT_ARG_LEN 128
+
+
+int read_file_to_buffer(uint8_t* buff, int max_buff_len, char* file_path);
+
+int gen_random_bytestream(uint8_t* bytes, size_t num_bytes);
+
+int bin2hex(uint8_t* hexarray, int arrlen, uint8_t* bytearray);
+
+
+
+
+int get_host_port(char* hostname, int* port, char* addr);
+
+
+
+void get_current_time_string(char* tstr);
+
+void sleepms(long ms);
+
+void fmt_logln(FILE *fp, char* fmt_out, ...);
+
+
+#endif
+++ /dev/null
-#ifndef _FRANK_CLI_H_
-#define _FRANK_CLI_H_
-
-#include "rat-chat/core.h"
-
-
-#ifndef VERIFICATION_LOCATION
-# define VERIFICATION_LOCATION "tls/ca.crt.pem"
-#endif
-
-
-# define ASSERT(x) { \
- if(!(x)) { \
- fprintf(stderr, "Assertion: %s: function %s, line %d\n", (char*)(__FILE__), (char*)(__func__), (int)__LINE__); \
- exit(SIGTRAP); \
- } \
-}
-
-
-
-
-void run_cli(char* addr);
-
-
-void run_cli_test(char* addr, int tc);
-
-
-int connect_to_engine(char* addr, long timeout);
-
-int auth();
-
-int join();
-
-void chat();
-
-void* reader();
-
-
-
-int verify_callback(int preverify, X509_STORE_CTX* x509_ctx);
-
-void init_openssl_library(void);
-void print_cn_name(const char* label, X509_NAME* const name);
-void print_san_name(const char* label, X509* const cert);
-void print_error_string(unsigned long err, const char* const label);
-
-extern int cli_done;
-extern char* PREFERRED_CIPHERS;
-
-
-extern int TEST_CASE;
-
-extern SSL_CTX* ctx;
-extern SSL *ssl ;
-
-extern uint8_t header[HUB_HEADER_BYTELEN];
-extern uint8_t body_len[HUB_BODY_BYTELEN];
-extern uint64_t body_len_new;
-extern uint8_t *body;
-
-#endif
+++ /dev/null
-#ifndef _FRANK_HUB_H_
-#define _FRANK_HUB_H_
-
-
-
-#include <stdio.h>
-#include <netinet/in.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <unistd.h>
-#include <time.h>
-#include <endian.h>
-#include <pthread.h>
-#include <stdarg.h>
-#include <sys/time.h>
-#include <poll.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <sys/epoll.h>
-#include <errno.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-
-#include <openssl/ssl.h>
-#include <openssl/err.h>
-#include <openssl/bio.h>
-#include <openssl/pem.h>
-#include <openssl/conf.h>
-#include <openssl/x509.h>
-#include <openssl/buffer.h>
-#include <openssl/x509v3.h>
-#include <openssl/opensslconf.h>
-
-#include "mongoose/mongoose.h"
-#include "cJSON/cJSON.h"
-
-#define DEBUG_THIS 0
-
-#define HUB_WORD 8
-#define HUB_HEADER_BYTELEN HUB_WORD * 3
-#define HUB_BODY_BYTELEN HUB_WORD * 1
-#define HUB_BODY_BYTEMAX HUB_WORD * 1280 //10KB
-#define HUB_TIMEOUT_MS 5000
-
-#define HUB_HEADER_AUTHSOCK "AUTHSOCK"
-#define HUB_HEADER_REGSOCK_CREATE "REGSOCK_CREATE"
-#define HUB_HEADER_REGSOCK_JOIN "REGSOCK_JOIN"
-
-
-#define HUB_HEADER_AUTHFRONT "AUTHFRONT"
-#define HUB_HEADER_AUTHFRANK "AUTHFRANK"
-#define HUB_HEADER_SENDSOCK "SENDSOCK"
-#define HUB_HEADER_RECVSOCK "RECVSOCK"
-#define HUB_HEADER_SENDFRONT "SENDFRONT"
-#define HUB_HEADER_RECVFRONT "RECVFRONT"
-#define HUB_HEADER_SENDFRANK "SENDFRANK"
-#define HUB_HEADER_RECVFRANK "RECVFRANK"
-
-
-
-#define TRUE 1
-#define FALSE 0
-#define MAX_BUFF HUB_BODY_BYTEMAX
-#define MAX_CONN 80
-#define MAX_ID_LEN 1024
-#define MAX_PW_LEN 4096
-#define PORT_FRONT 3000
-#define PORT_SOCK 3001
-
-
-#define ISSOCK 1
-#define ISFRONT 2
-#define CHAN_ISSOCK 3
-#define CHAN_ISFRONT 4
-
-
-
-#define MAX_DEVICE_NAME 40
-#define MAX_EVENTS_NO 400
-#define MAX_EVENT_TEXT_SIZE 10
-#define EVENTS_PER_PAGE 20
-
-#define MAX_USER_NAME 1024
-#define MAX_USER_PASS 2048
-#define MAX_USER_ACCESS_TOKEN 1024
-
-#define MAX_COOKIE_LEN 1024
-#define MAX_COOKIE_KEYLEN 32
-
-#define MAX_USERS 10
-
-#define MAX_PUBLIC_URI_LEN 512
-
-#define MAX_REQUEST_URI_LEN 1024 * 10
-#define MAX_CLIENT_ID_LEN 1024
-#define MAX_CLIENT_SECRET_LEN 1024
-#define MAX_POST_FIELDS_LEN 1024 * 10
-
-#define MAX_CODELEN 256
-#define GOAUTH_TOKENLEN 512
-
-#define MAX_REST_BUFF 1024 * 10
-#define MAX_WS_BUFF 1024 * 10
-
-#define WS_MAX_COMMAND_LEN 32
-#define WS_MAX_COMMAND_DATA_LEN WS_MAX_COMMAND_LEN * 8
-#define WS_MAX_COMMAND_RECV_LEN WS_MAX_COMMAND_LEN * 8 * 8
-
-#define WS_COMMAND_REQ_KEY "reqkey"
-#define WS_COMMAND_ROUNDTRIP "roundtrip"
-
-#define DEFAULT_RANDLEN 64
-
-
-
-#ifndef HTTP_URL
-#define HTTP_URL "http://0.0.0.0:3000"
-#endif
-
-
-#ifndef HTTPS_URL
-#define HTTPS_URL "https://0.0.0.0:3443"
-#endif
-
-
-#define IS_BIG_ENDIAN (!*(unsigned char *)&(uint16_t){1})
-
-#if __BIG_ENDIAN__
-# define htonll(x) (x)
-# define ntohll(x) (x)
-#else
-# define htonll(x) (((uint64_t)htonl((x) & 0xFFFFFFFF) << 32) | htonl((x) >> 32))
-# define ntohll(x) (((uint64_t)ntohl((x) & 0xFFFFFFFF) << 32) | ntohl((x) >> 32))
-#endif
-
-#ifndef SERVER_KEY
-# define SERVER_KEY "tls/server_priv.pem"
-#endif
-
-#ifndef SERVER_CERT
-# define SERVER_CERT "tls/server.crt.pem"
-#endif
-
-#ifndef HUB_CA_CERT
-# define HUB_CA_CERT "tls/ca.crt.pem"
-#endif
-
-#ifndef HUB_CA_PRIV
-# define HUB_CA_PRIV "tls/ca_priv.pem"
-#endif
-
-#ifndef HUB_CA_PUB
-# define HUB_CA_PUB "tls/ca_pub.pem"
-#endif
-
-
-#ifndef SUB1_CERT
-# define SUB1_CERT "tls/sub1.crt.pem"
-#endif
-
-
-#ifndef SUB2_CERT
-# define SUB2_CERT "tls/sub2.crt.pem"
-#endif
-
-
-#define DEFAULT_RANDLEN 64
-//#define WAIT 7
-
-
-
-
-
-struct user {
- char name[MAX_USER_NAME];
- char pass[MAX_USER_PASS];
-};
-
-
-struct CHANNEL_CONTEXT {
- int allocated;
- int sockfd;
- int frontfd;
- char id[MAX_ID_LEN];
- char pw[MAX_PW_LEN];
- SSL *ssl;
- SSL_CTX *ctx;
- int fd_ptr;
- int fds[MAX_CONN];
-
-};
-
-struct SOCK_CONTEXT {
- int allocated;
- int sockfd;
- SSL *ssl;
- SSL_CTX *ctx;
- int auth;
- char id[MAX_ID_LEN];
- int chan_idx;
-};
-
-
-
-
-struct HUB_PACKET {
-
- int ctx_type;
- char id[MAX_ID_LEN];
- int fd;
- uint8_t header[HUB_HEADER_BYTELEN];
- uint64_t body_len;
- uint8_t wbuff[MAX_BUFF];
- uint8_t* rbuff;
-
- int flag;
-
-};
-
-struct settings {
- bool log_enabled;
- int log_level;
- long brightness;
- char *device_name;
- };
-
-
-
-extern char CA_CERT[MAX_PW_LEN];
-
-extern char CA_PRIV[MAX_PW_LEN];
-
-extern char CA_PUB[MAX_PW_LEN];
-
-
-extern int s_sig_num;
-
-
-extern struct settings s_settings;
-
-extern uint64_t s_boot_timestamp;
-
-extern char *s_json_header;
-
-extern struct mg_mgr mgr;
-
-
-extern struct CHANNEL_CONTEXT CHAN_CTX[MAX_CONN];
-
-extern struct SOCK_CONTEXT SOCK_CTX[MAX_CONN];
-
-
-
-extern FILE* LOGFP;
-extern pthread_mutex_t G_MTX;
-
-extern int SOCK_FD;
-extern int SOCK_SERVLEN;
-extern int SOCK_EPLFD;
-extern struct epoll_event SOCK_EVENT;
-extern struct epoll_event *SOCK_EVENTARRAY;
-
-
-extern int FRONT_FD;
-extern int FRONT_SERVLEN;
-extern int FRONT_EPLFD;
-extern struct epoll_event FRONT_EVENT;
-extern struct epoll_event *FRONT_EVENTARRAY;
-
-extern int MAX_SD;
-
-extern int OPT;
-
-
-
-#endif
\ No newline at end of file
+++ /dev/null
-#ifndef _FRANK_HUB_CTL_H_
-#define _FRANK_HUB_CTL_H_
-
-#include "rat-chat/core.h"
-
-int make_socket_non_blocking (int sfd);
-
-SSL_CTX *create_context();
-
-void configure_context(SSL_CTX *ctx);
-
-
-int sig_verify(const char* cert_pem, const char* intermediate_pem);
-
-int extract_common_name(uint8_t* common_name, const char* cert);
-
-int idpw_verify(char* idpw);
-
-int update_chanctx_from_userinfo(char* id, char* pw);
-
-int update_chanctx_from_sockctx(int fd, char* id);
-
-
-
-
-int set_sockctx_by_fd(int fd);
-
-int get_sockctx_by_fd(int fd);
-
-int set_sockctx_id_by_fd(int fd, char* id);
-
-int get_sockctx_id_by_fd(int fd, char* id);
-
-int set_chanctx_by_id(char* id, int create, int fd);
-
-int get_chanctx_by_id(char* id);
-
-int set_sockctx_chan_id_by_fd(int fd, int chan_id);
-
-int get_sockctx_chan_id_by_fd(int fd);
-
-
-
-int calloc_chanctx();
-
-int free_chanctx(int idx);
-
-int calloc_sockctx();
-
-int free_sockctx(int idx, int memfree);
-
-
-
-
-int chanctx_write(int type, char* id, int write_len, uint8_t* wbuff);
-
-int chanctx_read(int type, char* id, int read_len, uint8_t* rbuff);
-
-int sockctx_write(int fd, int write_len, uint8_t* wbuff);
-
-int sockctx_read(int fd, int read_len, uint8_t* rbuff);
-
-
-
-
-void ctx_write_packet(struct HUB_PACKET* hp);
-
-
-void ctx_read_packet(struct HUB_PACKET* hp);
-
-
-
-
-#endif
\ No newline at end of file
+++ /dev/null
-#ifndef _FRANK_HUB_FRONT_H_
-#define _FRANK_HUB_FRONT_H_
-
-#include "rat-chat/core.h"
-
-
-
-
-
-
-void* front_listen_and_serve(void* varg);
-
-
-void sntp_fn(struct mg_connection *c, int ev, void *ev_data);
-
-void timer_sntp_fn(void *param);
-
-void route(struct mg_connection *c, int ev, void *ev_data);
-
-
-void front_handler(struct mg_connection *c, struct mg_ws_message *wm);
-
-
-void handle_healtiness_probe(struct mg_connection *c, struct mg_http_message *hm);
-
-
-int front_authenticate(struct mg_connection* c, struct mg_ws_message *wm, int* initial, char* command, char* data);
-
-void front_communicate(int chan_idx, char* command, char* data);
-
-
-
-
-
-
-#endif
\ No newline at end of file
+++ /dev/null
-#ifndef _FRANK_HUB_SOCK_H_
-#define _FRANK_HUB_SOCK_H_
-
-
-
-#include "rat-chat/core.h"
-
-
-
-void sock_listen_and_serve(void* varg);
-
-
-void sock_handle_conn();
-
-
-void sock_handle_client(int cfd);
-
-void sock_authenticate(int cfd);
-
-void sock_register(int cfd);
-
-void sock_communicate(int chan_idx, int sock_idx);
-
-#endif
\ No newline at end of file
+++ /dev/null
-#ifndef _FRANK_HUB_UTILS_H_
-#define _FRANK_HUB_UTILS_H_
-
-
-
-#include "rat-chat/core.h"
-
-
-#define MAX_TIMESTR_LEN 80
-#define MAX_LOG_TXT_LEN 1024
-#define MAX_FMT_ARG_LEN 128
-
-
-int read_file_to_buffer(uint8_t* buff, int max_buff_len, char* file_path);
-
-int gen_random_bytestream(uint8_t* bytes, size_t num_bytes);
-
-int bin2hex(uint8_t* hexarray, int arrlen, uint8_t* bytearray);
-
-
-
-
-int get_host_port(char* hostname, int* port, char* addr);
-
-
-
-void get_current_time_string(char* tstr);
-
-void sleepms(long ms);
-
-void fmt_logln(FILE *fp, char* fmt_out, ...);
-
-
-#endif
-#include "rat-chat/cli/cli.h"
-#include "rat-chat/utils.h"
+#include "chat/cli/cli.h"
+#include "chat/utils.h"
extern char* PREFERRED_CIPHERS = "HIGH:!aNULL:!kRSA:!SRP:!PSK:!CAMELLIA:!RC4:!MD5:!DSS";
-#include "rat-chat/ctl.h"
+#include "chat/ctl.h"
struct CHANNEL_CONTEXT CHAN_CTX[MAX_CONN];
-#include "rat-chat/ctl.h"
-#include "rat-chat/front/front.h"
-#include "rat-chat/utils.h"
+#include "chat/ctl.h"
+#include "chat/front/front.h"
+#include "chat/utils.h"
struct settings s_settings = {true, 1, 57, NULL};
mg_mgr_init(&mgr);
- s_settings.device_name = strdup("rat-chat");
+ s_settings.device_name = strdup("chat");
mg_http_listen(&mgr, HTTP_URL, route, NULL);
-#include "rat-chat/ctl.h"
-#include "rat-chat/sock/sock.h"
-#include "rat-chat/utils.h"
+#include "chat/ctl.h"
+#include "chat/sock/sock.h"
+#include "chat/utils.h"
int SOCK_FD;
int SOCK_SERVLEN;
-#include "rat-chat/utils.h"
+#include "chat/utils.h"
int read_file_to_buffer(uint8_t* buff, int max_buff_len, char* file_path){