mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Merge pull request #760 from nurupo/server-to-node
Renamed dht server to dht node
This commit is contained in:
commit
f219fb4ac1
10
.travis.yml
10
.travis.yml
|
@ -15,6 +15,14 @@ before_script:
|
|||
- cd ..
|
||||
#installing yasm, needed for compiling vpx
|
||||
- sudo apt-get install yasm > /dev/null
|
||||
#installing libconfig, needed for DHT_bootstrap_daemon
|
||||
- wget http://www.hyperrealm.com/libconfig/libconfig-1.4.9.tar.gz > /dev/null
|
||||
- tar -xvzf libconfig-1.4.9.tar.gz > /dev/null
|
||||
- cd libconfig-1.4.9
|
||||
- ./configure > /dev/null
|
||||
- make -j3 > /dev/null
|
||||
- sudo make install > /dev/null
|
||||
- cd ..
|
||||
#installing libopus, needed for audio encoding/decoding
|
||||
- wget http://downloads.xiph.org/releases/opus/opus-1.0.3.tar.gz > /dev/null
|
||||
- tar xzf opus-1.0.3.tar.gz > /dev/null
|
||||
|
@ -37,7 +45,7 @@ before_script:
|
|||
|
||||
script:
|
||||
- autoreconf -i
|
||||
- CFLAGS=-Ofast ./configure
|
||||
- CFLAGS=-Ofast ./configure --enable-daemon --enable-ntox
|
||||
- make -j3
|
||||
- make check
|
||||
- make dist
|
||||
|
|
|
@ -49,8 +49,6 @@ On FreeBSD 10+:
|
|||
pkg install automake autoconf
|
||||
```
|
||||
|
||||
Note that `libconfig-dev` should be >= 1.4.
|
||||
|
||||
You should get and install [libsodium](https://github.com/jedisct1/libsodium):
|
||||
```bash
|
||||
git clone git://github.com/jedisct1/libsodium.git
|
||||
|
@ -112,7 +110,7 @@ brew install --HEAD libtoxcore
|
|||
|
||||
To do it manually:
|
||||
```
|
||||
brew install libtool automake autoconf libconfig libsodium check
|
||||
brew install libtool automake autoconf libsodium check
|
||||
```
|
||||
Then clone this repo and generate makefile:
|
||||
```bash
|
||||
|
@ -234,7 +232,7 @@ While [Toxic](https://github.com/tox/toxic) is no longer in core, a list of Tox
|
|||
- --disable-av disable A/V support (default: auto) see: [libtoxav](#libtoxav)
|
||||
- --enable-phone build phone (default: no) see: [Test phone](#phone)
|
||||
- --enable-ntox build nTox client (default: no) see: [nTox](#ntox)
|
||||
- --enable-daemon build DHT bootstrap daemon (default: no) see: [Bootstrap daemon](#bootstrapd)
|
||||
- --enable-daemon build DHT bootstrap daemon (default=no) see: [Bootstrap daemon](#bootstrapd)
|
||||
- --enable-shared[=PKGS] build shared libraries [default=yes]
|
||||
- --enable-static[=PKGS] build static libraries [default=yes]
|
||||
|
||||
|
@ -335,7 +333,7 @@ Daemon is disabled by default. You can enable it by adding --enable-daemon argum
|
|||
```bash
|
||||
./configure --enable-daemon
|
||||
```
|
||||
There is one dependency required for bootstrap daemon: libconfig.
|
||||
There is one dependency required for bootstrap daemon: `libconfig-dev` >= 1.4.
|
||||
|
||||
Install on fedora:
|
||||
```bash
|
||||
|
@ -354,6 +352,7 @@ brew install libconfig
|
|||
OS X non-homebrew:
|
||||
Grab the following [package] (http://www.hyperrealm.com/libconfig/), uncompress and install
|
||||
|
||||
See this [readme](other\bootstrap_daemon\README.md) on how to set up the bootstrap daemon.
|
||||
|
||||
|
||||
<a name="ntox" />
|
||||
|
|
|
@ -8,5 +8,5 @@ include ../toxcore/Makefile.inc
|
|||
include ../toxav/Makefile.inc
|
||||
include ../other/Makefile.inc
|
||||
include ../testing/Makefile.inc
|
||||
include ../other/bootstrap_serverdaemon/Makefile.inc
|
||||
include ../other/bootstrap_daemon/Makefile.inc
|
||||
include ../auto_tests/Makefile.inc
|
||||
|
|
|
@ -12,9 +12,9 @@ can use Tox regardless of the quality of their internet connection.
|
|||
|
||||
How it's probably going to work:
|
||||
1. Alice, a Tox client on a TCP only network generates a temporary public key
|
||||
and connects to a bootstrap server.
|
||||
and connects to a bootstrap node.
|
||||
|
||||
2. Using the bootstrap server she find and connects to a couple (exact number
|
||||
2. Using the bootstrap node she find and connects to a couple (exact number
|
||||
to be determined later) number of random nodes that have TCP relay support.
|
||||
|
||||
3. She uses the onion through the TCP relay connections to send friend requests
|
||||
|
|
|
@ -7,7 +7,7 @@ But:
|
|||
Vastly simplified packet format and encryption.
|
||||
|
||||
Boostrapping:
|
||||
The first time you install the client we bootstrap it with a node on our servers.(bandwidth should not be a problem as the client only needs to be sent one reply.)
|
||||
The first time you install the client we bootstrap it with a node. (bandwidth should not be a problem as the client only needs to be sent one reply.)
|
||||
|
||||
|
||||
Basics
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* DHT boostrap
|
||||
*
|
||||
* A simple DHT boostrap server for tox.
|
||||
* A simple DHT boostrap node for tox.
|
||||
*
|
||||
* Copyright (C) 2013 Tox project All Rights Reserved.
|
||||
*
|
||||
|
@ -33,8 +33,8 @@
|
|||
|
||||
#include "../testing/misc_tools.c"
|
||||
|
||||
#ifdef DHT_SERVER_EXTRA_PACKETS
|
||||
#include "./bootstrap_server_packets.c"
|
||||
#ifdef DHT_NODE_EXTRA_PACKETS
|
||||
#include "./bootstrap_node_packets.c"
|
||||
|
||||
#define DHT_VERSION_NUMBER 1
|
||||
#define DHT_MOTD "This is a test motd"
|
||||
|
@ -111,7 +111,7 @@ int main(int argc, char *argv[])
|
|||
Onion *onion = new_onion(dht);
|
||||
Onion_Announce *onion_a = new_onion_announce(dht);
|
||||
|
||||
#ifdef DHT_SERVER_EXTRA_PACKETS
|
||||
#ifdef DHT_NODE_EXTRA_PACKETS
|
||||
bootstrap_set_callbacks(dht->net, DHT_VERSION_NUMBER, DHT_MOTD, sizeof(DHT_MOTD));
|
||||
#endif
|
||||
|
||||
|
@ -123,7 +123,7 @@ int main(int argc, char *argv[])
|
|||
perror("Initialization");
|
||||
|
||||
manage_keys(dht);
|
||||
/* We want our DHT public key to be the same as our internal one since this is a bootstrap server */
|
||||
/* We want our DHT public key to be the same as our internal one since this is a bootstrap node */
|
||||
memcpy(dht->self_public_key, dht->c->self_public_key, crypto_box_PUBLICKEYBYTES);
|
||||
memcpy(dht->self_secret_key, dht->c->self_secret_key, crypto_box_SECRETKEYBYTES);
|
||||
printf("Public key: ");
|
||||
|
@ -166,7 +166,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
while (1) {
|
||||
if (is_waiting_for_dht_connection && DHT_isconnected(dht)) {
|
||||
printf("Connected to other bootstrap server successfully.\n");
|
||||
printf("Connected to other bootstrap node successfully.\n");
|
||||
is_waiting_for_dht_connection = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
As maintaining 2 seperate lists of the same information seemed redundant, this list has been phased out.
|
||||
|
||||
For a current DHT server list please visit http://wiki.tox.im/Servers
|
||||
For a current DHT node list please visit http://wiki.tox.im/nodes
|
|
@ -15,5 +15,5 @@ DHT_bootstrap_LDADD = $(LIBSODIUM_LDFLAGS) \
|
|||
$(NACL_LIBS) \
|
||||
$(WINSOCK2_LIBS)
|
||||
|
||||
EXTRA_DIST += $(top_srcdir)/other/DHTservers \
|
||||
EXTRA_DIST += $(top_srcdir)/other/DHTnodes \
|
||||
$(top_srcdir)/other/tox.png
|
||||
|
|
|
@ -3,10 +3,10 @@ if BUILD_DHT_BOOTSTRAP_DAEMON
|
|||
noinst_PROGRAMS += tox_bootstrap_daemon
|
||||
|
||||
tox_bootstrap_daemon_SOURCES = \
|
||||
../other/bootstrap_serverdaemon/tox_bootstrap_daemon.c
|
||||
../other/bootstrap_daemon/tox_bootstrap_daemon.c
|
||||
|
||||
tox_bootstrap_daemon_CFLAGS = \
|
||||
-I$(top_srcdir)/other/bootstrap_serverdaemon \
|
||||
-I$(top_srcdir)/other/bootstrap_daemon \
|
||||
$(LIBSODIUM_CFLAGS) \
|
||||
$(NACL_CFLAGS) \
|
||||
$(LIBCONFIG_CFLAGS)
|
||||
|
@ -22,6 +22,6 @@ tox_bootstrap_daemon_LDADD = \
|
|||
endif
|
||||
|
||||
EXTRA_DIST += \
|
||||
$(top_srcdir)/other/bootstrap_serverdaemon/conf \
|
||||
$(top_srcdir)/other/bootstrap_serverdaemon/tox_bootstrap_daemon.sh
|
||||
$(top_srcdir)/other/bootstrap_daemon/conf \
|
||||
$(top_srcdir)/other/bootstrap_daemon/tox_bootstrap_daemon.sh
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
// ProjectTox dht bootstrap server daemon configuration file.
|
||||
// ProjectTox dht bootstrap node daemon configuration file.
|
||||
|
||||
// Listening port.
|
||||
port = 33445
|
||||
|
@ -20,20 +20,21 @@ enable_ipv6 = false
|
|||
// Automatically bootstrap with nodes on local area network.
|
||||
enable_lan_discovery = true
|
||||
|
||||
// Any number of servers the daemon will bootstrap itself from.
|
||||
// Remember to replace the provided example with your own server list.
|
||||
// You may leave the list empty or remove "bootstrap_servers" complitely,
|
||||
// Any number of nodes the daemon will bootstrap itself from.
|
||||
// Remember to replace the provided example with your own node list.
|
||||
// There is a maintained list of bootstrap nodes on Tox's wiki, if you need it.
|
||||
// You may leave the list empty or remove "bootstrap_nodes" complitely,
|
||||
// in both cases this will be interpreted as if you don't want to bootstrap
|
||||
// from anyone.
|
||||
bootstrap_servers = (
|
||||
{ // Server 1
|
||||
bootstrap_nodes = (
|
||||
{ // Node 1
|
||||
// Any ipv4 or ipv6, depending if `enable_ipv6` is set or not, and also
|
||||
// any US-ASCII domain name.
|
||||
address = "198.46.136.167"
|
||||
port = 33445
|
||||
public_key = "728925473812C7AAC482BE7250BCCAD0B8CB9F737BF3D42ABD34459C1768F854"
|
||||
},
|
||||
{ // Server 2
|
||||
{ // Node 2
|
||||
address = "example.org"
|
||||
port = 33445
|
||||
public_key = "8CD5A9BF0A6CE358BA36F7A653F99FA6B258FF756E490F52C1F98CC420F78858"
|
|
@ -1,6 +1,6 @@
|
|||
/* tox_bootstrap_daemon.c
|
||||
*
|
||||
* Tox DHT bootstrap server daemon.
|
||||
* Tox DHT bootstrap node daemon.
|
||||
*
|
||||
* Copyright (C) 2014 Tox project All Rights Reserved.
|
||||
*
|
||||
|
@ -92,7 +92,7 @@ int manage_keys(DHT *dht, char *keys_file_path)
|
|||
|
||||
fclose(keys_file);
|
||||
|
||||
// We want our DHT public key to be the same as our internal one since this is a bootstrap server
|
||||
// We want our DHT public key to be the same as our internal one since this is a bootstrap node
|
||||
memcpy(dht->self_public_key, dht->c->self_public_key, crypto_box_PUBLICKEYBYTES);
|
||||
memcpy(dht->self_secret_key, dht->c->self_secret_key, crypto_box_SECRETKEYBYTES);
|
||||
|
||||
|
@ -184,14 +184,14 @@ int get_general_config(char *cfg_file_path, char **pid_file_path, char **keys_fi
|
|||
return 1;
|
||||
}
|
||||
|
||||
// Bootstraps servers listed in the config file
|
||||
// Bootstraps nodes listed in the config file
|
||||
//
|
||||
// returns 1 on success, some or no bootstrap servers were added
|
||||
// returns 1 on success, some or no bootstrap nodes were added
|
||||
// 0 on failure, a error accured while parsing config file
|
||||
|
||||
int bootstrap_from_config(char *cfg_file_path, DHT *dht, int enable_ipv6)
|
||||
{
|
||||
const char *NAME_BOOTSTRAP_SERVERS = "bootstrap_servers";
|
||||
const char *NAME_BOOTSTRAP_NODES = "bootstrap_nodes";
|
||||
|
||||
const char *NAME_PUBLIC_KEY = "public_key";
|
||||
const char *NAME_PORT = "port";
|
||||
|
@ -207,16 +207,16 @@ int bootstrap_from_config(char *cfg_file_path, DHT *dht, int enable_ipv6)
|
|||
return 0;
|
||||
}
|
||||
|
||||
config_setting_t *server_list = config_lookup(&cfg, NAME_BOOTSTRAP_SERVERS);
|
||||
config_setting_t *node_list = config_lookup(&cfg, NAME_BOOTSTRAP_NODES);
|
||||
|
||||
if (server_list == NULL) {
|
||||
syslog(LOG_WARNING, "No '%s' setting in the configuration file. Skipping bootstrapping.\n", NAME_BOOTSTRAP_SERVERS);
|
||||
if (node_list == NULL) {
|
||||
syslog(LOG_WARNING, "No '%s' setting in the configuration file. Skipping bootstrapping.\n", NAME_BOOTSTRAP_NODES);
|
||||
config_destroy(&cfg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (config_setting_length(server_list) == 0) {
|
||||
syslog(LOG_WARNING, "No bootstrap servers found. Skipping bootstrapping.\n");
|
||||
if (config_setting_length(node_list) == 0) {
|
||||
syslog(LOG_WARNING, "No bootstrap nodes found. Skipping bootstrapping.\n");
|
||||
config_destroy(&cfg);
|
||||
return 1;
|
||||
}
|
||||
|
@ -225,45 +225,45 @@ int bootstrap_from_config(char *cfg_file_path, DHT *dht, int enable_ipv6)
|
|||
const char *bs_address;
|
||||
const char *bs_public_key;
|
||||
|
||||
config_setting_t *server;
|
||||
config_setting_t *node;
|
||||
|
||||
int i = 0;
|
||||
|
||||
while (config_setting_length(server_list)) {
|
||||
while (config_setting_length(node_list)) {
|
||||
|
||||
server = config_setting_get_elem(server_list, 0);
|
||||
node = config_setting_get_elem(node_list, 0);
|
||||
|
||||
if (server == NULL) {
|
||||
if (node == NULL) {
|
||||
config_destroy(&cfg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Check that all settings are present
|
||||
if (config_setting_lookup_string(server, NAME_PUBLIC_KEY, &bs_public_key) == CONFIG_FALSE) {
|
||||
syslog(LOG_WARNING, "Bootstrap server #%d: Couldn't find '%s' setting. Skipping the server.\n", i, NAME_PUBLIC_KEY);
|
||||
if (config_setting_lookup_string(node, NAME_PUBLIC_KEY, &bs_public_key) == CONFIG_FALSE) {
|
||||
syslog(LOG_WARNING, "Bootstrap node #%d: Couldn't find '%s' setting. Skipping the node.\n", i, NAME_PUBLIC_KEY);
|
||||
goto next;
|
||||
}
|
||||
|
||||
if (config_setting_lookup_int(server, NAME_PORT, &bs_port) == CONFIG_FALSE) {
|
||||
syslog(LOG_WARNING, "Bootstrap server #%d: Couldn't find '%s' setting. Skipping the server.\n", i, NAME_PORT);
|
||||
if (config_setting_lookup_int(node, NAME_PORT, &bs_port) == CONFIG_FALSE) {
|
||||
syslog(LOG_WARNING, "Bootstrap node #%d: Couldn't find '%s' setting. Skipping the node.\n", i, NAME_PORT);
|
||||
goto next;
|
||||
}
|
||||
|
||||
if (config_setting_lookup_string(server, NAME_ADDRESS, &bs_address) == CONFIG_FALSE) {
|
||||
syslog(LOG_WARNING, "Bootstrap server #%d: Couldn't find '%s' setting. Skipping the server.\n", i, NAME_ADDRESS);
|
||||
if (config_setting_lookup_string(node, NAME_ADDRESS, &bs_address) == CONFIG_FALSE) {
|
||||
syslog(LOG_WARNING, "Bootstrap node #%d: Couldn't find '%s' setting. Skipping the node.\n", i, NAME_ADDRESS);
|
||||
goto next;
|
||||
}
|
||||
|
||||
// Process settings
|
||||
if (strlen(bs_public_key) != 64) {
|
||||
syslog(LOG_WARNING, "Bootstrap server #%d: Invalid '%s': %s. Skipping the server.\n", i, NAME_PUBLIC_KEY,
|
||||
syslog(LOG_WARNING, "Bootstrap node #%d: Invalid '%s': %s. Skipping the node.\n", i, NAME_PUBLIC_KEY,
|
||||
bs_public_key);
|
||||
goto next;
|
||||
}
|
||||
|
||||
// not (1 <= port <= 65535)
|
||||
if (bs_port < 1 || bs_port > 65535) {
|
||||
syslog(LOG_WARNING, "Bootstrap server #%d: Invalid '%s': %d. Skipping the server.\n", i, NAME_PORT, bs_port);
|
||||
syslog(LOG_WARNING, "Bootstrap node #%d: Invalid '%s': %d. Skipping the node.\n", i, NAME_PORT, bs_port);
|
||||
goto next;
|
||||
}
|
||||
|
||||
|
@ -273,17 +273,17 @@ int bootstrap_from_config(char *cfg_file_path, DHT *dht, int enable_ipv6)
|
|||
free(bs_public_key_bin);
|
||||
|
||||
if (!address_resolved) {
|
||||
syslog(LOG_WARNING, "Bootstrap server #%d: Invalid '%s': %s. Skipping the server.\n", i, NAME_ADDRESS, bs_address);
|
||||
syslog(LOG_WARNING, "Bootstrap node #%d: Invalid '%s': %s. Skipping the node.\n", i, NAME_ADDRESS, bs_address);
|
||||
goto next;
|
||||
}
|
||||
|
||||
syslog(LOG_DEBUG, "Successfully added bootstrap server #%d: %s:%d %s\n", i, bs_address, bs_port, bs_public_key);
|
||||
syslog(LOG_DEBUG, "Successfully added bootstrap node #%d: %s:%d %s\n", i, bs_address, bs_port, bs_public_key);
|
||||
|
||||
next:
|
||||
// config_setting_lookup_string() allocates string inside and doesn't allow us to free it
|
||||
// so in order to reuse `bs_public_key` and `bs_address` we have to remove the element
|
||||
// which will cause libconfig to free allocated strings
|
||||
config_setting_remove_elem(server_list, 0);
|
||||
config_setting_remove_elem(node_list, 0);
|
||||
i++;
|
||||
}
|
||||
|
||||
|
@ -378,9 +378,9 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
if (bootstrap_from_config(cfg_file_path, dht, enable_ipv6)) {
|
||||
syslog(LOG_DEBUG, "List of bootstrap servers read successfully\n");
|
||||
syslog(LOG_DEBUG, "List of bootstrap nodes read successfully\n");
|
||||
} else {
|
||||
syslog(LOG_ERR, "Couldn't read list of bootstrap servers in %s. Exiting.\n", cfg_file_path);
|
||||
syslog(LOG_ERR, "Couldn't read list of bootstrap nodes in %s. Exiting.\n", cfg_file_path);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -449,7 +449,7 @@ int main(int argc, char *argv[])
|
|||
networking_poll(dht->net);
|
||||
|
||||
if (waiting_for_dht_connection && DHT_isconnected(dht)) {
|
||||
syslog(LOG_DEBUG, "Connected to other bootstrap server successfully.\n");
|
||||
syslog(LOG_DEBUG, "Connected to other bootstrap node successfully.\n");
|
||||
waiting_for_dht_connection = 0;
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
/* bootstrap_server_packets.c
|
||||
/* bootstrap_node_packets.c
|
||||
*
|
||||
* Special bootstrap server only packets.
|
||||
* Special bootstrap node only packets.
|
||||
*
|
||||
* Include it in your bootstrap server and use: bootstrap_set_callbacks() to enable.
|
||||
* Include it in your bootstrap node and use: bootstrap_set_callbacks() to enable.
|
||||
*
|
||||
* Copyright (C) 2013 Tox project All Rights Reserved.
|
||||
*
|
|
@ -995,7 +995,7 @@ void print_help(char *prog_name)
|
|||
|
||||
puts("Options: (order IS relevant)");
|
||||
puts(" --ipv4 / --ipv6 [Optional] Support IPv4 only or IPv4 & IPv6.");
|
||||
puts(" IP PORT KEY [REQUIRED] A server to connect to (IP/Port) and its key.");
|
||||
puts(" IP PORT KEY [REQUIRED] A node to connect to (IP/Port) and its key.");
|
||||
puts(" -f keyfile [Optional] Specify a keyfile to read from and write to.");
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ typedef int sock_t;
|
|||
#define NET_PACKET_ONION_RECV_2 141
|
||||
#define NET_PACKET_ONION_RECV_1 142
|
||||
|
||||
/* Only used for bootstrap servers */
|
||||
/* Only used for bootstrap nodes */
|
||||
#define BOOTSTRAP_INFO_PACKET_ID 240
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user