mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 02:33:02 +01:00
Fixed spam problem. (I broke the API so this will not build)
The friend address is what the byte string that you give away for people to add you will be called. 1. Every friend address now contains a number set by the friend. This is to prevent someone from randomly spamming people in the DHT with friend requests and makes it so you need the person to actually give you the address in some way to send the friend request. This number is expected to be encrypted with the friend request. All requests that do not contain this number will be rejected. This means the spammer can no longer use the DHT to collect lists of valid addresses to spam. It also enables users to quickly change the number in case a spammer gets hold of the address and starts spamming it. 2. A 2 byte checksum will be added (not implemented yet) to prevent people from accidentally adding random strings as friends. (NOTE that this has nothing to do with the spam problem I just decided to add a placeholder for it now.)
This commit is contained in:
parent
fcf556cd1b
commit
2857e6af8f
8
chat.c
8
chat.c
@ -307,11 +307,13 @@ void execute(ToxWindow *self, ChatContext *ctx, Messenger *m, char *cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if (!strcmp(cmd, "/myid")) {
|
else if (!strcmp(cmd, "/myid")) {
|
||||||
char id[KEY_SIZE_BYTES*2+1] = {0};
|
char id[FRIEND_ADDRESS_SIZE*2+1] = {0};
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < KEY_SIZE_BYTES; i++) {
|
uint8_t address[FRIEND_ADDRESS_SIZE];
|
||||||
|
getaddress(m, address);
|
||||||
|
for (i = 0; i < FRIEND_ADDRESS_SIZE; i++) {
|
||||||
char xx[3];
|
char xx[3];
|
||||||
snprintf(xx, sizeof(xx), "%02x", self_public_key[i] & 0xff);
|
snprintf(xx, sizeof(xx), "%02X", address[i] & 0xff);
|
||||||
strcat(id, xx);
|
strcat(id, xx);
|
||||||
}
|
}
|
||||||
wprintw(ctx->history, "Your ID: %s\n", id);
|
wprintw(ctx->history, "Your ID: %s\n", id);
|
||||||
|
14
prompt.c
14
prompt.c
@ -93,7 +93,7 @@ void cmd_accept(ToxWindow *self, Messenger *m, char **args)
|
|||||||
|
|
||||||
void cmd_add(ToxWindow *self, Messenger *m, char **args)
|
void cmd_add(ToxWindow *self, Messenger *m, char **args)
|
||||||
{
|
{
|
||||||
uint8_t id_bin[KEY_SIZE_BYTES];
|
uint8_t id_bin[FRIEND_ADDRESS_SIZE];
|
||||||
char xx[3];
|
char xx[3];
|
||||||
uint32_t x;
|
uint32_t x;
|
||||||
char *id = args[1];
|
char *id = args[1];
|
||||||
@ -106,12 +106,12 @@ void cmd_add(ToxWindow *self, Messenger *m, char **args)
|
|||||||
if (!msg)
|
if (!msg)
|
||||||
msg = "";
|
msg = "";
|
||||||
|
|
||||||
if (strlen(id) != 2*KEY_SIZE_BYTES) {
|
if (strlen(id) != 2*FRIEND_ADDRESS_SIZE) {
|
||||||
wprintw(self->window, "Invalid ID length.\n");
|
wprintw(self->window, "Invalid ID length.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < KEY_SIZE_BYTES; ++i) {
|
for (i = 0; i < FRIEND_ADDRESS_SIZE; ++i) {
|
||||||
xx[0] = id[2*i];
|
xx[0] = id[2*i];
|
||||||
xx[1] = id[2*i+1];
|
xx[1] = id[2*i+1];
|
||||||
xx[2] = '\0';
|
xx[2] = '\0';
|
||||||
@ -217,11 +217,13 @@ void cmd_msg(ToxWindow *self, Messenger *m, char **args)
|
|||||||
|
|
||||||
void cmd_myid(ToxWindow *self, Messenger *m, char **args)
|
void cmd_myid(ToxWindow *self, Messenger *m, char **args)
|
||||||
{
|
{
|
||||||
char id[KEY_SIZE_BYTES*2 + 1] = {0};
|
char id[FRIEND_ADDRESS_SIZE*2 + 1] = {0};
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < KEY_SIZE_BYTES; ++i) {
|
uint8_t address[FRIEND_ADDRESS_SIZE];
|
||||||
|
getaddress(m, address);
|
||||||
|
for (i = 0; i < FRIEND_ADDRESS_SIZE; ++i) {
|
||||||
char xx[3];
|
char xx[3];
|
||||||
snprintf(xx, sizeof(xx), "%02x", self_public_key[i] & 0xff);
|
snprintf(xx, sizeof(xx), "%02X", address[i] & 0xff);
|
||||||
strcat(id, xx);
|
strcat(id, xx);
|
||||||
}
|
}
|
||||||
wprintw(self->window, "Your ID: %s\n", id);
|
wprintw(self->window, "Your ID: %s\n", id);
|
||||||
|
Loading…
Reference in New Issue
Block a user