summaryrefslogtreecommitdiff
path: root/toxcore
diff options
context:
space:
mode:
authorcotox <39076296+cotox@users.noreply.github.com>2018-06-26 11:45:17 +0000
committercotox <39076296+cotox@users.noreply.github.com>2018-06-26 11:45:17 +0000
commit5b14542d3b5af207170536c3e84fd80f6035cc03 (patch)
tree0b422a2389028102659f3b6cfac61f4023d3684c /toxcore
parentae7899cab8104fa3c3078a3e61ddfa58a826e39a (diff)
Make arg `host` understand clearly.
Rename args `host:port` from `address:port`. The *address* is well known as *Tox Address* in this project. Then we should reserve *addres* to it, and use *host* to express the hostname or IP address in TCP domain.
Diffstat (limited to 'toxcore')
-rw-r--r--toxcore/tox.api.h10
-rw-r--r--toxcore/tox.c12
-rw-r--r--toxcore/tox.h11
3 files changed, 16 insertions, 17 deletions
diff --git a/toxcore/tox.api.h b/toxcore/tox.api.h
index 8ed05a7e..694d7465 100644
--- a/toxcore/tox.api.h
+++ b/toxcore/tox.api.h
@@ -756,7 +756,7 @@ uint8_t[size] savedata {
756 * This function will attempt to connect to the node using UDP. You must use 756 * This function will attempt to connect to the node using UDP. You must use
757 * this function even if ${options.this.udp_enabled} was set to false. 757 * this function even if ${options.this.udp_enabled} was set to false.
758 * 758 *
759 * @param address The hostname or IP address (IPv4 or IPv6) of the node. Must be 759 * @param host The hostname or IP address (IPv4 or IPv6) of the node. Must be
760 * at most $MAX_HOSTNAME_LENGTH chars, including the NUL byte. 760 * at most $MAX_HOSTNAME_LENGTH chars, including the NUL byte.
761 * @param port The port on the host on which the bootstrap Tox instance is 761 * @param port The port on the host on which the bootstrap Tox instance is
762 * listening. 762 * listening.
@@ -764,10 +764,10 @@ uint8_t[size] savedata {
764 * ($PUBLIC_KEY_SIZE bytes). 764 * ($PUBLIC_KEY_SIZE bytes).
765 * @return true on success. 765 * @return true on success.
766 */ 766 */
767bool bootstrap(string address, uint16_t port, const uint8_t[PUBLIC_KEY_SIZE] public_key) { 767bool bootstrap(string host, uint16_t port, const uint8_t[PUBLIC_KEY_SIZE] public_key) {
768 NULL, 768 NULL,
769 /** 769 /**
770 * The address could not be resolved to an IP address, or the IP address 770 * The hostname could not be resolved to an IP address, or the IP address
771 * passed was invalid. 771 * passed was invalid.
772 */ 772 */
773 BAD_HOST, 773 BAD_HOST,
@@ -785,13 +785,13 @@ bool bootstrap(string address, uint16_t port, const uint8_t[PUBLIC_KEY_SIZE] pub
785 * the same bootstrap node, or to add TCP relays without using them as 785 * the same bootstrap node, or to add TCP relays without using them as
786 * bootstrap nodes. 786 * bootstrap nodes.
787 * 787 *
788 * @param address The hostname or IP address (IPv4 or IPv6) of the TCP relay. 788 * @param host The hostname or IP address (IPv4 or IPv6) of the TCP relay.
789 * @param port The port on the host on which the TCP relay is listening. 789 * @param port The port on the host on which the TCP relay is listening.
790 * @param public_key The long term public key of the TCP relay 790 * @param public_key The long term public key of the TCP relay
791 * ($PUBLIC_KEY_SIZE bytes). 791 * ($PUBLIC_KEY_SIZE bytes).
792 * @return true on success. 792 * @return true on success.
793 */ 793 */
794bool add_tcp_relay(string address, uint16_t port, const uint8_t[PUBLIC_KEY_SIZE] public_key) 794bool add_tcp_relay(string host, uint16_t port, const uint8_t[PUBLIC_KEY_SIZE] public_key)
795 with error for bootstrap; 795 with error for bootstrap;
796 796
797 797
diff --git a/toxcore/tox.c b/toxcore/tox.c
index d2dcd93e..f7613d4f 100644
--- a/toxcore/tox.c
+++ b/toxcore/tox.c
@@ -248,9 +248,9 @@ void tox_get_savedata(const Tox *tox, uint8_t *savedata)
248 } 248 }
249} 249}
250 250
251bool tox_bootstrap(Tox *tox, const char *address, uint16_t port, const uint8_t *public_key, TOX_ERR_BOOTSTRAP *error) 251bool tox_bootstrap(Tox *tox, const char *host, uint16_t port, const uint8_t *public_key, TOX_ERR_BOOTSTRAP *error)
252{ 252{
253 if (!address || !public_key) { 253 if (!host || !public_key) {
254 SET_ERROR_PARAMETER(error, TOX_ERR_BOOTSTRAP_NULL); 254 SET_ERROR_PARAMETER(error, TOX_ERR_BOOTSTRAP_NULL);
255 return 0; 255 return 0;
256 } 256 }
@@ -262,7 +262,7 @@ bool tox_bootstrap(Tox *tox, const char *address, uint16_t port, const uint8_t *
262 262
263 IP_Port *root; 263 IP_Port *root;
264 264
265 int32_t count = net_getipport(address, &root, TOX_SOCK_DGRAM); 265 int32_t count = net_getipport(host, &root, TOX_SOCK_DGRAM);
266 266
267 if (count == -1) { 267 if (count == -1) {
268 net_freeipport(root); 268 net_freeipport(root);
@@ -291,10 +291,10 @@ bool tox_bootstrap(Tox *tox, const char *address, uint16_t port, const uint8_t *
291 return 0; 291 return 0;
292} 292}
293 293
294bool tox_add_tcp_relay(Tox *tox, const char *address, uint16_t port, const uint8_t *public_key, 294bool tox_add_tcp_relay(Tox *tox, const char *host, uint16_t port, const uint8_t *public_key,
295 TOX_ERR_BOOTSTRAP *error) 295 TOX_ERR_BOOTSTRAP *error)
296{ 296{
297 if (!address || !public_key) { 297 if (!host || !public_key) {
298 SET_ERROR_PARAMETER(error, TOX_ERR_BOOTSTRAP_NULL); 298 SET_ERROR_PARAMETER(error, TOX_ERR_BOOTSTRAP_NULL);
299 return 0; 299 return 0;
300 } 300 }
@@ -306,7 +306,7 @@ bool tox_add_tcp_relay(Tox *tox, const char *address, uint16_t port, const uint8
306 306
307 IP_Port *root; 307 IP_Port *root;
308 308
309 int32_t count = net_getipport(address, &root, TOX_SOCK_STREAM); 309 int32_t count = net_getipport(host, &root, TOX_SOCK_STREAM);
310 310
311 if (count == -1) { 311 if (count == -1) {
312 net_freeipport(root); 312 net_freeipport(root);
diff --git a/toxcore/tox.h b/toxcore/tox.h
index 468113d9..f8cb5e5a 100644
--- a/toxcore/tox.h
+++ b/toxcore/tox.h
@@ -905,7 +905,7 @@ typedef enum TOX_ERR_BOOTSTRAP {
905 TOX_ERR_BOOTSTRAP_NULL, 905 TOX_ERR_BOOTSTRAP_NULL,
906 906
907 /** 907 /**
908 * The address could not be resolved to an IP address, or the IP address 908 * The hostname could not be resolved to an IP address, or the IP address
909 * passed was invalid. 909 * passed was invalid.
910 */ 910 */
911 TOX_ERR_BOOTSTRAP_BAD_HOST, 911 TOX_ERR_BOOTSTRAP_BAD_HOST,
@@ -925,7 +925,7 @@ typedef enum TOX_ERR_BOOTSTRAP {
925 * This function will attempt to connect to the node using UDP. You must use 925 * This function will attempt to connect to the node using UDP. You must use
926 * this function even if Tox_Options.udp_enabled was set to false. 926 * this function even if Tox_Options.udp_enabled was set to false.
927 * 927 *
928 * @param address The hostname or IP address (IPv4 or IPv6) of the node. Must be 928 * @param host The hostname or IP address (IPv4 or IPv6) of the node. Must be
929 * at most TOX_MAX_HOSTNAME_LENGTH chars, including the NUL byte. 929 * at most TOX_MAX_HOSTNAME_LENGTH chars, including the NUL byte.
930 * @param port The port on the host on which the bootstrap Tox instance is 930 * @param port The port on the host on which the bootstrap Tox instance is
931 * listening. 931 * listening.
@@ -933,7 +933,7 @@ typedef enum TOX_ERR_BOOTSTRAP {
933 * (TOX_PUBLIC_KEY_SIZE bytes). 933 * (TOX_PUBLIC_KEY_SIZE bytes).
934 * @return true on success. 934 * @return true on success.
935 */ 935 */
936bool tox_bootstrap(Tox *tox, const char *address, uint16_t port, const uint8_t *public_key, TOX_ERR_BOOTSTRAP *error); 936bool tox_bootstrap(Tox *tox, const char *host, uint16_t port, const uint8_t *public_key, TOX_ERR_BOOTSTRAP *error);
937 937
938/** 938/**
939 * Adds additional host:port pair as TCP relay. 939 * Adds additional host:port pair as TCP relay.
@@ -942,14 +942,13 @@ bool tox_bootstrap(Tox *tox, const char *address, uint16_t port, const uint8_t *
942 * the same bootstrap node, or to add TCP relays without using them as 942 * the same bootstrap node, or to add TCP relays without using them as
943 * bootstrap nodes. 943 * bootstrap nodes.
944 * 944 *
945 * @param address The hostname or IP address (IPv4 or IPv6) of the TCP relay. 945 * @param host The hostname or IP address (IPv4 or IPv6) of the TCP relay.
946 * @param port The port on the host on which the TCP relay is listening. 946 * @param port The port on the host on which the TCP relay is listening.
947 * @param public_key The long term public key of the TCP relay 947 * @param public_key The long term public key of the TCP relay
948 * (TOX_PUBLIC_KEY_SIZE bytes). 948 * (TOX_PUBLIC_KEY_SIZE bytes).
949 * @return true on success. 949 * @return true on success.
950 */ 950 */
951bool tox_add_tcp_relay(Tox *tox, const char *address, uint16_t port, const uint8_t *public_key, 951bool tox_add_tcp_relay(Tox *tox, const char *host, uint16_t port, const uint8_t *public_key, TOX_ERR_BOOTSTRAP *error);
952 TOX_ERR_BOOTSTRAP *error);
953 952
954/** 953/**
955 * Protocols that can be used to connect to the network or friends. 954 * Protocols that can be used to connect to the network or friends.