minor
This commit is contained in:
parent
910653f5e8
commit
d71ddf70cc
@ -30,6 +30,10 @@ if(NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/openssl/Configure")
|
||||
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/log.c/src/log.c")
|
||||
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
|
||||
endif()
|
||||
|
||||
set(EXTERN "${PROJECT_SOURCE_DIR}/extern")
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
|
||||
37
src/main.c
37
src/main.c
@ -1,9 +1,11 @@
|
||||
#include <arpa/inet.h>
|
||||
#include <errno.h>
|
||||
#include <netinet/in.h>
|
||||
#include <openssl/err.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <openssl/ssl3.h>
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/types.h>
|
||||
#include <netdb.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
@ -22,10 +24,23 @@ die(const char *errstr, ...) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Client connection
|
||||
void
|
||||
die_ssl(const char *errstr, ...) {
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, errstr);
|
||||
vfprintf(stderr, errstr, ap);
|
||||
va_end(ap);
|
||||
|
||||
ERR_print_errors_fp(stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
int fd;
|
||||
} cconnection_t;
|
||||
SSL_CTX *ctx;
|
||||
SSL *ssl;
|
||||
} ClientConnection;
|
||||
|
||||
void*
|
||||
get_in_addr(struct sockaddr *addr) {
|
||||
@ -36,9 +51,13 @@ get_in_addr(struct sockaddr *addr) {
|
||||
return &((struct sockaddr_in6*)addr)->sin6_addr;
|
||||
}
|
||||
|
||||
|
||||
enum { err_size = 512 };
|
||||
char err[err_size];
|
||||
|
||||
// Returns error or nullptr
|
||||
char*
|
||||
connect_server(char *hostname, char *port, cconnection_t *connection) {
|
||||
connect_tcp(char *hostname, char *port, int *clientfd) {
|
||||
int rv;
|
||||
struct addrinfo hints, *res, *p;
|
||||
|
||||
@ -70,8 +89,6 @@ connect_server(char *hostname, char *port, cconnection_t *connection) {
|
||||
}
|
||||
|
||||
if (p == nullptr) {
|
||||
ssize_t err_size = 512;
|
||||
char *err = malloc(512);
|
||||
snprintf(err, err_size, "Failed to connect to %s:%s", hostname, port);
|
||||
return err;
|
||||
}
|
||||
@ -82,8 +99,14 @@ connect_server(char *hostname, char *port, cconnection_t *connection) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char*
|
||||
bind_tcp(char *port) {
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
main() {
|
||||
if(nullptr == NULL) return 1;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user