Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

display IPv6 addresses correctly #12

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ AC_CHECK_LIB([seccomp], [seccomp_init])
# Checks for header files.
AC_CHECK_HEADERS([stdlib.h stdio.h unistd.h stdint.h string.h time.h signal.h])
AC_CHECK_HEADERS([syslog.h fcntl.h seccomp.h netdb.h net/if.h netinet/in.h])
AC_CHECK_HEADERS([sys/types.h sys/stat.h sys/ioctl.h sys/select.h sys/socket.h])
AC_CHECK_HEADERS([sys/types.h sys/stat.h sys/ioctl.h sys/epoll.h sys/socket.h])
AC_CHECK_HEADERS([grp.h pwd.h])

# Checks for typedefs, structures, and compiler characteristics.
Expand All @@ -75,7 +75,7 @@ AC_TYPE_UINT64_T

# Checks for library functions.
AC_FUNC_MALLOC
AC_CHECK_FUNCS([memset select socket])
AC_CHECK_FUNCS([memset socket])

# Sanity check for configure
AC_CONFIG_SRCDIR([src/meshvpn.c])
Expand Down
31 changes: 28 additions & 3 deletions include/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@

// cipher context storage
struct s_crypto {
EVP_CIPHER_CTX enc_ctx;
EVP_CIPHER_CTX dec_ctx;
HMAC_CTX hmac_ctx;
EVP_CIPHER_CTX *enc_ctx;
EVP_CIPHER_CTX *dec_ctx;
HMAC_CTX *hmac_ctx;
};


Expand Down Expand Up @@ -119,4 +119,29 @@ int cryptoCalculateSHA512(unsigned char *hash_buf, const int hash_len, const uns
// generate session keys from password
int cryptoSetSessionKeysFromPassword(struct s_crypto *session_ctx, const unsigned char *password, const int password_len, const int cipher_algorithm, const int hmac_algorithm);

#if OPENSSL_VERSION_NUMBER < 0x10100000L
#include <openssl/engine.h>

struct ossl_init_settings_st {
char *filename;
char *appname;
unsigned long flags;
};

typedef struct ossl_init_settings_st OPENSSL_INIT_SETTINGS;

# define OPENSSL_INIT_ADD_ALL_CIPHERS 0x00000004L
# define OPENSSL_INIT_ADD_ALL_DIGESTS 0x00000008L
# define OPENSSL_INIT_LOAD_CONFIG 0x00000040L

void DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key);
HMAC_CTX *HMAC_CTX_new(void);
void HMAC_CTX_free(HMAC_CTX *ctx);
EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void);
void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx);
EVP_MD_CTX *EVP_MD_CTX_new(void);
void EVP_MD_CTX_free(EVP_MD_CTX *ctx);
int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
#endif

#endif
61 changes: 32 additions & 29 deletions include/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
#include <net/if.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/epoll.h>
#endif

#if defined(IO_LINUX)
Expand All @@ -89,55 +89,58 @@

// The IO addr structure.
struct s_io_addr {
unsigned char addr[24];
unsigned char addr[24];
};


// The IO addrinfo structure.
struct s_io_addrinfo {
struct s_io_addr item[16];
int count;
struct s_io_addr item[16];
int count;
};


// The IO handle structure.
struct s_io_handle {
int enabled;
int fd;
struct sockaddr_storage source_sockaddr;
struct s_io_addr source_addr;
int group_id;
int content_len;
int type;
int open;
int enabled;
int fd;
struct sockaddr_storage source_sockaddr;
struct s_io_addr source_addr;
int group_id;
int content_len;
int type;
int open;
#if defined(IO_WINDOWS)
HANDLE fd_h;
int open_h;
OVERLAPPED ovlr;
int ovlr_used;
OVERLAPPED ovlw;
int ovlw_used;
HANDLE fd_h;
int open_h;
OVERLAPPED ovlr;
int ovlr_used;
OVERLAPPED ovlw;
int ovlw_used;
#endif
};


// The IO state structure.
struct s_io_state {
unsigned char *mem;
struct s_io_handle *handle;
int bufsize;
int max;
int count;
int timeout;
int sockmark;
int nat64clat;
unsigned char nat64_prefix[12];
int debug;
unsigned char *mem;
struct s_io_handle *handle;
int bufsize;
int max;
int count;
int timeout;
int sockmark;
int nat64clat;
unsigned char nat64_prefix[12];
int debug;
#if defined(IO_LINUX) || defined(IO_BSD)
int epollfd;
#endif
};


// Returns length of string.
int ioStrlen(const char *str, const int max_len);
size_t ioStrlen(const char *str, const size_t max_len);

// Resolve name. Returns number of addresses.
int ioResolveName(struct s_io_addrinfo *iai, const char *hostname, const char *port);
Expand Down
32 changes: 16 additions & 16 deletions src/app/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,68 +110,68 @@ int parseConfigLine(char *line, int len, struct s_initconfig *cs) {
return 1;
}
else if(parseConfigLineCheckCommand(line,len,"local",&vpos)) {
strncpy(cs->sourceip,&line[vpos],CONFPARSER_NAMEBUF_SIZE);
strncpy(cs->sourceip,&line[vpos],CONFPARSER_NAMEBUF_SIZE+1);
return 1;
}
else if(parseConfigLineCheckCommand(line,len,"port",&vpos)) {
strncpy(cs->sourceport,&line[vpos],CONFPARSER_NAMEBUF_SIZE);
strncpy(cs->sourceport,&line[vpos],CONFPARSER_NAMEBUF_SIZE+1);
return 1;
}
else if(parseConfigLineCheckCommand(line,len,"user",&vpos)) {
strncpy(cs->userstr,&line[vpos],CONFPARSER_NAMEBUF_SIZE);
strncpy(cs->userstr,&line[vpos],CONFPARSER_NAMEBUF_SIZE+1);
return 1;
}
else if(parseConfigLineCheckCommand(line,len,"group",&vpos)) {
strncpy(cs->groupstr,&line[vpos],CONFPARSER_NAMEBUF_SIZE);
strncpy(cs->groupstr,&line[vpos],CONFPARSER_NAMEBUF_SIZE+1);
return 1;
}
else if(parseConfigLineCheckCommand(line, len, "pidfile", &vpos)) {
strncpy(cs->pidfile, &line[vpos],CONFPARSER_NAMEBUF_SIZE);
strncpy(cs->pidfile, &line[vpos],CONFPARSER_NAMEBUF_SIZE+1);
cs->enablepidfile = 1;
return 1;
}
else if(parseConfigLineCheckCommand(line, len, "privatekey", &vpos)) {
strncpy(cs->privatekey, &line[vpos], CONFPARSER_NAMEBUF_SIZE);
strncpy(cs->privatekey, &line[vpos], CONFPARSER_NAMEBUF_SIZE+1);
return 1;
}
else if(parseConfigLineCheckCommand(line,len,"chroot",&vpos)) {
strncpy(cs->chrootstr,&line[vpos],CONFPARSER_NAMEBUF_SIZE);
strncpy(cs->chrootstr,&line[vpos],CONFPARSER_NAMEBUF_SIZE+1);
return 1;
}
else if(parseConfigLineCheckCommand(line,len,"networkname",&vpos)) {
strncpy(cs->networkname,&line[vpos],CONFPARSER_NAMEBUF_SIZE);
strncpy(cs->networkname,&line[vpos],CONFPARSER_NAMEBUF_SIZE+1);
return 1;
}
else if(parseConfigLineCheckCommand(line,len,"interface",&vpos)) {
strncpy(cs->tapname,&line[vpos],CONFPARSER_NAMEBUF_SIZE);
strncpy(cs->tapname,&line[vpos],CONFPARSER_NAMEBUF_SIZE+1);
return 1;
}
else if(parseConfigLineCheckCommand(line,len,"ifconfig4",&vpos)) {
strncpy(cs->ifconfig4,&line[vpos],CONFPARSER_NAMEBUF_SIZE);
strncpy(cs->ifconfig4,&line[vpos],CONFPARSER_NAMEBUF_SIZE+1);
return 1;
}
else if(parseConfigLineCheckCommand(line,len,"ifconfig6",&vpos)) {
strncpy(cs->ifconfig6,&line[vpos],CONFPARSER_NAMEBUF_SIZE);
strncpy(cs->ifconfig6,&line[vpos],CONFPARSER_NAMEBUF_SIZE+1);
return 1;
}
else if(parseConfigLineCheckCommand(line,len,"upcmd",&vpos)) {
strncpy(cs->upcmd,&line[vpos],CONFPARSER_NAMEBUF_SIZE);
strncpy(cs->upcmd,&line[vpos],CONFPARSER_NAMEBUF_SIZE+1);
return 1;
}
else if(parseConfigLineCheckCommand(line,len,"initpeers",&vpos)) {
cs->initpeers[cs->initpeerscount] = malloc(sizeof(char) * CONFPARSER_NAMEBUF_SIZE);
strncpy(cs->initpeers[cs->initpeerscount],&line[vpos],CONFPARSER_NAMEBUF_SIZE);
cs->initpeers[cs->initpeerscount] = malloc(sizeof(char) * (CONFPARSER_NAMEBUF_SIZE+1));
strncpy(cs->initpeers[cs->initpeerscount],&line[vpos],CONFPARSER_NAMEBUF_SIZE+1);
cs->initpeerscount++;
debug("detected new init peers");

return 1;
}
else if(parseConfigLineCheckCommand(line,len,"engine",&vpos)) {
strncpy(cs->engines,&line[vpos],CONFPARSER_NAMEBUF_SIZE);
strncpy(cs->engines,&line[vpos],CONFPARSER_NAMEBUF_SIZE+1);
return 1;
}
else if(parseConfigLineCheckCommand(line,len,"psk",&vpos)) {
strncpy(cs->password,&line[vpos],CONFPARSER_NAMEBUF_SIZE);
strncpy(cs->password,&line[vpos],CONFPARSER_NAMEBUF_SIZE+1);
cs->password_len = strlen(cs->password);
return 1;
}
Expand Down
Loading