-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First connection using SSL successful. Began work on docs.
- Loading branch information
Jose Fonseca
committed
Oct 11, 2020
1 parent
43735ec
commit d1604c0
Showing
31 changed files
with
739 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
cavax - A C language implementation of Avalanche AVAX Protocol | ||
|
||
Browse cavax Documentation at https://crypto.bi/cavax/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/usr/share/automake-1.16/COPYING |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/usr/share/automake-1.16/INSTALL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# https://crypto.bi/cavax/ | ||
AUTOMAKE_OPTIONS=subdir-objects | ||
AM_LDFLAGS= | ||
AM_CPPFLAGS = -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include | ||
ACLOCAL_AMFLAGS=-I m4 | ||
bin_PROGRAMS=bin/cavax | ||
bin_cavax_SOURCES=src/cavax.c src/network/network.c src/network/beacons.c src/network/connect.c src/sys/log.c | ||
bin_cavax_CPPFLAGS = -Wall -Wextra -pedantic-errors -I./include | ||
bin_cavax_LDFLAGS = | ||
bin_cavax_LDADD=-lglib-2.0 -lpthread -lm -lssl -lcrypto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cavax - A C language implementation of Avalanche AVAX Protocol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
cavax - A C language implementation of Avalanche AVAX Protocol | ||
|
||
Browse cavax Documentation at https://crypto.bi/cavax/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
# cavax | ||
A C language implementation of Avalanche AVAX Protocol | ||
|
||
A C language implementation of [Avalanche AVAX Protocol](https://crypto.bi/category/avax/) | ||
|
||
Browse [cavax Documentation](https://crypto.bi/cavax/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# https://crypto.bi/cavax/ | ||
|
||
AC_INIT([cavax], [0.1]) | ||
AC_CONFIG_SRCDIR([.]) | ||
AM_INIT_AUTOMAKE | ||
AC_CONFIG_MACRO_DIRS([m4]) | ||
AC_PREREQ([2.69]) | ||
AC_CONFIG_HEADERS([config.h]) | ||
AC_PROG_CC | ||
AC_CHECK_HEADERS([stdlib.h]) | ||
AC_CONFIG_FILES([Makefile]) | ||
AC_OUTPUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef _Z_CAVAX_CAVAX | ||
#define _Z_CAVAX_CAVAX | ||
|
||
/* | ||
https://crypto.bi/cavax/ | ||
*/ | ||
|
||
// constants from network/network.go | ||
#define defaultInitialReconnectDelay 1 | ||
#define defaultMaxReconnectDelay (60 * 60) | ||
#define DefaultMaxMessageSize (1 << 21) | ||
#define defaultSendQueueSize (1 << 10) | ||
#define defaultMaxNetworkPendingSendBytes (1 << 29) // 512MB | ||
#define defaultNetworkPendingSendBytesToRateLimit (defaultMaxNetworkPendingSendBytes / 4) | ||
#define defaultMaxClockDifference 60 | ||
#define defaultPeerListGossipSpacing 60 | ||
#define defaultPeerListGossipSize 100 | ||
#define defaultPeerListStakerGossipFraction 2 | ||
#define defaultGetVersionTimeout 2 | ||
#define defaultAllowPrivateIPs true | ||
#define defaultGossipSize 50 | ||
#define defaultPingPongTimeout 60 | ||
#define defaultPingFrequency (3 * defaultPingPongTimeout / 4) | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef _Z_CAVAX_CAVAX_GENERAL | ||
#define _Z_CAVAX_CAVAX_GENERAL | ||
|
||
/* | ||
https://crypto.bi/cavax/ | ||
*/ | ||
|
||
#define COUNT_OF(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x]))))) | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef _Z_CAVAX_LOG | ||
#define _Z_CAVAX_LOG | ||
|
||
/* | ||
https://crypto.bi/cavax/ | ||
*/ | ||
|
||
enum cavax_log_message_type_e { | ||
CAVAX_MESSAGE_INFO, | ||
CAVAX_MESSAGE_ERROR, | ||
CAVAX_MESSAGE_WARNING, | ||
CAVAX_MESSAGE_DEBUG, | ||
}; | ||
|
||
void cavax_log(const char *msg, enum cavax_log_message_type_e typ); | ||
|
||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#ifndef _Z_CAVAX_NETWORK_BEACON_FUNCS | ||
#define _Z_CAVAX_NETWORK_BEACON_FUNCS | ||
|
||
/* | ||
https://crypto.bi/cavax/ | ||
*/ | ||
|
||
#include <string.h> | ||
#include <stdint.h> | ||
#include <openssl/ssl.h> | ||
#include <openssl/err.h> | ||
|
||
#include "connection.h" | ||
#include "host.h" | ||
|
||
void cavax_connect_beacons(struct cavax_host cavax_beacons[], size_t beacon_count, SSL_CTX *ctx); | ||
void cavax_disconnect_beacons(struct cavax_peer_connection cavax_beacons[], size_t beacon_count); | ||
|
||
struct cavax_host *cavax_get_random_beacon(void); | ||
|
||
/* | ||
Initialize and connect beacons. | ||
*/ | ||
void cavax_init_beacons(); | ||
void cavax_stop_beacons(); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#ifndef _Z_CAVAX_NETWORK_BEACONS | ||
#define _Z_CAVAX_NETWORK_BEACONS | ||
|
||
/* | ||
https://crypto.bi/cavax/ | ||
*/ | ||
|
||
|
||
#include <string.h> | ||
#include <stdint.h> | ||
#include <openssl/ssl.h> | ||
#include <openssl/err.h> | ||
|
||
#include "host.h" | ||
#include "connect.h" | ||
#include "connection.h" | ||
|
||
// IP and ID lists copied from genesis/beacons.go | ||
char *cavax_beacon_ips[] = { | ||
"54.94.43.49:9651", | ||
"52.79.47.77:9651", | ||
"18.229.206.191:9651", | ||
"3.34.221.73:9651", | ||
"13.244.155.170:9651", | ||
"13.244.47.224:9651", | ||
"122.248.200.212:9651", | ||
"52.30.9.211:9651", | ||
"122.248.199.127:9651", | ||
"18.202.190.40:9651", | ||
"15.206.182.45:9651", | ||
"15.207.11.193:9651", | ||
"44.226.118.72:9651", | ||
"54.185.87.50:9651", | ||
"18.158.15.12:9651", | ||
"3.21.38.33:9651", | ||
"54.93.182.129:9651", | ||
"3.128.138.36:9651", | ||
"3.104.107.241:9651", | ||
"3.106.25.139:9651", | ||
"18.162.129.129:9651", | ||
"18.162.161.230:9651", | ||
"52.47.181.114:9651", | ||
"15.188.9.42:9651" | ||
}; | ||
|
||
char *cavax_beacon_ids[] = { | ||
"NodeID-A6onFGyJjA37EZ7kYHANMR1PFRT8NmXrF", | ||
"NodeID-6SwnPJLH8cWfrJ162JjZekbmzaFpjPcf", | ||
"NodeID-GSgaA47umS1px2ohVjodW9621Ks63xDxD", | ||
"NodeID-BQEo5Fy1FRKLbX51ejqDd14cuSXJKArH2", | ||
"NodeID-Drv1Qh7iJvW3zGBBeRnYfCzk56VCRM2GQ", | ||
"NodeID-DAtCoXfLT6Y83dgJ7FmQg8eR53hz37J79", | ||
"NodeID-FGRoKnyYKFWYFMb6Xbocf4hKuyCBENgWM", | ||
"NodeID-Dw7tuwxpAmcpvVGp9JzaHAR3REPoJ8f2R", | ||
"NodeID-4kCLS16Wy73nt1Zm54jFZsL7Msrv3UCeJ", | ||
"NodeID-9T7NXBFpp8LWCyc58YdKNoowDipdVKAWz", | ||
"NodeID-6ghBh6yof5ouMCya2n9fHzhpWouiZFVVj", | ||
"NodeID-HiFv1DpKXkAAfJ1NHWVqQoojjznibZXHP", | ||
"NodeID-Fv3t2shrpkmvLnvNzcv1rqRKbDAYFnUor", | ||
"NodeID-AaxT2P4uuPAHb7vAD8mNvjQ3jgyaV7tu9", | ||
"NodeID-kZNuQMHhydefgnwjYX1fhHMpRNAs9my1", | ||
"NodeID-A7GwTSd47AcDVqpTVj7YtxtjHREM33EJw", | ||
"NodeID-Hr78Fy8uDYiRYocRYHXp4eLCYeb8x5UuM", | ||
"NodeID-9CkG9MBNavnw7EVSRsuFr7ws9gascDQy3", | ||
"NodeID-A8jypu63CWp76STwKdqP6e9hjL675kdiG", | ||
"NodeID-HsBEx3L71EHWSXaE6gvk2VsNntFEZsxqc", | ||
"NodeID-Nr584bLpGgbCUbZFSBaBz3Xum5wpca9Ym", | ||
"NodeID-QKGoUvqcgormCoMj6yPw9isY7DX9H4mdd", | ||
"NodeID-HCw7S2TVbFPDWNBo1GnFWqJ47f9rDJtt1", | ||
"NodeID-FYv1Lb29SqMpywYXH7yNkcFAzRF2jvm3K" | ||
}; | ||
|
||
#define CAVAX_BEACON_IP_LEN(bcon) (bcon.port_ptr - bcon.ip_ptr) | ||
#define CAVAX_BEACON_LIST_SIZE (sizeof(cavax_beacon_ips) / sizeof(cavax_beacon_ips[0])) | ||
|
||
struct cavax_host cavax_beacons[CAVAX_BEACON_LIST_SIZE]; | ||
struct cavax_peer_connection cavax_beacon_connections[CAVAX_BEACON_LIST_SIZE]; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#ifndef _Z_CAVAX_NETWORK_CONNECT | ||
#define _Z_CAVAX_NETWORK_CONNECT | ||
|
||
/* | ||
https://crypto.bi/cavax/ | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <unistd.h> | ||
#include <sys/socket.h> | ||
#include <arpa/inet.h> | ||
#include <openssl/ssl.h> | ||
#include <openssl/err.h> | ||
|
||
#include "connection.h" | ||
|
||
|
||
/* | ||
Connect a socket to host : port and return socket fd. | ||
*/ | ||
int cavax_connect(const char *host, uint16_t port); | ||
|
||
SSL *cavax_upgrade_connection(int fd, SSL_CTX *ssl_ctx); | ||
|
||
int cavax_connect(const char *host, uint16_t port); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef _Z_CAVAX_NETWORK_CONNECTION | ||
#define _Z_CAVAX_NETWORK_CONNECTION | ||
|
||
/* | ||
https://crypto.bi/cavax/ | ||
*/ | ||
|
||
|
||
#include <stdio.h> | ||
#include <sys/socket.h> | ||
#include <arpa/inet.h> | ||
#include <openssl/ssl.h> | ||
#include <openssl/err.h> | ||
#include <stdbool.h> | ||
|
||
struct cavax_peer_connection { | ||
int fd; | ||
SSL *ssl; | ||
bool responded_version; // mark true if host was live upon connection | ||
}; | ||
|
||
|
||
int cavax_connect(const char *host, uint16_t port); | ||
SSL *cavax_upgrade_connection(int fd, SSL_CTX *ssl_ctx); | ||
void cavax_close_peer_connection(struct cavax_peer_connection *conn); | ||
int cavax_connect(const char *host, uint16_t port); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef _Z_CAVAX_NETWORK_FLA | ||
#define _Z_CAVAX_NETWORK_FLA | ||
|
||
/* | ||
https://crypto.bi/cavax/ | ||
*/ | ||
|
||
|
||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
struct cavax_fixed_length_array { | ||
uint8_t *buf; | ||
size_t len; | ||
}; | ||
|
||
|
||
#endif |
Oops, something went wrong.