File README.md changed (mode: 100644) (index cd38142..6007e75) |
... |
... |
Client can be ran as a regular non-root user, [unless A < 1024](https://www.linu |
62 |
62 |
|
|
63 |
63 |
## Security / threat model |
## Security / threat model |
64 |
64 |
|
|
65 |
|
**TUNTOX IS NOT SECURE WITHOUT THE -s SWITCH.** Supply *-s yourpassword* both on the server and the client, and you will be fine. This switch is introduced in 0.0.4, codename "Mr. Lahey's Got My Porno Tape!". |
|
|
65 |
|
**TUNTOX IS NOT SECURE WITHOUT THE -s SWITCH.** Supply *-s yourpassword* both on the server and the client, and you will be fine. This switch is introduced in 0.0.4, codename "Mr. Lahey's Got My Porno Tape!". Even better, run `TUNTOX_SHARED_SECRET=yourpassword tuntox ...` on both sides. |
66 |
66 |
|
|
67 |
67 |
The Tuntox server generates a new Tox ID on every startup, or saves its private key in a file. Anyone who wants to connect to this server needs its Tox ID, which consists of the publicly-known pubkey and a secret 32-bit "antispam" value. Then, the client sends a shared secret which is then compared to the secred supplied on server's command line. If they don't match, friend request is left unanswered. |
The Tuntox server generates a new Tox ID on every startup, or saves its private key in a file. Anyone who wants to connect to this server needs its Tox ID, which consists of the publicly-known pubkey and a secret 32-bit "antispam" value. Then, the client sends a shared secret which is then compared to the secred supplied on server's command line. If they don't match, friend request is left unanswered. |
68 |
68 |
|
|
File client.c changed (mode: 100644) (index 0634702..381087c) |
... |
... |
int handle_pong_frame(protocol_frame *rcvd_frame) |
37 |
37 |
|
|
38 |
38 |
if(ping_mode) |
if(ping_mode) |
39 |
39 |
{ |
{ |
40 |
|
// state = CLIENT_STATE_PONG_RECEIVED; |
|
41 |
40 |
state = CLIENT_STATE_SEND_PING; |
state = CLIENT_STATE_SEND_PING; |
42 |
41 |
} |
} |
43 |
42 |
return 0; |
return 0; |
|
... |
... |
int handle_server_tcp_frame(protocol_frame *rcvd_frame) |
198 |
197 |
|
|
199 |
198 |
if(sent_bytes < 0) |
if(sent_bytes < 0) |
200 |
199 |
{ |
{ |
201 |
|
char data[PROTOCOL_BUFFER_OFFSET]; |
|
|
200 |
|
uint8_t data[PROTOCOL_BUFFER_OFFSET]; |
202 |
201 |
protocol_frame frame_st, *frame; |
protocol_frame frame_st, *frame; |
203 |
202 |
|
|
204 |
203 |
log_printf(L_INFO, "Could not write to socket %d: %s\n", write_sockfd, strerror(errno)); |
log_printf(L_INFO, "Could not write to socket %d: %s\n", write_sockfd, strerror(errno)); |
|
... |
... |
int handle_server_tcp_frame(protocol_frame *rcvd_frame) |
231 |
230 |
int handle_server_tcp_fin_frame(protocol_frame *rcvd_frame) |
int handle_server_tcp_fin_frame(protocol_frame *rcvd_frame) |
232 |
231 |
{ |
{ |
233 |
232 |
tunnel *tun=NULL; |
tunnel *tun=NULL; |
234 |
|
int offset = 0; |
|
235 |
233 |
int connid = rcvd_frame->connid; |
int connid = rcvd_frame->connid; |
236 |
234 |
|
|
237 |
235 |
HASH_FIND_INT(by_id, &connid, tun); |
HASH_FIND_INT(by_id, &connid, tun); |
|
... |
... |
int handle_server_tcp_fin_frame(protocol_frame *rcvd_frame) |
258 |
256 |
} |
} |
259 |
257 |
|
|
260 |
258 |
/* Main loop for the client */ |
/* Main loop for the client */ |
261 |
|
int do_client_loop(char *tox_id_str) |
|
|
259 |
|
int do_client_loop(unsigned char *tox_id_str) |
262 |
260 |
{ |
{ |
263 |
261 |
unsigned char tox_packet_buf[PROTOCOL_MAX_PACKET_SIZE]; |
unsigned char tox_packet_buf[PROTOCOL_MAX_PACKET_SIZE]; |
264 |
262 |
unsigned char tox_id[TOX_ADDRESS_SIZE]; |
unsigned char tox_id[TOX_ADDRESS_SIZE]; |
|
... |
... |
int do_client_loop(char *tox_id_str) |
273 |
271 |
client_tunnel.sockfd = 0; |
client_tunnel.sockfd = 0; |
274 |
272 |
FD_ZERO(&client_master_fdset); |
FD_ZERO(&client_master_fdset); |
275 |
273 |
|
|
276 |
|
tox_callback_friend_lossless_packet(tox, parse_lossless_packet, NULL); |
|
|
274 |
|
tox_callback_friend_lossless_packet(tox, parse_lossless_packet); |
277 |
275 |
|
|
278 |
276 |
if(!string_to_id(tox_id, tox_id_str)) |
if(!string_to_id(tox_id, tox_id_str)) |
279 |
277 |
{ |
{ |
|
... |
... |
int do_client_loop(char *tox_id_str) |
292 |
290 |
while(1) |
while(1) |
293 |
291 |
{ |
{ |
294 |
292 |
/* Let tox do its stuff */ |
/* Let tox do its stuff */ |
295 |
|
tox_iterate(tox); |
|
|
293 |
|
tox_iterate(tox, NULL); |
296 |
294 |
|
|
297 |
295 |
switch(state) |
switch(state) |
298 |
296 |
{ |
{ |
|
... |
... |
int do_client_loop(char *tox_id_str) |
307 |
305 |
break; |
break; |
308 |
306 |
case CLIENT_STATE_CONNECTED: |
case CLIENT_STATE_CONNECTED: |
309 |
307 |
{ |
{ |
310 |
|
uint8_t* data = "Hi, fellow tuntox instance!"; |
|
|
308 |
|
uint8_t* data = (uint8_t *)"Hi, fellow tuntox instance!"; |
311 |
309 |
uint16_t length = sizeof(data); |
uint16_t length = sizeof(data); |
312 |
310 |
TOX_ERR_FRIEND_ADD add_error; |
TOX_ERR_FRIEND_ADD add_error; |
313 |
311 |
|
|
314 |
312 |
if(use_shared_secret) |
if(use_shared_secret) |
315 |
313 |
{ |
{ |
316 |
|
data = shared_secret; |
|
|
314 |
|
data = (uint8_t *)shared_secret; |
317 |
315 |
data[TOX_MAX_FRIEND_REQUEST_LENGTH-1] = '\0'; |
data[TOX_MAX_FRIEND_REQUEST_LENGTH-1] = '\0'; |
318 |
|
length = strlen(data)+1; |
|
|
316 |
|
length = strlen((char *)data)+1; |
319 |
317 |
log_printf(L_DEBUG, "Sent shared secret of length %u\n", length); |
log_printf(L_DEBUG, "Sent shared secret of length %u\n", length); |
320 |
318 |
} |
} |
321 |
319 |
|
|
File main.h changed (mode: 100644) (index 329135f..fdffa11) |
... |
... |
extern tunnel *by_id; |
109 |
109 |
void parse_lossless_packet(Tox *tox, uint32_t friendnumber, const uint8_t *data, size_t len, void *tmp); |
void parse_lossless_packet(Tox *tox, uint32_t friendnumber, const uint8_t *data, size_t len, void *tmp); |
110 |
110 |
tunnel *tunnel_create(int sockfd, int connid, uint32_t friendnumber); |
tunnel *tunnel_create(int sockfd, int connid, uint32_t friendnumber); |
111 |
111 |
void tunnel_delete(tunnel *t); |
void tunnel_delete(tunnel *t); |
|
112 |
|
void update_select_nfds(int fd); |
|
113 |
|
int send_frame(protocol_frame *frame, uint8_t *data); |
|
114 |
|
int send_tunnel_request_packet(char *remote_host, int remote_port, int friend_number); |
112 |
115 |
|
|
113 |
116 |
void print_version(void); |
void print_version(void); |
114 |
117 |
#endif |
#endif |