diff --git a/auth/enc_ks.h b/auth/enc_ks.h deleted file mode 100644 index 330bbd27d299b8022e2d12f314c5923f9bf2ae7c..0000000000000000000000000000000000000000 --- a/auth/enc_ks.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _ENC_KS_H_ -#define _ENC_KS_H_ -#include <time.h> -#include <pthread.h> -#include "uthash.h" -struct dap_http_client; - -struct enc_key; -typedef struct enc_ks_key{ - char id[33]; - struct enc_key *key; - time_t time_created; - pthread_mutex_t mutex; - UT_hash_handle hh; // makes this structure hashable with UTHASH library -} enc_ks_key_t; - -extern int enc_ks_init(); -extern void enc_ks_deinit(); - -extern enc_ks_key_t * enc_ks_find(const char * v_id); -extern struct enc_key * enc_ks_find_http(struct dap_http_client * http); - -//extern enc_ks_key_t * enc_ks_new(); -extern enc_ks_key_t * enc_ks_add(struct enc_key * key); -extern void enc_ks_delete(const char *id); - -#endif diff --git a/core/dap_client.c b/core/dap_client.c index 10e2493aeea487ed6317150864d7f4cdd9455322..d2f9d4aefae5b4c53682c575a832f71e84929afc 100644 --- a/core/dap_client.c +++ b/core/dap_client.c @@ -1,3 +1,23 @@ +/* + Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc + All rights reserved. + + This file is part of DAP (Deus Applications Prototypes) the open source project + + DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + DAP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. +*/ + #include <sys/epoll.h> #include <stdlib.h> #include <stdio.h> diff --git a/core/dap_client.h b/core/dap_client.h index 77c41b67700f9fa7a04affc1a21179ef31c3ccde..1868b4ddb21632ee3a48aab0abfc9377a7227351 100644 --- a/core/dap_client.h +++ b/core/dap_client.h @@ -1,3 +1,23 @@ +/* + Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc + All rights reserved. + + This file is part of DAP (Deus Applications Prototypes) the open source project + + DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + DAP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. +*/ + #ifndef _DAP_CLIENT_H #define _DAP_CLIENT_H diff --git a/core/dap_server.c b/core/dap_server.c index a13148035605aa5426cd4da5f1dadd239e5c8cea..62901056a91028c1d3bc6e5c24034ab6e3f6fe56 100644 --- a/core/dap_server.c +++ b/core/dap_server.c @@ -1,3 +1,23 @@ +/* + Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc + All rights reserved. + + This file is part of DAP (Deus Applications Prototypes) the open source project + + DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + DAP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. +*/ + #include <arpa/inet.h> #include <netinet/in.h> #include <sys/socket.h> diff --git a/core/dap_server.h b/core/dap_server.h index 903833004c9496649c08e72832d86dc93e34d3e0..8cbc25aa883f14a1b6cba9a9f6d66e228be50122 100644 --- a/core/dap_server.h +++ b/core/dap_server.h @@ -1,3 +1,23 @@ +/* + Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc + All rights reserved. + + This file is part of DAP (Deus Applications Prototypes) the open source project + + DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + DAP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. +*/ + #ifndef _SERVER_H_ #define _SERVER_H_ diff --git a/db/CMakeLists.txt b/db/CMakeLists.txt deleted file mode 100644 index 52b8a9240b4e07d72836ec1de6dae45e72235f15..0000000000000000000000000000000000000000 --- a/db/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -cmake_minimum_required(VERSION 2.8) -project (dapdb) - -set(DB_SRCS db_chat.c db_contact.c db_core.c db_http.c db_http_file.c ) - -include_directories("${INCLUDE_DIRECTORIES} ${dapcore_INCLUDE_DIRS}") -include_directories("${INCLUDE_DIRECTORIES} ${dapcrypt_INCLUDE_DIRS}") -include_directories("${INCLUDE_DIRECTORIES} ${dapauth_INCLUDE_DIRS}") -include_directories("${INCLUDE_DIRECTORIES} ${daphttp_INCLUDE_DIRS}") -include_directories("${INCLUDE_DIRECTORIES} ${dapdb_http_INCLUDE_DIRS}") -include_directories("${INCLUDE_DIRECTORIES} ${MONGO_INCLUDE_DIRS}") - -add_definitions ("${dapcore_DEFINITIONS}") -add_definitions ("${dapauth_DEFINITIONS}") -add_definitions ("${dapcrypt_DEFINITIONS}") -add_definitions ("${daphttp_DEFINITIONS}") -add_definitions ("${dapdb_http_DEFINITIONS}") - -add_library(${PROJECT_NAME} STATIC ${DB_SRCS}) - -link_libraries("${MONGO_LIBRARIES}") - -set(${PROJECT_NAME}_DEFINITIONS CACHE INTERNAL "${PROJECT_NAME}: Definitions" FORCE) - -set(${PROJECT_NAME}_INCLUDE_DIRS ${PROJECT_SOURCE_DIR} CACHE INTERNAL "${PROJECT_NAME}: Include Directories" FORCE) diff --git a/db/db_core.c b/db/db_core.c deleted file mode 100644 index 83501868e055d356b140469ce88b236a43b701af..0000000000000000000000000000000000000000 --- a/db/db_core.c +++ /dev/null @@ -1,60 +0,0 @@ -#include <string.h> -#include <bson.h> -#include <bcon.h> -#include <mongoc.h> -#include "common.h" -#include "config.h" -#include "db_core.h" -#define LOG_TAG "db" - -mongoc_client_t *mongo_client = NULL; - -int db_core_init() -{ - mongoc_init(); - - mongo_client = mongoc_client_new (my_config.db_path); - - log_it(DEBUG, "Checking connection to database..."); - if(!mongoc_client_get_server_status(mongo_client, NULL, NULL, NULL)) - { - log_it(ERROR, "Can't connect to database"); - return -1; - } - - return 0; -} - -void db_core_deinit() -{ - mongoc_client_destroy (mongo_client); - mongoc_cleanup (); -} - - - -void db_core_refresh() -{ - -} - - -int db_input_validation(const char * str) -{ - // The compiler will stack "multiple" "strings" "end" "to" "end" - // into "multiplestringsendtoend", so we don't need one giant line. - static const char *nospecial="0123456789" - "abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - ".=@?_!#$%"; - - while(*str) // Loop until (*url) == 0. (*url) is about equivalent to url[0]. - { - // Can we find the character at *url in the string 'nospecial'? - // If not, it's a special character and we should return 0. - if(strchr(nospecial, *str) == NULL) return(0); - str++; // Jump to the next character. Adding one to a pointer moves it ahead one element. - } - - return(1); // Return 1 for success. -} diff --git a/db/db_core.h b/db/db_core.h deleted file mode 100644 index 37f79abdb039e5a03cf7d2bcc8cda496a0af3957..0000000000000000000000000000000000000000 --- a/db/db_core.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _DATABASE_H_ -#define _DATABASE_H_ - -#include <stddef.h> -#include <mongoc.h> - -extern int db_core_init(); -extern void db_core_deinit(); - -extern void db_core_refresh(); - -extern int db_input_validation(const char * str); - -extern mongoc_client_t *mongo_client; - - -#endif diff --git a/db/db_http.c b/db/db_http.c deleted file mode 100644 index 33c5f0d217f3593b3c07fcc49da23948eb01c79d..0000000000000000000000000000000000000000 --- a/db/db_http.c +++ /dev/null @@ -1,76 +0,0 @@ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include "utlist.h" - -#include "common.h" - -#include "dap_client.h" -#include "dap_http_client.h" -#include "../db_http/dap_http_simple.h" - -#include "db_http.h" -#include "db_auth.h" - - -#include "enc_http.h" - -#define LOG_TAG "db_http" - -#define LAST_USE_KEY(key) ((rsa_key_t*)key->internal)->last_time_use_key - -void db_http_proc(dap_http_simple_t * cl_st, void * arg ); - -int db_http_init() -{ - log_it(NOTICE, "Init content manager"); - return 0; -} - -void db_http_deinit() -{ - log_it(NOTICE, "Deinit content manager"); -} - - -void db_http_add_proc(struct dap_http * sh, const char * url) -{ - dap_http_simple_proc_add(sh,url,1000000,db_http_proc); -} - -/** - * @brief content_proc Process content list request - * @param sh HTTP simple client instance - * @param arg Return if ok - */ -void db_http_proc(dap_http_simple_t * cl_st, void * arg ) -{ - bool *isOk= (bool*)arg; - enc_http_delegate_t * dg; - strcpy(cl_st->reply_mime,"application/octet-stream"); - - dg=enc_http_request_decode(cl_st); - if(dg){ - dg->isOk=true; - if(strcmp(dg->url_path,"auth")==0){ - db_auth_http_proc(dg,NULL); - } - else if (strcmp(dg->url_path,"TestRsaKey")==0) { - enc_http_reply_f(dg,"TestRsaKey Request"); - } - else { - if(dg->url_path) - log_it(ERROR,"Wrong DB request %s",dg->url_path); - else - log_it(ERROR,"Wrong DB request: nothing after / "); - dg->isOk=false; - } - *isOk=dg->isOk; - enc_http_reply_encode(cl_st,dg); - enc_http_delegate_delete(dg); - }else{ - *isOk=false; - log_it(WARNING,"No KeyID in the request"); - } -} - diff --git a/db/db_http.h b/db/db_http.h deleted file mode 100644 index 623f089de4e8b00fb19aa86ecb198d2c6fcd6bd9..0000000000000000000000000000000000000000 --- a/db/db_http.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef _DB_HTTP_H_ -#define _DB_HTTP_H_ - -#include "enc_ks.h" -#include "enc_key.h" -#include "config.h" - -extern int db_http_init(); -extern void db_http_deinit(); -extern void db_http_add_proc(struct dap_http * sh, const char * url); -#endif diff --git a/db/db_http_file.c b/db/db_http_file.c deleted file mode 100644 index db909ed6cfc6db5bd3ef6dd91fc4abec1838ea61..0000000000000000000000000000000000000000 --- a/db/db_http_file.c +++ /dev/null @@ -1,245 +0,0 @@ -#include <sys/stat.h> -#include <stdio.h> -#include <unistd.h> -#include <string.h> -#include <errno.h> - -#include "common.h" -#include "config.h" - -//#include "db_content.h" - -#include "dap_http.h" -#include "dap_http_client.h" - -#include "enc.h" -#include "enc_key.h" -#include "enc_ks.h" - -#define LOG_TAG "db_http_file" - -typedef struct db_http_file{ - FILE * fd; - size_t file_size; - enc_key_t * key; - size_t position; - char path[4096]; - dap_http_client_t * client; -} db_http_file_t; - -#define DB_HTTP_FILE(a) ((db_http_file_t*) (a)->internal ) - - -void db_http_file_headers_read(dap_http_client_t * cl_ht, void * arg); -void db_http_file_headers_write(dap_http_client_t * cl_ht, void * arg); -void db_http_file_data_read(dap_http_client_t * cl_ht, void * arg); -void db_http_file_data_write(dap_http_client_t * cl_ht, void * arg); - - -int db_http_file_init() -{ - return 0; -} - -void db_http_file_deinit() -{ - -} - -void db_http_file_proc_add(struct dap_http *sh, const char * url_path) -{ - dap_http_add_proc(sh,url_path,NULL,NULL,NULL,db_http_file_headers_read,db_http_file_headers_write, - db_http_file_data_read,db_http_file_data_write,NULL); -} - - - -/** - * @brief db_http_file_headers_read Signal thats HTTP client is now going to output the data - * @param cl_ht HTTP client instance - * @param arg Not used - */ -void db_http_file_headers_read(dap_http_client_t * cl_ht, void * arg) -{ - (void) arg; - cl_ht->state_write=DAP_HTTP_CLIENT_STATE_START; - cl_ht->state_read=cl_ht->keep_alive?DAP_HTTP_CLIENT_STATE_START:DAP_HTTP_CLIENT_STATE_NONE; - dap_client_ready_to_write(cl_ht->client,true); - dap_client_ready_to_read(cl_ht->client,cl_ht->keep_alive); -} - -/** - * @brief db_http_file_headers Prepare response HTTP headers for file folder request - * @param cl_ht HTTP client instane - * @param arg Not used - */ -void db_http_file_headers_write(dap_http_client_t * cl_ht, void * arg) -{ - (void) arg; - - enc_key_t * key= enc_ks_find_http(cl_ht); - if(key){ - uint8_t buf[sizeof(cl_ht->url_path)]; - size_t buf_size=0; - size_t url_path_size=strlen(cl_ht->url_path); - - if(url_path_size){ - if(url_path_size>sizeof(cl_ht->url_path)){ - log_it(WARNING, "Too big URL path %lu bytes, shrinking to %lu",url_path_size,sizeof(cl_ht->url_path)); - url_path_size=sizeof(cl_ht->url_path); - } - buf_size=enc_decode(key,cl_ht->url_path,url_path_size,buf,ENC_DATA_TYPE_B64); - - uint8_t file_variant=0; - if(strcmp(buf,"poster_small")==0){ - file_variant=1; - }else if(strcmp(buf,"poster_big")==0){ - file_variant=2; - } - if(file_variant){ - size_t in_query_string_length=strlen(cl_ht->in_query_string); - - if(in_query_string_length){ - long long cnt_id; - buf_size=enc_decode(key,cl_ht->in_query_string,in_query_string_length,buf,ENC_DATA_TYPE_B64); - if(sscanf(buf,"id=%lld",&cnt_id)==1){ - char buf2[255]; - snprintf(buf2,sizeof(buf2)-1,"id=%lld",cnt_id); - // db_content_t * cnt=db_content_select(buf2); //erase - void * cnt = NULL; - if(cnt){ - // Produce local path for file to open - char * file_path=NULL; - - /* ERASE */ - /* - if(file_variant==1) - file_path=cnt->poster_small; - else if( file_variant==2) - file_path=cnt->poster_big;*/ - - if(file_path){ - // Init specific file response data for HTTP client instance - cl_ht->internal=(db_http_file_t *) calloc (1,sizeof(db_http_file_t)); - db_http_file_t* cl_ht_file=DB_HTTP_FILE(cl_ht); - cl_ht_file->client=cl_ht; - cl_ht_file->key=key; - - - snprintf(cl_ht_file->path,sizeof(cl_ht_file->path),"%s/%s", my_config.contents_path, file_path ); - - log_it(DEBUG, "Check %s file", cl_ht_file->path); - - struct stat file_stat; - if(stat(cl_ht_file->path,&file_stat)==0){ - cl_ht->out_last_modified=file_stat.st_mtime; - cl_ht->out_content_length=(file_stat.st_size%AES_BLOCK_SIZE )? - (file_stat.st_size +(AES_BLOCK_SIZE- (file_stat.st_size%AES_BLOCK_SIZE) )): - file_stat.st_size; - cl_ht_file->file_size=file_stat.st_size; - cl_ht_file->fd=fopen(cl_ht_file->path,"r"); - if(cl_ht_file->fd == NULL){ - log_it(ERROR, "Can't open %s: %s",cl_ht_file->path,strerror(errno)); - cl_ht->reply_status_code=404; - strncpy(cl_ht->reply_reason_phrase,"Not Found",sizeof(cl_ht->reply_reason_phrase)); - }else{ - log_it(NOTICE, "Open %s file (%lu bytes raw, %lu bytes encrypted )",cl_ht_file->path,cl_ht_file->file_size,cl_ht->out_content_length); - cl_ht->reply_status_code=200; - dap_client_ready_to_write(cl_ht->client,true); - strncpy(cl_ht->reply_reason_phrase,"OK",sizeof(cl_ht->reply_reason_phrase)); - } - - }else{ - log_it(WARNING, "Can't get file info: %s",strerror(errno)); - cl_ht->reply_status_code=404; - strncpy(cl_ht->reply_reason_phrase,"Not Found",sizeof(cl_ht->reply_reason_phrase)); - } - }else{ - log_it(WARNING, "Unknown file variant %uc",file_variant); - cl_ht->reply_status_code=404; - strncpy(cl_ht->reply_reason_phrase,"Not Found",sizeof(cl_ht->reply_reason_phrase)); - } - }else{ - log_it(WARNING, "Can't find id %lld in database",cnt_id); - cl_ht->reply_status_code=404; - strncpy(cl_ht->reply_reason_phrase,"Not Found",sizeof(cl_ht->reply_reason_phrase)); - } - }else{ - log_it(WARNING, "Can't parse decoded in query string '%s'",buf); - cl_ht->reply_status_code=500; - strncpy(cl_ht->reply_reason_phrase,"Not Found",sizeof(cl_ht->reply_reason_phrase)); - } - }else{ - log_it(WARNING, "Empty in query string"); - cl_ht->reply_status_code=404; - strncpy(cl_ht->reply_reason_phrase,"Not Found",sizeof(cl_ht->reply_reason_phrase)); - } - }else{ - log_it(WARNING, "Wrong path request (decoded string '%s' )", buf ); - cl_ht->reply_status_code=500; - strncpy(cl_ht->reply_reason_phrase,"ERROR",sizeof(cl_ht->reply_reason_phrase)); - } - }else{ - - log_it(WARNING, "Empty url path"); - cl_ht->reply_status_code=500; - strncpy(cl_ht->reply_reason_phrase,"ERROR",sizeof(cl_ht->reply_reason_phrase)); - } - }else{ - log_it(WARNING, "No KeyID in request"); - cl_ht->reply_status_code=500; - strncpy(cl_ht->reply_reason_phrase,"ERROR",sizeof(cl_ht->reply_reason_phrase)); - } -} - -/** - * @brief db_http_file_read HTTP client callback for reading function for the folder processing - * @param cl_ht HTTP client instance - * @param arg Pointer to int with return bytes number - */ -void db_http_file_data_read(dap_http_client_t * cl_ht, void * arg) -{ - int * bytes_return = (int*) arg; // Return number of read bytes - //Do nothing - *bytes_return=cl_ht->client->buf_in_size; -} - -/** - * @brief db_http_folder_write HTTP client callback for writting function for the folder processing - * @param cl_ht HTTP client instance - * @param arg - */ -void db_http_file_data_write(dap_http_client_t * cl_ht, void * arg) -{ - (void) arg; - db_http_file_t * cl_ht_file= DB_HTTP_FILE(cl_ht); - - uint8_t buf[AES_BLOCK_SIZE*200]; // We thing that its dividing on AES_BLOCKSIZE to have no trailing zeros in encrypted block - size_t buf_size_max=sizeof(buf); - if(cl_ht_file->file_size- cl_ht_file->position<buf_size_max) - buf_size_max=(cl_ht_file->file_size- cl_ht_file->position); - - if(buf_size_max){ - size_t buf_size=0; - buf_size+=fread(buf+buf_size,1,buf_size_max-buf_size,cl_ht_file->fd); - - cl_ht_file->position+=buf_size; - cl_ht->client->buf_out_size=enc_code(cl_ht_file->key, buf,buf_size,cl_ht->client->buf_out,ENC_DATA_TYPE_RAW); - // log_it(DEBUG, "Have read %lu bytes from the file (ecrypted size %lu total size %lu expecting %lu)",buf_size,cl_ht->client->buf_out_size,cl_ht_file->position, cl_ht_file->client->out_content_length); - if(feof(cl_ht_file->fd)!=0){ - log_it(INFO, "All the file %s is sent out (%lu bytes)",cl_ht_file->path,cl_ht_file->position); - //strncat(cl_ht->client->buf_out+cl_ht->client->buf_out_size,"\r\n",sizeof(cl_ht->client->buf_out)); - fclose(cl_ht_file->fd); - dap_client_ready_to_write(cl_ht->client,false); - cl_ht->client->signal_close=!cl_ht->keep_alive; - cl_ht->state_write=DAP_HTTP_CLIENT_STATE_NONE; - } - }else{ - log_it(INFO, "All the file %s is sent out (%lu bytes)",cl_ht_file->path,cl_ht_file->position); - fclose(cl_ht_file->fd); - dap_client_ready_to_write(cl_ht->client,false); - cl_ht->client->signal_close=!cl_ht->keep_alive; - cl_ht->state_write=DAP_HTTP_CLIENT_STATE_NONE; - } -} - diff --git a/db/db_http_file.h b/db/db_http_file.h deleted file mode 100644 index d0d9a2e5921249043ac532af40db7147595a0eec..0000000000000000000000000000000000000000 --- a/db/db_http_file.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _DB_HTTP_FILE_H_ -#define _DB_HTTP_FILE_H_ -struct dap_http; - -extern int db_http_file_init(); -extern void db_http_file_deinit(); - -extern void db_http_file_proc_add(struct dap_http *sh, const char * url_path); - -#endif diff --git a/db_http/CMakeLists.txt b/db_http/CMakeLists.txt deleted file mode 100644 index 2b709a260d991a14f62b3afd225757e57d679e31..0000000000000000000000000000000000000000 --- a/db_http/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -cmake_minimum_required(VERSION 2.8) -project (dapdb_http) - -set(DB_HTTP_SRCS dap_http_simple.c ) - -include_directories("${INCLUDE_DIRECTORIES} ${dapcore_INCLUDE_DIRS}") -include_directories("${INCLUDE_DIRECTORIES} ${dapcrypt_INCLUDE_DIRS}") -include_directories("${INCLUDE_DIRECTORIES} ${dapauth_INCLUDE_DIRS}") -include_directories("${INCLUDE_DIRECTORIES} ${dapdb_INCLUDE_DIRS}") -include_directories("${INCLUDE_DIRECTORIES} ${daphttp_INCLUDE_DIRS}") -include_directories("${INCLUDE_DIRECTORIES} ${MONGO_INCLUDE_DIRS}") -include_directories("${INCLUDE_DIRECTORIES} ${MONGO_LIBRARY_DIRS}") -include_directories("${INCLUDE_DIRECTORIES} ${BSON_INCLUDE_DIRS}") -include_directories("${INCLUDE_DIRECTORIES} ${BSON_LIBRARY_DIRS}") -add_definitions ("${dapcore_DEFINITIONS}") -add_definitions ("${dapcrypt_DEFINITIONS}") -add_definitions ("${dapauth_DEFINITIONS}") -add_definitions ("${daphttp_DEFINITIONS}") -add_definitions ("${dapdb_DEFINITIONS}") - -add_library(${PROJECT_NAME} STATIC ${DB_HTTP_SRCS}) - - -set(${PROJECT_NAME}_DEFINITIONS CACHE INTERNAL "${PROJECT_NAME}: Definitions" FORCE) - -set(${PROJECT_NAME}_INCLUDE_DIRS ${PROJECT_SOURCE_DIR} CACHE INTERNAL "${PROJECT_NAME}: Include Directories" FORCE) diff --git a/auth/CMakeLists.txt b/enc/CMakeLists.txt similarity index 67% rename from auth/CMakeLists.txt rename to enc/CMakeLists.txt index 8efda9b75181b71fee93befcda269eb432962df6..78161c06ac69ffb8d41b0e4420b902829433a9eb 100644 --- a/auth/CMakeLists.txt +++ b/enc/CMakeLists.txt @@ -1,20 +1,16 @@ cmake_minimum_required(VERSION 2.8) -project (dapauth) +project (dapserverenc) -set(AUTH_SRCS db_auth.c enc_http.c enc_ks.c ) +set(SERVERENC_SRCS enc_http.c enc_ks.c ) include_directories("${INCLUDE_DIRECTORIES} ${dapcore_INCLUDE_DIRS}") include_directories("${INCLUDE_DIRECTORIES} ${dapcrypt_INCLUDE_DIRS}") -include_directories("${INCLUDE_DIRECTORIES} ${dapdb_INCLUDE_DIRS}") include_directories("${INCLUDE_DIRECTORIES} ${daphttp_INCLUDE_DIRS}") -include_directories("${INCLUDE_DIRECTORIES} ${dapdb_http_INCLUDE_DIRS}") -include_directories("${INCLUDE_DIRECTORIES} ${MONGO_INCLUDE_DIRS}") add_definitions ("${dapcore_DEFINITIONS}") add_definitions ("${dapdb_DEFINITIONS}") add_definitions ("${dapcrypt_DEFINITIONS}") add_definitions ("${daphttp_DEFINITIONS}") -add_definitions ("${dapdb_http_DEFINITIONS}") add_library(${PROJECT_NAME} STATIC ${AUTH_SRCS}) set(${PROJECT_NAME}_DEFINITIONS CACHE INTERNAL "${PROJECT_NAME}: Definitions" FORCE) diff --git a/auth/enc_http.c b/enc/enc_http.c similarity index 91% rename from auth/enc_http.c rename to enc/enc_http.c index e407d57eeb486ad7859078ae6a3c007d76a5250c..25e385d49726b9f0ede03414fb70b4a81a02d8a0 100644 --- a/auth/enc_http.c +++ b/enc/enc_http.c @@ -1,3 +1,23 @@ +/* + Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc + All rights reserved. + + This file is part of DAP (Deus Applications Prototypes) the open source project + + DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + DAP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. +*/ + #include <stdio.h> #include <string.h> #include <stdint.h> diff --git a/auth/enc_http.h b/enc/enc_http.h similarity index 59% rename from auth/enc_http.h rename to enc/enc_http.h index d62f95008e34515bd33a64dd04138dde6d82d412..abe6f4ca0a4ed74d21ab6e33fca1d413f859875a 100644 --- a/auth/enc_http.h +++ b/enc/enc_http.h @@ -1,3 +1,23 @@ +/* + Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc + All rights reserved. + + This file is part of DAP (Deus Applications Prototypes) the open source project + + DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + DAP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. +*/ + #ifndef _ENC_HTTP_H_ #define _ENC_HTTP_H_ #include <stddef.h> diff --git a/auth/enc_ks.c b/enc/enc_ks.c similarity index 69% rename from auth/enc_ks.c rename to enc/enc_ks.c index a8cc4540ff7cffd231c475a863c02c64d9db71de..7f5d6c7c36240ce3fd13155a8643acc29256ee35 100644 --- a/auth/enc_ks.c +++ b/enc/enc_ks.c @@ -1,3 +1,23 @@ +/* + Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc + All rights reserved. + + This file is part of DAP (Deus Applications Prototypes) the open source project + + DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + DAP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. +*/ + #include "uthash.h" #include "common.h" diff --git a/enc/enc_ks.h b/enc/enc_ks.h new file mode 100644 index 0000000000000000000000000000000000000000..c3cda573cff0f572ceb4362b01e7f39edbdc8194 --- /dev/null +++ b/enc/enc_ks.h @@ -0,0 +1,47 @@ +/* + Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc + All rights reserved. + + This file is part of DAP (Deus Applications Prototypes) the open source project + + DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + DAP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef _ENC_KS_H_ +#define _ENC_KS_H_ +#include <time.h> +#include <pthread.h> +#include "uthash.h" +struct dap_http_client; + +struct enc_key; +typedef struct enc_ks_key{ + char id[33]; + struct enc_key *key; + time_t time_created; + pthread_mutex_t mutex; + UT_hash_handle hh; // makes this structure hashable with UTHASH library +} enc_ks_key_t; + +extern int enc_ks_init(); +extern void enc_ks_deinit(); + +extern enc_ks_key_t * enc_ks_find(const char * v_id); +extern struct enc_key * enc_ks_find_http(struct dap_http_client * http); + +//extern enc_ks_key_t * enc_ks_new(); +extern enc_ks_key_t * enc_ks_add(struct enc_key * key); +extern void enc_ks_delete(const char *id); + +#endif diff --git a/http/CMakeLists.txt b/http/CMakeLists.txt index b061df204c02924a93aeb1b5692967a920c2fba5..96c26e08b074a82f7b4388d5dfa8f145f0602c38 100644 --- a/http/CMakeLists.txt +++ b/http/CMakeLists.txt @@ -1,18 +1,13 @@ cmake_minimum_required(VERSION 2.8) project (daphttp) -set(HTTP_SRCS dap_http.c dap_http_client.c dap_http_folder.c dap_http_header.c ) +set(HTTP_SRCS dap_http.c dap_http_client.c dap_http_folder.c dap_http_header.c dap_http_simple.c dap_http_simple.h ) include_directories("${INCLUDE_DIRECTORIES} ${dapcore_INCLUDE_DIRS}") include_directories("${INCLUDE_DIRECTORIES} ${dapcrypt_INCLUDE_DIRS}") -include_directories("${INCLUDE_DIRECTORIES} ${dapauth_INCLUDE_DIRS}") -include_directories("${INCLUDE_DIRECTORIES} ${dapdb_http_INCLUDE_DIRS}") -include_directories("${INCLUDE_DIRECTORIES} ${MONGO_INCLUDE_DIRS}") add_definitions ("${dapcore_DEFINITIONS}") -add_definitions ("${dapauth_DEFINITIONS}") add_definitions ("${dapcrypt_DEFINITIONS}") -add_definitions ("${dapdb_http_DEFINITIONS}") add_library(${PROJECT_NAME} STATIC ${HTTP_SRCS}) diff --git a/http/dap_http.c b/http/dap_http.c index 683363eef58b293afd326064cd2bbdf9a89e622d..9e407619d8bf6bc866f2c3dfb175585dbb7b654c 100644 --- a/http/dap_http.c +++ b/http/dap_http.c @@ -1,3 +1,23 @@ +/* + Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc + All rights reserved. + + This file is part of DAP (Deus Applications Prototypes) the open source project + + DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + DAP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. +*/ + #include <netinet/in.h> #include <sys/socket.h> diff --git a/http/dap_http.h b/http/dap_http.h index af1846c2e43cacad6ba890a9517ad3a926603eff..f44bb41b9509fe502e30aaf2672f24c5b11fc65a 100644 --- a/http/dap_http.h +++ b/http/dap_http.h @@ -1,3 +1,23 @@ +/* + Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc + All rights reserved. + + This file is part of DAP (Deus Applications Prototypes) the open source project + + DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + DAP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. +*/ + #ifndef _SERVER_HTTP_H_ #define _SERVER_HTTP_H_ #include "dap_server.h" diff --git a/http/dap_http_folder.c b/http/dap_http_folder.c index ce647ffb889291d8364f5fce2ee87b4bad354eb7..ddec9659f0f4ebb394fa6b354a513432458b946b 100644 --- a/http/dap_http_folder.c +++ b/http/dap_http_folder.c @@ -1,3 +1,23 @@ +/* + Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc + All rights reserved. + + This file is part of DAP (Deus Applications Prototypes) the open source project + + DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + DAP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. +*/ + #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> diff --git a/http/dap_http_folder.h b/http/dap_http_folder.h index 52814216be0d31dd3a8cd74595786c4be25004c0..3dec0498a19076fff6cf71e8b4eed3f10ce7c3bc 100644 --- a/http/dap_http_folder.h +++ b/http/dap_http_folder.h @@ -1,3 +1,23 @@ +/* + Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc + All rights reserved. + + This file is part of DAP (Deus Applications Prototypes) the open source project + + DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + DAP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. +*/ + #ifndef _DAP_HTTP_FOLDER_H_ #define _DAP_HTTP_FOLDER_H_ diff --git a/db_http/dap_http_simple.c b/http/dap_http_simple.c similarity index 91% rename from db_http/dap_http_simple.c rename to http/dap_http_simple.c index c7e5cdd102d6ea082a913c2699060a4fa73ed0f1..e7c30e57fc03a301622d2c6437c88afcede44efd 100644 --- a/db_http/dap_http_simple.c +++ b/http/dap_http_simple.c @@ -1,3 +1,23 @@ +/* + Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc + All rights reserved. + + This file is part of DAP (Deus Applications Prototypes) the open source project + + DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + DAP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. +*/ + #include <stdio.h> #include <stdarg.h> #include <stdbool.h> diff --git a/db_http/dap_http_simple.h b/http/dap_http_simple.h similarity index 55% rename from db_http/dap_http_simple.h rename to http/dap_http_simple.h index e239c81d9364a6cc7b516a897cc2295b44560dd6..51fba93d2b3f89f06954df92caa86a1f50dcabd1 100644 --- a/db_http/dap_http_simple.h +++ b/http/dap_http_simple.h @@ -1,3 +1,23 @@ +/* + Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc + All rights reserved. + + This file is part of DAP (Deus Applications Prototypes) the open source project + + DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + DAP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. +*/ + #ifndef _DAP_HTTP_SIMPLE_H_ #define _DAP_HTTP_SIMPLE_H_ #include <stddef.h>