diff options
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | auto_tests/tox_test.c | 16 | ||||
-rw-r--r-- | other/bootstrap_daemon/src/command_line_arguments.h | 3 | ||||
-rw-r--r-- | other/bootstrap_daemon/src/config.c | 5 | ||||
-rw-r--r-- | other/bootstrap_daemon/src/config.h | 6 | ||||
-rw-r--r-- | other/fun/strkey.c | 13 | ||||
-rwxr-xr-x | other/travis/toxcore-script | 6 | ||||
-rw-r--r-- | toxav/toxav.c | 6 | ||||
-rw-r--r-- | toxcore/tox.c | 6 | ||||
-rw-r--r-- | toxdns/toxdns.c | 2 | ||||
-rw-r--r-- | toxencryptsave/toxencryptsave.c | 6 |
11 files changed, 41 insertions, 30 deletions
diff --git a/.travis.yml b/.travis.yml index 2ced7f3c..2b099bae 100644 --- a/.travis.yml +++ b/.travis.yml | |||
@@ -5,7 +5,7 @@ compiler: | |||
5 | 5 | ||
6 | env: | 6 | env: |
7 | matrix: | 7 | matrix: |
8 | - BUILD=hstox | 8 | # - BUILD=hstox |
9 | - BUILD=toxcore | 9 | - BUILD=toxcore |
10 | 10 | ||
11 | addons: | 11 | addons: |
diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c index f57a2611..397c8acd 100644 --- a/auto_tests/tox_test.c +++ b/auto_tests/tox_test.c | |||
@@ -944,7 +944,8 @@ START_TEST(test_many_clients_tcp) | |||
944 | uint8_t dpk[TOX_PUBLIC_KEY_SIZE]; | 944 | uint8_t dpk[TOX_PUBLIC_KEY_SIZE]; |
945 | tox_self_get_dht_id(toxes[0], dpk); | 945 | tox_self_get_dht_id(toxes[0], dpk); |
946 | TOX_ERR_BOOTSTRAP error = 0; | 946 | TOX_ERR_BOOTSTRAP error = 0; |
947 | ck_assert_msg(tox_add_tcp_relay(toxes[i], TOX_LOCALHOST, TCP_RELAY_PORT, dpk, &error), "add relay error, %i, %i", i, error); | 947 | ck_assert_msg(tox_add_tcp_relay(toxes[i], TOX_LOCALHOST, TCP_RELAY_PORT, dpk, &error), "add relay error, %i, %i", i, |
948 | error); | ||
948 | ck_assert_msg(tox_bootstrap(toxes[i], TOX_LOCALHOST, 33445, dpk, 0), "Bootstrap error"); | 949 | ck_assert_msg(tox_bootstrap(toxes[i], TOX_LOCALHOST, 33445, dpk, 0), "Bootstrap error"); |
949 | } | 950 | } |
950 | 951 | ||
@@ -1039,7 +1040,8 @@ START_TEST(test_many_clients_tcp_b) | |||
1039 | tox_callback_friend_request(toxes[i], accept_friend_request, &to_comp); | 1040 | tox_callback_friend_request(toxes[i], accept_friend_request, &to_comp); |
1040 | uint8_t dpk[TOX_PUBLIC_KEY_SIZE]; | 1041 | uint8_t dpk[TOX_PUBLIC_KEY_SIZE]; |
1041 | tox_self_get_dht_id(toxes[(i % NUM_TCP_RELAYS)], dpk); | 1042 | tox_self_get_dht_id(toxes[(i % NUM_TCP_RELAYS)], dpk); |
1042 | ck_assert_msg(tox_add_tcp_relay(toxes[i], TOX_LOCALHOST, TCP_RELAY_PORT + (i % NUM_TCP_RELAYS), dpk, 0), "add relay error"); | 1043 | ck_assert_msg(tox_add_tcp_relay(toxes[i], TOX_LOCALHOST, TCP_RELAY_PORT + (i % NUM_TCP_RELAYS), dpk, 0), |
1044 | "add relay error"); | ||
1043 | tox_self_get_dht_id(toxes[0], dpk); | 1045 | tox_self_get_dht_id(toxes[0], dpk); |
1044 | ck_assert_msg(tox_bootstrap(toxes[i], TOX_LOCALHOST, 33445, dpk, 0), "Bootstrap error"); | 1046 | ck_assert_msg(tox_bootstrap(toxes[i], TOX_LOCALHOST, 33445, dpk, 0), "Bootstrap error"); |
1045 | } | 1047 | } |
@@ -1169,7 +1171,7 @@ START_TEST(test_many_group) | |||
1169 | uint32_t to_comp = 234212; | 1171 | uint32_t to_comp = 234212; |
1170 | int test_run = 0; | 1172 | int test_run = 0; |
1171 | 1173 | ||
1172 | group_test_restart: | 1174 | group_test_restart: |
1173 | 1175 | ||
1174 | for (i = 0; i < NUM_GROUP_TOX; ++i) { | 1176 | for (i = 0; i < NUM_GROUP_TOX; ++i) { |
1175 | toxes[i] = tox_new(0, 0); | 1177 | toxes[i] = tox_new(0, 0); |
@@ -1264,8 +1266,8 @@ START_TEST(test_many_group) | |||
1264 | * important again. | 1266 | * important again. |
1265 | */ | 1267 | */ |
1266 | ck_assert_msg(num_peers == NUM_GROUP_TOX, "\n\tBad number of group peers (pre check)." | 1268 | ck_assert_msg(num_peers == NUM_GROUP_TOX, "\n\tBad number of group peers (pre check)." |
1267 | "\n\t\t\tExpected: %u but tox_instance(%u) only has: %i\n\n", | 1269 | "\n\t\t\tExpected: %u but tox_instance(%u) only has: %i\n\n", |
1268 | NUM_GROUP_TOX, i, num_peers); | 1270 | NUM_GROUP_TOX, i, num_peers); |
1269 | 1271 | ||
1270 | uint8_t title[2048]; | 1272 | uint8_t title[2048]; |
1271 | int ret = tox_group_get_title(toxes[i], 0, title, sizeof(title)); | 1273 | int ret = tox_group_get_title(toxes[i], 0, title, sizeof(title)); |
@@ -1308,8 +1310,8 @@ START_TEST(test_many_group) | |||
1308 | for (i = 0; i < (k - 1); ++i) { | 1310 | for (i = 0; i < (k - 1); ++i) { |
1309 | int num_peers = tox_group_number_peers(toxes[i], 0); | 1311 | int num_peers = tox_group_number_peers(toxes[i], 0); |
1310 | ck_assert_msg(num_peers == (k - 1), "\n\tBad number of group peers (post check)." | 1312 | ck_assert_msg(num_peers == (k - 1), "\n\tBad number of group peers (post check)." |
1311 | "\n\t\t\tExpected: %u but tox_instance(%u) only has: %i\n\n", | 1313 | "\n\t\t\tExpected: %u but tox_instance(%u) only has: %i\n\n", |
1312 | (k - 1), i, num_peers); | 1314 | (k - 1), i, num_peers); |
1313 | } | 1315 | } |
1314 | } | 1316 | } |
1315 | 1317 | ||
diff --git a/other/bootstrap_daemon/src/command_line_arguments.h b/other/bootstrap_daemon/src/command_line_arguments.h index c73cd15e..1d30f428 100644 --- a/other/bootstrap_daemon/src/command_line_arguments.h +++ b/other/bootstrap_daemon/src/command_line_arguments.h | |||
@@ -37,6 +37,7 @@ | |||
37 | * @param log_backend Sets to the provided by the user log backend option. | 37 | * @param log_backend Sets to the provided by the user log backend option. |
38 | * @param run_in_foreground Sets to the provided by the user foreground option. | 38 | * @param run_in_foreground Sets to the provided by the user foreground option. |
39 | */ | 39 | */ |
40 | void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path, LOG_BACKEND *log_backend, bool *run_in_foreground); | 40 | void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path, LOG_BACKEND *log_backend, |
41 | bool *run_in_foreground); | ||
41 | 42 | ||
42 | #endif // COMMAND_LINE_ARGUMENTS_H | 43 | #endif // COMMAND_LINE_ARGUMENTS_H |
diff --git a/other/bootstrap_daemon/src/config.c b/other/bootstrap_daemon/src/config.c index 12ae693d..29924ae4 100644 --- a/other/bootstrap_daemon/src/config.c +++ b/other/bootstrap_daemon/src/config.c | |||
@@ -143,9 +143,8 @@ void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_ports, int | |||
143 | } | 143 | } |
144 | 144 | ||
145 | int get_general_config(const char *cfg_file_path, char **pid_file_path, char **keys_file_path, int *port, | 145 | int get_general_config(const char *cfg_file_path, char **pid_file_path, char **keys_file_path, int *port, |
146 | int *enable_ipv6, | 146 | int *enable_ipv6, int *enable_ipv4_fallback, int *enable_lan_discovery, int *enable_tcp_relay, |
147 | int *enable_ipv4_fallback, int *enable_lan_discovery, int *enable_tcp_relay, uint16_t **tcp_relay_ports, | 147 | uint16_t **tcp_relay_ports, int *tcp_relay_port_count, int *enable_motd, char **motd) |
148 | int *tcp_relay_port_count, int *enable_motd, char **motd) | ||
149 | { | 148 | { |
150 | config_t cfg; | 149 | config_t cfg; |
151 | 150 | ||
diff --git a/other/bootstrap_daemon/src/config.h b/other/bootstrap_daemon/src/config.h index 13cf929a..93e7fc49 100644 --- a/other/bootstrap_daemon/src/config.h +++ b/other/bootstrap_daemon/src/config.h | |||
@@ -37,9 +37,9 @@ | |||
37 | * @return 1 on success, | 37 | * @return 1 on success, |
38 | * 0 on failure, doesn't modify any data pointed by arguments. | 38 | * 0 on failure, doesn't modify any data pointed by arguments. |
39 | */ | 39 | */ |
40 | int get_general_config(const char *cfg_file_path, char **pid_file_path, char **keys_file_path, int *port, int *enable_ipv6, | 40 | int get_general_config(const char *cfg_file_path, char **pid_file_path, char **keys_file_path, int *port, |
41 | int *enable_ipv4_fallback, int *enable_lan_discovery, int *enable_tcp_relay, uint16_t **tcp_relay_ports, | 41 | int *enable_ipv6, int *enable_ipv4_fallback, int *enable_lan_discovery, int *enable_tcp_relay, |
42 | int *tcp_relay_port_count, int *enable_motd, char **motd); | 42 | uint16_t **tcp_relay_ports, int *tcp_relay_port_count, int *enable_motd, char **motd); |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * Bootstraps off nodes listed in the config file. | 45 | * Bootstraps off nodes listed in the config file. |
diff --git a/other/fun/strkey.c b/other/fun/strkey.c index 7e5a1e1c..649b26dd 100644 --- a/other/fun/strkey.c +++ b/other/fun/strkey.c | |||
@@ -46,6 +46,7 @@ | |||
46 | void print_key(unsigned char *key) | 46 | void print_key(unsigned char *key) |
47 | { | 47 | { |
48 | size_t i; | 48 | size_t i; |
49 | |||
49 | for (i = 0; i < crypto_box_PUBLICKEYBYTES; i++) { | 50 | for (i = 0; i < crypto_box_PUBLICKEYBYTES; i++) { |
50 | if (key[i] < 16) { | 51 | if (key[i] < 16) { |
51 | fprintf(stdout, "0"); | 52 | fprintf(stdout, "0"); |
@@ -67,11 +68,14 @@ int main(int argc, char *argv[]) | |||
67 | offset = atoi(argv[1]); | 68 | offset = atoi(argv[1]); |
68 | char *desired_hex = argv[2]; | 69 | char *desired_hex = argv[2]; |
69 | len = strlen(desired_hex); | 70 | len = strlen(desired_hex); |
71 | |||
70 | if (len % 2 != 0) { | 72 | if (len % 2 != 0) { |
71 | fprintf(stderr, "Desired key should have an even number of letters\n"); | 73 | fprintf(stderr, "Desired key should have an even number of letters\n"); |
72 | exit(1); | 74 | exit(1); |
73 | } | 75 | } |
74 | size_t block_length = (offset < 0 ? 0 : offset) + len/2; | 76 | |
77 | size_t block_length = (offset < 0 ? 0 : offset) + len / 2; | ||
78 | |||
75 | if (block_length > crypto_box_PUBLICKEYBYTES) { | 79 | if (block_length > crypto_box_PUBLICKEYBYTES) { |
76 | fprintf(stderr, "The given key with the given offset exceed public key's length\n"); | 80 | fprintf(stderr, "The given key with the given offset exceed public key's length\n"); |
77 | exit(1); | 81 | exit(1); |
@@ -80,6 +84,7 @@ int main(int argc, char *argv[]) | |||
80 | // convert hex to bin | 84 | // convert hex to bin |
81 | char *pos = desired_hex; | 85 | char *pos = desired_hex; |
82 | size_t i; | 86 | size_t i; |
87 | |||
83 | for (i = 0; i < len; pos += 2) { | 88 | for (i = 0; i < len; pos += 2) { |
84 | sscanf(pos, "%2hhx", &desired_bin[i]); | 89 | sscanf(pos, "%2hhx", &desired_bin[i]); |
85 | ++i; | 90 | ++i; |
@@ -97,12 +102,14 @@ int main(int argc, char *argv[]) | |||
97 | 102 | ||
98 | if (offset < 0) { | 103 | if (offset < 0) { |
99 | int found = 0; | 104 | int found = 0; |
105 | |||
100 | do { | 106 | do { |
101 | #ifdef PRINT_TRIES_COUNT | 107 | #ifdef PRINT_TRIES_COUNT |
102 | tries ++; | 108 | tries ++; |
103 | #endif | 109 | #endif |
104 | crypto_box_keypair(public_key, secret_key); | 110 | crypto_box_keypair(public_key, secret_key); |
105 | int i; | 111 | int i; |
112 | |||
106 | for (i = 0; i <= crypto_box_PUBLICKEYBYTES - len; i ++) { | 113 | for (i = 0; i <= crypto_box_PUBLICKEYBYTES - len; i ++) { |
107 | if (memcmp(public_key + i, desired_bin, len) == 0) { | 114 | if (memcmp(public_key + i, desired_bin, len) == 0) { |
108 | found = 1; | 115 | found = 1; |
@@ -115,7 +122,7 @@ int main(int argc, char *argv[]) | |||
115 | 122 | ||
116 | do { | 123 | do { |
117 | #ifdef PRINT_TRIES_COUNT | 124 | #ifdef PRINT_TRIES_COUNT |
118 | tries ++; | 125 | tries ++; |
119 | #endif | 126 | #endif |
120 | crypto_box_keypair(public_key, secret_key); | 127 | crypto_box_keypair(public_key, secret_key); |
121 | } while (memcmp(p, desired_bin, len) != 0); | 128 | } while (memcmp(p, desired_bin, len) != 0); |
@@ -130,7 +137,7 @@ int main(int argc, char *argv[]) | |||
130 | fprintf(stdout, "\n"); | 137 | fprintf(stdout, "\n"); |
131 | 138 | ||
132 | #ifdef PRINT_TRIES_COUNT | 139 | #ifdef PRINT_TRIES_COUNT |
133 | fprintf(stdout, "Found the key pair on %llu try.\n", tries); | 140 | fprintf(stdout, "Found the key pair on %llu try.\n", tries); |
134 | #endif | 141 | #endif |
135 | 142 | ||
136 | return 0; | 143 | return 0; |
diff --git a/other/travis/toxcore-script b/other/travis/toxcore-script index b2ee5d02..b99bbe5b 100755 --- a/other/travis/toxcore-script +++ b/other/travis/toxcore-script | |||
@@ -3,8 +3,10 @@ | |||
3 | set -e -x | 3 | set -e -x |
4 | 4 | ||
5 | # Check if toxcore.h and toxav.h match apidsl tox.in.h and toxav.in.h. | 5 | # Check if toxcore.h and toxav.h match apidsl tox.in.h and toxav.in.h. |
6 | ../apidsl/_build/apigen.native ./other/apidsl/tox.in.h | $ASTYLE --options=./other/astyle/astylerc > toxcore/tox.h | 6 | ../apidsl/_build/apigen.native other/apidsl/tox.in.h | $ASTYLE --options=other/astyle/astylerc > toxcore/tox.h |
7 | ../apidsl/_build/apigen.native ./other/apidsl/toxav.in.h | $ASTYLE --options=./other/astyle/astylerc > toxav/toxav.h | 7 | ../apidsl/_build/apigen.native other/apidsl/toxav.in.h | $ASTYLE --options=other/astyle/astylerc > toxav/toxav.h |
8 | # Check if the code is formatted according to the astyle configuration. | ||
9 | $ASTYLE --options=other/astyle/astylerc `find . -name "*.[ch]" -and -not -name "*.in.*" -and -not -wholename "*crypto_pwhash*" -and -not -wholename "./super_donators/*"` | ||
8 | git diff --exit-code | 10 | git diff --exit-code |
9 | 11 | ||
10 | # Build toxcore and run tests. | 12 | # Build toxcore and run tests. |
diff --git a/toxav/toxav.c b/toxav/toxav.c index 814c4f26..1aece0b3 100644 --- a/toxav/toxav.c +++ b/toxav/toxav.c | |||
@@ -121,11 +121,11 @@ uint32_t toxav_version_patch(void) | |||
121 | 121 | ||
122 | bool toxav_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch) | 122 | bool toxav_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch) |
123 | { | 123 | { |
124 | return (TOXAV_VERSION_MAJOR == major && /* Force the major version */ | 124 | return (TOXAV_VERSION_MAJOR == major && /* Force the major version */ |
125 | (TOXAV_VERSION_MINOR > minor || /* Current minor version must be newer than requested -- or -- */ | 125 | (TOXAV_VERSION_MINOR > minor || /* Current minor version must be newer than requested -- or -- */ |
126 | (TOXAV_VERSION_MINOR == minor && TOXAV_VERSION_PATCH >= patch) /* the patch must be the same or newer */ | 126 | (TOXAV_VERSION_MINOR == minor && TOXAV_VERSION_PATCH >= patch) /* the patch must be the same or newer */ |
127 | ) | 127 | ) |
128 | ); | 128 | ); |
129 | } | 129 | } |
130 | 130 | ||
131 | ToxAV *toxav_new(Tox *tox, TOXAV_ERR_NEW *error) | 131 | ToxAV *toxav_new(Tox *tox, TOXAV_ERR_NEW *error) |
diff --git a/toxcore/tox.c b/toxcore/tox.c index 23d0d3e4..b642db75 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -87,11 +87,11 @@ uint32_t tox_version_patch(void) | |||
87 | 87 | ||
88 | bool tox_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch) | 88 | bool tox_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch) |
89 | { | 89 | { |
90 | return (TOX_VERSION_MAJOR == major && /* Force the major version */ | 90 | return (TOX_VERSION_MAJOR == major && /* Force the major version */ |
91 | (TOX_VERSION_MINOR > minor || /* Current minor version must be newer than requested -- or -- */ | 91 | (TOX_VERSION_MINOR > minor || /* Current minor version must be newer than requested -- or -- */ |
92 | (TOX_VERSION_MINOR == minor && TOX_VERSION_PATCH >= patch) /* the patch must be the same or newer */ | 92 | (TOX_VERSION_MINOR == minor && TOX_VERSION_PATCH >= patch) /* the patch must be the same or newer */ |
93 | ) | 93 | ) |
94 | ); | 94 | ); |
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
diff --git a/toxdns/toxdns.c b/toxdns/toxdns.c index 1fbf4a00..a435eee5 100644 --- a/toxdns/toxdns.c +++ b/toxdns/toxdns.c | |||
@@ -43,7 +43,7 @@ uint8_t i = 0; \ | |||
43 | i++; \ | 43 | i++; \ |
44 | } \ | 44 | } \ |
45 | } \ | 45 | } \ |
46 | } \ | 46 | } |
47 | 47 | ||
48 | typedef struct { | 48 | typedef struct { |
49 | uint8_t temp_pk[crypto_box_PUBLICKEYBYTES]; | 49 | uint8_t temp_pk[crypto_box_PUBLICKEYBYTES]; |
diff --git a/toxencryptsave/toxencryptsave.c b/toxencryptsave/toxencryptsave.c index bbe0422f..267bd813 100644 --- a/toxencryptsave/toxencryptsave.c +++ b/toxencryptsave/toxencryptsave.c | |||
@@ -64,11 +64,11 @@ uint32_t toxes_version_patch(void) | |||
64 | 64 | ||
65 | bool toxes_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch) | 65 | bool toxes_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch) |
66 | { | 66 | { |
67 | return (TOXES_VERSION_MAJOR == major && /* Force the major version */ | 67 | return (TOXES_VERSION_MAJOR == major && /* Force the major version */ |
68 | (TOXES_VERSION_MINOR > minor || /* Current minor version must be newer than requested -- or -- */ | 68 | (TOXES_VERSION_MINOR > minor || /* Current minor version must be newer than requested -- or -- */ |
69 | (TOXES_VERSION_MINOR == minor && TOXES_VERSION_PATCH >= patch) /* the patch must be the same or newer */ | 69 | (TOXES_VERSION_MINOR == minor && TOXES_VERSION_PATCH >= patch) /* the patch must be the same or newer */ |
70 | ) | 70 | ) |
71 | ); | 71 | ); |
72 | } | 72 | } |
73 | 73 | ||
74 | /* Clients should consider alerting their users that, unlike plain data, if even one bit | 74 | /* Clients should consider alerting their users that, unlike plain data, if even one bit |