Skip to content

Commit

Permalink
Fixed some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
gjedeer committed Dec 7, 2016
1 parent 5667e56 commit b3b0e34
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SOURCES = $(wildcard *.c)
DEPS=libsodium toxcore
CC=gcc
CFLAGS=-g #-std=c99
CFLAGS=-g -Wall #-std=c99
CFLAGS += $(shell pkg-config --cflags $(DEPS))
LDFLAGS=-g -pthread -lm -static -lrt
LDFLAGS += $(shell pkg-config --static --libs $(DEPS))
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Client can be ran as a regular non-root user, [unless A < 1024](https://www.linu

## Security / threat model

**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!".
**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.

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.

Expand Down
16 changes: 7 additions & 9 deletions client.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ int handle_pong_frame(protocol_frame *rcvd_frame)

if(ping_mode)
{
// state = CLIENT_STATE_PONG_RECEIVED;
state = CLIENT_STATE_SEND_PING;
}
return 0;
Expand Down Expand Up @@ -198,7 +197,7 @@ int handle_server_tcp_frame(protocol_frame *rcvd_frame)

if(sent_bytes < 0)
{
char data[PROTOCOL_BUFFER_OFFSET];
uint8_t data[PROTOCOL_BUFFER_OFFSET];
protocol_frame frame_st, *frame;

log_printf(L_INFO, "Could not write to socket %d: %s\n", write_sockfd, strerror(errno));
Expand Down Expand Up @@ -231,7 +230,6 @@ int handle_server_tcp_frame(protocol_frame *rcvd_frame)
int handle_server_tcp_fin_frame(protocol_frame *rcvd_frame)
{
tunnel *tun=NULL;
int offset = 0;
int connid = rcvd_frame->connid;

HASH_FIND_INT(by_id, &connid, tun);
Expand All @@ -258,7 +256,7 @@ int handle_server_tcp_fin_frame(protocol_frame *rcvd_frame)
}

/* Main loop for the client */
int do_client_loop(char *tox_id_str)
int do_client_loop(unsigned char *tox_id_str)
{
unsigned char tox_packet_buf[PROTOCOL_MAX_PACKET_SIZE];
unsigned char tox_id[TOX_ADDRESS_SIZE];
Expand All @@ -273,7 +271,7 @@ int do_client_loop(char *tox_id_str)
client_tunnel.sockfd = 0;
FD_ZERO(&client_master_fdset);

tox_callback_friend_lossless_packet(tox, parse_lossless_packet, NULL);
tox_callback_friend_lossless_packet(tox, parse_lossless_packet);

if(!string_to_id(tox_id, tox_id_str))
{
Expand All @@ -292,7 +290,7 @@ int do_client_loop(char *tox_id_str)
while(1)
{
/* Let tox do its stuff */
tox_iterate(tox);
tox_iterate(tox, NULL);

switch(state)
{
Expand All @@ -307,15 +305,15 @@ int do_client_loop(char *tox_id_str)
break;
case CLIENT_STATE_CONNECTED:
{
uint8_t* data = "Hi, fellow tuntox instance!";
uint8_t* data = (uint8_t *)"Hi, fellow tuntox instance!";
uint16_t length = sizeof(data);
TOX_ERR_FRIEND_ADD add_error;

if(use_shared_secret)
{
data = shared_secret;
data = (uint8_t *)shared_secret;
data[TOX_MAX_FRIEND_REQUEST_LENGTH-1] = '\0';
length = strlen(data)+1;
length = strlen((char *)data)+1;
log_printf(L_DEBUG, "Sent shared secret of length %u\n", length);
}

Expand Down
2 changes: 1 addition & 1 deletion client.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ int handle_pong_frame(protocol_frame *rcvd_frame);
int handle_acktunnel_frame(protocol_frame *rcvd_frame);
int handle_server_tcp_frame(protocol_frame *rcvd_frame);
int handle_server_tcp_fin_frame(protocol_frame *rcvd_frame);
int do_client_loop(char *tox_id_str);
int do_client_loop(unsigned char *tox_id_str);
2 changes: 1 addition & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void set_tox_username(Tox *tox)
int gai_result;
TOX_ERR_SET_INFO error;

gethostname(hostname, 1024);
gethostname((char*)hostname, 1024);
hostname[1023] = '\0';

tox_self_set_name(tox, hostname, strlen(hostname), &error);
Expand Down
3 changes: 3 additions & 0 deletions main.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ extern tunnel *by_id;
void parse_lossless_packet(Tox *tox, uint32_t friendnumber, const uint8_t *data, size_t len, void *tmp);
tunnel *tunnel_create(int sockfd, int connid, uint32_t friendnumber);
void tunnel_delete(tunnel *t);
void update_select_nfds(int fd);
int send_frame(protocol_frame *frame, uint8_t *data);
int send_tunnel_request_packet(char *remote_host, int remote_port, int friend_number);

void print_version(void);
#endif

0 comments on commit b3b0e34

Please sign in to comment.