diff options
author | irungentoo <irungentoo@gmail.com> | 2013-08-13 09:32:31 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-08-13 09:32:31 -0400 |
commit | 97f449a2f1aa3e4fbe7f2d853efa0c7935ded967 (patch) | |
tree | 9896c268be528828617823d7b04da9f7a0d0386f /core/Messenger.h | |
parent | 8fe1dec5d634a2bba214b9204bda8341e8b26ed5 (diff) |
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.)
Diffstat (limited to 'core/Messenger.h')
-rw-r--r-- | core/Messenger.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/core/Messenger.h b/core/Messenger.h index aa9611a4..48e14cf7 100644 --- a/core/Messenger.h +++ b/core/Messenger.h | |||
@@ -38,6 +38,8 @@ extern "C" { | |||
38 | #define MAX_NAME_LENGTH 128 | 38 | #define MAX_NAME_LENGTH 128 |
39 | #define MAX_STATUSMESSAGE_LENGTH 128 | 39 | #define MAX_STATUSMESSAGE_LENGTH 128 |
40 | 40 | ||
41 | #define FRIEND_ADDRESS_SIZE (crypto_box_PUBLICKEYBYTES + sizeof(uint32_t) + sizeof(uint16_t)) | ||
42 | |||
41 | #define PACKET_ID_NICKNAME 48 | 43 | #define PACKET_ID_NICKNAME 48 |
42 | #define PACKET_ID_STATUSMESSAGE 49 | 44 | #define PACKET_ID_STATUSMESSAGE 49 |
43 | #define PACKET_ID_USERSTATUS 50 | 45 | #define PACKET_ID_USERSTATUS 50 |
@@ -89,6 +91,7 @@ typedef struct { | |||
89 | uint16_t info_size; /* length of the info */ | 91 | uint16_t info_size; /* length of the info */ |
90 | uint32_t message_id; /* a semi-unique id used in read receipts */ | 92 | uint32_t message_id; /* a semi-unique id used in read receipts */ |
91 | uint8_t receives_read_receipts; /* shall we send read receipts to this person? */ | 93 | uint8_t receives_read_receipts; /* shall we send read receipts to this person? */ |
94 | uint32_t friendrequest_nospam; /*The nospam number used in the friend request*/ | ||
92 | } Friend; | 95 | } Friend; |
93 | 96 | ||
94 | typedef struct Messenger { | 97 | typedef struct Messenger { |
@@ -134,9 +137,17 @@ typedef struct Messenger { | |||
134 | } Messenger; | 137 | } Messenger; |
135 | 138 | ||
136 | /* | 139 | /* |
140 | * returns a FRIEND_ADDRESS_SIZE byte address to give to others. | ||
141 | * format: [client_id (32 bytes)][nospam number (4 bytes)][checksum (2 bytes)] | ||
142 | * | ||
143 | * TODO: add checksum. | ||
144 | */ | ||
145 | void getaddress(Messenger *m, uint8_t *address); | ||
146 | |||
147 | /* | ||
137 | * add a friend | 148 | * add a friend |
138 | * set the data that will be sent along with friend request | 149 | * set the data that will be sent along with friend request |
139 | * client_id is the client id of the friend | 150 | * address is the address of the friend (returned by getaddress) it must be FRIEND_ADDRESS_SIZE bytes. TODO: add checksum. |
140 | * data is the data and length is the length | 151 | * data is the data and length is the length |
141 | * returns the friend number if success | 152 | * returns the friend number if success |
142 | * return -1 if message length is too long | 153 | * return -1 if message length is too long |
@@ -145,7 +156,7 @@ typedef struct Messenger { | |||
145 | * return -4 if friend request already sent or already a friend | 156 | * return -4 if friend request already sent or already a friend |
146 | * return -5 for unknown error | 157 | * return -5 for unknown error |
147 | */ | 158 | */ |
148 | int m_addfriend(Messenger *m, uint8_t *client_id, uint8_t *data, uint16_t length); | 159 | int m_addfriend(Messenger *m, uint8_t *address, uint8_t *data, uint16_t length); |
149 | 160 | ||
150 | 161 | ||
151 | /* add a friend without sending a friendrequest. | 162 | /* add a friend without sending a friendrequest. |