@@ -16,32 +16,36 @@ static void *proxy_routine(void *arg)
16
16
return nullptr ;
17
17
}
18
18
19
- static bool try_bootstrap (Tox * tox1 , Tox * tox2 , Tox * tox3 , Tox * tox4 )
19
+ static bool try_bootstrap (Tox * tox1 , Tox * tox2 , Tox * tox3 , Tox * tox4 , Tox * tox5 )
20
20
{
21
21
for (uint32_t i = 0 ; i < 400 ; ++ i ) {
22
22
if (tox_self_get_connection_status (tox1 ) != TOX_CONNECTION_NONE &&
23
23
tox_self_get_connection_status (tox2 ) != TOX_CONNECTION_NONE &&
24
24
tox_self_get_connection_status (tox3 ) != TOX_CONNECTION_NONE &&
25
- tox_self_get_connection_status (tox4 ) != TOX_CONNECTION_NONE ) {
26
- printf ("%d %d %d %d\n" ,
25
+ tox_self_get_connection_status (tox4 ) != TOX_CONNECTION_NONE &&
26
+ tox_self_get_connection_status (tox5 ) != TOX_CONNECTION_NONE ) {
27
+ printf ("%d %d %d %d %d\n" ,
27
28
tox_self_get_connection_status (tox1 ),
28
29
tox_self_get_connection_status (tox2 ),
29
30
tox_self_get_connection_status (tox3 ),
30
- tox_self_get_connection_status (tox4 ));
31
+ tox_self_get_connection_status (tox4 ),
32
+ tox_self_get_connection_status (tox5 ));
31
33
return true;
32
34
}
33
35
34
36
tox_iterate (tox1 , nullptr );
35
37
tox_iterate (tox2 , nullptr );
36
38
tox_iterate (tox3 , nullptr );
37
39
tox_iterate (tox4 , nullptr );
40
+ tox_iterate (tox5 , nullptr );
38
41
39
42
if (i % 10 == 0 ) {
40
- printf ("%d %d %d %d\n" ,
43
+ printf ("%d %d %d %d %d \n" ,
41
44
tox_self_get_connection_status (tox1 ),
42
45
tox_self_get_connection_status (tox2 ),
43
46
tox_self_get_connection_status (tox3 ),
44
- tox_self_get_connection_status (tox4 ));
47
+ tox_self_get_connection_status (tox4 ),
48
+ tox_self_get_connection_status (tox5 ));
45
49
}
46
50
47
51
c_sleep (tox_iteration_interval (tox1 ));
@@ -60,15 +64,16 @@ int main(int argc, char **argv)
60
64
c_sleep (100 );
61
65
}
62
66
63
- const uint16_t tcp_port = 8082 ;
64
- uint32_t index [] = { 1 , 2 , 3 , 4 };
67
+ const uint16_t tcp_port = 8083 ;
68
+ uint32_t index [] = { 1 , 2 , 3 , 4 , 5 };
65
69
66
70
struct Tox_Options * tox_options = tox_options_new (nullptr );
67
71
ck_assert (tox_options != nullptr );
68
72
69
73
// tox1 is a TCP server and has UDP enabled.
70
74
tox_options_set_udp_enabled (tox_options , true);
71
75
tox_options_set_tcp_port (tox_options , tcp_port );
76
+ tox_options_set_local_discovery_enabled (tox_options , false);
72
77
73
78
Tox * tox1 = tox_new_log (tox_options , nullptr , & index [0 ]);
74
79
ck_assert (tox1 != nullptr );
@@ -80,8 +85,10 @@ int main(int argc, char **argv)
80
85
ck_assert (dht_port != 0 );
81
86
82
87
// tox2 is a regular DHT node bootstrapping against tox1.
88
+ tox_options_default (tox_options );
83
89
tox_options_set_udp_enabled (tox_options , true);
84
90
tox_options_set_tcp_port (tox_options , 0 );
91
+ tox_options_set_local_discovery_enabled (tox_options , false);
85
92
86
93
Tox * tox2 = tox_new_log (tox_options , nullptr , & index [1 ]);
87
94
ck_assert (tox2 != nullptr );
@@ -90,36 +97,57 @@ int main(int argc, char **argv)
90
97
ck_assert (tox_bootstrap (tox2 , "127.0.0.1" , dht_port , dht_pk , nullptr ));
91
98
92
99
// tox3 has UDP disabled and connects to tox1 via an HTTP proxy
100
+ tox_options_default (tox_options );
93
101
tox_options_set_udp_enabled (tox_options , false);
94
102
tox_options_set_proxy_host (tox_options , "127.0.0.1" );
95
103
tox_options_set_proxy_port (tox_options , 8080 );
96
104
tox_options_set_proxy_type (tox_options , TOX_PROXY_TYPE_HTTP );
105
+ tox_options_set_local_discovery_enabled (tox_options , false);
97
106
98
107
Tox * tox3 = tox_new_log (tox_options , nullptr , & index [2 ]);
99
108
ck_assert (tox3 != nullptr );
100
109
101
- // tox4 has UDP disabled and connects to tox1 via a SOCKS5 proxy
110
+ // tox4 has UDP disabled and connects to tox1 via a SOCKS5 proxy with no auth
111
+ tox_options_default (tox_options );
102
112
tox_options_set_udp_enabled (tox_options , false);
103
113
tox_options_set_proxy_host (tox_options , "127.0.0.1" );
104
114
tox_options_set_proxy_port (tox_options , 8081 );
105
115
tox_options_set_proxy_type (tox_options , TOX_PROXY_TYPE_SOCKS5 );
116
+ tox_options_set_local_discovery_enabled (tox_options , false);
106
117
107
118
Tox * tox4 = tox_new_log (tox_options , nullptr , & index [3 ]);
108
119
ck_assert (tox4 != nullptr );
109
120
110
- // tox3 and tox4 bootstrap against tox1 and add it as a TCP relay
121
+ // tox5 has UDP disabled and connects to tox1 via a SOCKS5 proxy with username/password auth
122
+ tox_options_default (tox_options );
123
+ tox_options_set_udp_enabled (tox_options , false);
124
+ tox_options_set_proxy_host (tox_options , "127.0.0.1" );
125
+ tox_options_set_proxy_port (tox_options , 8082 );
126
+ tox_options_set_proxy_type (tox_options , TOX_PROXY_TYPE_SOCKS5 );
127
+ tox_options_set_proxy_socks5_username (tox_options , (const uint8_t * ) "nurupo" , strlen ("nurupo" ));
128
+ tox_options_set_proxy_socks5_password (tox_options , (const uint8_t * ) "hunter2" , strlen ("hunter2" ));
129
+ tox_options_set_local_discovery_enabled (tox_options , false);
130
+
131
+ Tox * tox5 = tox_new_log (tox_options , nullptr , & index [4 ]);
132
+ ck_assert (tox5 != nullptr );
133
+
134
+ // tox3, tox4 and tox5 bootstrap against tox1 and add it as a TCP relay
111
135
ck_assert (tox_bootstrap (tox3 , "127.0.0.1" , dht_port , dht_pk , nullptr ));
112
136
ck_assert (tox_add_tcp_relay (tox3 , "127.0.0.1" , tcp_port , dht_pk , nullptr ));
113
137
114
138
ck_assert (tox_bootstrap (tox4 , "127.0.0.1" , dht_port , dht_pk , nullptr ));
115
139
ck_assert (tox_add_tcp_relay (tox4 , "127.0.0.1" , tcp_port , dht_pk , nullptr ));
116
140
141
+ ck_assert (tox_bootstrap (tox5 , "127.0.0.1" , dht_port , dht_pk , nullptr ));
142
+ ck_assert (tox_add_tcp_relay (tox5 , "127.0.0.1" , tcp_port , dht_pk , nullptr ));
143
+
117
144
int ret = 1 ;
118
- if (try_bootstrap (tox1 , tox2 , tox3 , tox4 )) {
145
+ if (try_bootstrap (tox1 , tox2 , tox3 , tox4 , tox5 )) {
119
146
ret = 0 ;
120
147
}
121
148
122
149
tox_options_free (tox_options );
150
+ tox_kill (tox5 );
123
151
tox_kill (tox4 );
124
152
tox_kill (tox3 );
125
153
tox_kill (tox2 );
0 commit comments