summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Biro <nurupo.contributions@gmail.com>2014-05-18 19:31:50 -0400
committerMaxim Biro <nurupo.contributions@gmail.com>2014-05-18 19:59:01 -0400
commitfe1694fa6963ca0eceb898e4a07c60c123f23184 (patch)
tree74cb3ab2e0a843b14f9ac411aa4da6ca1bc387af
parent261a70353ff316cc993c23faf07cb0f60e2e5819 (diff)
Added default ports to the .c file, included 33445 port
-rw-r--r--other/bootstrap_daemon/conf4
-rw-r--r--other/bootstrap_daemon/tox_bootstrap_daemon.c45
2 files changed, 39 insertions, 10 deletions
diff --git a/other/bootstrap_daemon/conf b/other/bootstrap_daemon/conf
index bbdf7652..23580d9d 100644
--- a/other/bootstrap_daemon/conf
+++ b/other/bootstrap_daemon/conf
@@ -22,9 +22,9 @@ enable_lan_discovery = true
22 22
23enable_tcp_relay = true 23enable_tcp_relay = true
24 24
25// Tox uses 443 and 3389 ports by default, so it's highly recommended to keep 25// Tox uses 443, 3389 and 33445 ports by default, so it's highly recommended to keep
26// them. 26// them.
27tcp_relay_ports = [443, 3389] 27tcp_relay_ports = [443, 3389, 33445]
28 28
29// It's planned to use message of the day as a convenient method of checking 29// It's planned to use message of the day as a convenient method of checking
30// whether a node is up or not, though there are other methods of doing that. 30// whether a node is up or not, though there are other methods of doing that.
diff --git a/other/bootstrap_daemon/tox_bootstrap_daemon.c b/other/bootstrap_daemon/tox_bootstrap_daemon.c
index afe2b2ac..66271288 100644
--- a/other/bootstrap_daemon/tox_bootstrap_daemon.c
+++ b/other/bootstrap_daemon/tox_bootstrap_daemon.c
@@ -58,14 +58,16 @@
58#define SLEEP_TIME_MILLISECONDS 30 58#define SLEEP_TIME_MILLISECONDS 30
59#define sleep usleep(1000*SLEEP_TIME_MILLISECONDS) 59#define sleep usleep(1000*SLEEP_TIME_MILLISECONDS)
60 60
61#define DEFAULT_PID_FILE_PATH ".tox_bootstrap_daemon.pid" 61#define DEFAULT_PID_FILE_PATH ".tox_bootstrap_daemon.pid"
62#define DEFAULT_KEYS_FILE_PATH ".tox_bootstrap_daemon.keys" 62#define DEFAULT_KEYS_FILE_PATH ".tox_bootstrap_daemon.keys"
63#define DEFAULT_PORT 33445 63#define DEFAULT_PORT 33445
64#define DEFAULT_ENABLE_IPV6 0 // 1 - true, 0 - false 64#define DEFAULT_ENABLE_IPV6 0 // 1 - true, 0 - false
65#define DEFAULT_ENABLE_LAN_DISCOVERY 1 // 1 - true, 0 - false 65#define DEFAULT_ENABLE_LAN_DISCOVERY 1 // 1 - true, 0 - false
66#define DEFAULT_ENABLE_TCP_RELAY 1 // 1 - true, 0 - false 66#define DEFAULT_ENABLE_TCP_RELAY 1 // 1 - true, 0 - false
67#define DEFAULT_ENABLE_MOTD 1 // 1 - true, 0 - false 67#define DEFAULT_TCP_RELAY_PORTS 443, 3389, 33445 // comma-separated list of ports. make sure to adjust DEFAULT_TCP_RELAY_PORTS_COUNT accordingly
68#define DEFAULT_MOTD DAEMON_NAME 68#define DEFAULT_TCP_RELAY_PORTS_COUNT 3
69#define DEFAULT_ENABLE_MOTD 1 // 1 - true, 0 - false
70#define DEFAULT_MOTD DAEMON_NAME
69 71
70#define MIN_ALLOWED_PORT 1 72#define MIN_ALLOWED_PORT 1
71#define MAX_ALLOWED_PORT 65535 73#define MAX_ALLOWED_PORT 65535
@@ -129,6 +131,33 @@ void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_ports, int
129 131
130 if (ports_array == NULL) { 132 if (ports_array == NULL) {
131 syslog(LOG_WARNING, "No '%s' setting in the configuration file.\n", NAME_TCP_RELAY_PORTS); 133 syslog(LOG_WARNING, "No '%s' setting in the configuration file.\n", NAME_TCP_RELAY_PORTS);
134 syslog(LOG_WARNING, "Using default '%s':\n", NAME_TCP_RELAY_PORTS);
135
136 uint16_t default_ports[DEFAULT_TCP_RELAY_PORTS_COUNT] = {DEFAULT_TCP_RELAY_PORTS};
137
138 int i;
139
140 for (i = 0; i < DEFAULT_TCP_RELAY_PORTS_COUNT; i ++) {
141 syslog(LOG_WARNING, "Port #%d: %u\n", i, default_ports[i]);
142 }
143
144 // similar procedure to the one of reading config file below
145 *tcp_relay_ports = malloc(DEFAULT_TCP_RELAY_PORTS_COUNT * sizeof(uint16_t));
146
147 for (i = 0; i < DEFAULT_TCP_RELAY_PORTS_COUNT; i ++) {
148
149 (*tcp_relay_ports)[*tcp_relay_port_count] = default_ports[i];
150 if ((*tcp_relay_ports)[*tcp_relay_port_count] < MIN_ALLOWED_PORT || (*tcp_relay_ports)[*tcp_relay_port_count] > MAX_ALLOWED_PORT) {
151 syslog(LOG_WARNING, "Port #%d: Invalid port: %u, should be in [%d, %d]. Skipping.\n", i, (*tcp_relay_ports)[*tcp_relay_port_count], MIN_ALLOWED_PORT, MAX_ALLOWED_PORT);
152 continue;
153 }
154
155 (*tcp_relay_port_count) ++;
156 }
157
158 // the loop above skips invalid ports, so we adjust the allocated memory size
159 *tcp_relay_ports = realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t));
160
132 return; 161 return;
133 } 162 }
134 163