Fix #211 - ADC IINF should have flag AP for application name, and VE for version.

x# Please enter the commit message for your changes. Lines starting
This commit is contained in:
Jan Vidar Krey 2014-08-03 22:51:47 +02:00
parent 4263750bc5
commit 652ac5f9b9
4 changed files with 35 additions and 13 deletions

View File

@ -111,7 +111,10 @@ typedef uint32_t fourcc_t;
#define ADC_INF_FLAG_CLIENT_ID "ID" /* client id, aka CID */ #define ADC_INF_FLAG_CLIENT_ID "ID" /* client id, aka CID */
#define ADC_INF_FLAG_NICK "NI" /* nick name */ #define ADC_INF_FLAG_NICK "NI" /* nick name */
#define ADC_INF_FLAG_DESCRIPTION "DE" /* user description */ #define ADC_INF_FLAG_DESCRIPTION "DE" /* user description */
#define ADC_INF_FLAG_USER_AGENT "VE" /* software version */
#define ADC_INF_FLAG_USER_AGENT_PRODUCT "AP" /* software name */
#define ADC_INF_FLAG_USER_AGENT_VERSION "VE" /* software version */
#define ADC_INF_FLAG_SUPPORT "SU" /* support (extensions, feature cast) */ #define ADC_INF_FLAG_SUPPORT "SU" /* support (extensions, feature cast) */
#define ADC_INF_FLAG_SHARED_SIZE "SS" /* size of total files shared in bytes */ #define ADC_INF_FLAG_SHARED_SIZE "SS" /* size of total files shared in bytes */
#define ADC_INF_FLAG_SHARED_FILES "SF" /* number of files shared */ #define ADC_INF_FLAG_SHARED_FILES "SF" /* number of files shared */

View File

@ -909,7 +909,8 @@ void hub_set_variables(struct hub_info* hub, struct acl_handle* acl)
if (hub->command_info) if (hub->command_info)
{ {
adc_msg_add_named_argument(hub->command_info, ADC_INF_FLAG_CLIENT_TYPE, ADC_CLIENT_TYPE_HUB); adc_msg_add_named_argument(hub->command_info, ADC_INF_FLAG_CLIENT_TYPE, ADC_CLIENT_TYPE_HUB);
adc_msg_add_named_argument(hub->command_info, ADC_INF_FLAG_USER_AGENT, server); adc_msg_add_named_argument(hub->command_info, ADC_INF_FLAG_USER_AGENT_PRODUCT, PRODUCT);
adc_msg_add_named_argument(hub->command_info, ADC_INF_FLAG_USER_AGENT_VERSION, GIT_VERSION);
tmp = adc_msg_escape(hub->config->hub_name); tmp = adc_msg_escape(hub->config->hub_name);
adc_msg_add_named_argument(hub->command_info, ADC_INF_FLAG_NICK, tmp); adc_msg_add_named_argument(hub->command_info, ADC_INF_FLAG_NICK, tmp);

View File

@ -366,21 +366,37 @@ static int check_logged_in(struct hub_info* hub, struct hub_user* user, struct a
*/ */
static int check_user_agent(struct hub_info* hub, struct hub_user* user, struct adc_message* cmd) static int check_user_agent(struct hub_info* hub, struct hub_user* user, struct adc_message* cmd)
{ {
char* ua_encoded = 0; char* ua_name_encoded = 0;
char* ua = 0; char* ua_version_encoded = 0;
char* str = 0;
size_t offset = 0;
/* Get client user agent version */ /* Get client user agent version */
ua_encoded = adc_msg_get_named_argument(cmd, ADC_INF_FLAG_USER_AGENT); ua_name_encoded = adc_msg_get_named_argument(cmd, ADC_INF_FLAG_USER_AGENT_PRODUCT);
if (ua_encoded) ua_version_encoded = adc_msg_get_named_argument(cmd, ADC_INF_FLAG_USER_AGENT_VERSION);
if (ua_name_encoded)
{ {
ua = adc_msg_unescape(ua_encoded); str = adc_msg_unescape(ua_name_encoded);
if (ua) if (str)
{ {
memcpy(user->id.user_agent, ua, MIN(strlen(ua), MAX_UA_LEN)); offset = strlen(str);
hub_free(ua); memcpy(user->id.user_agent, str, MIN(offset, MAX_UA_LEN));
hub_free(str);
} }
} }
hub_free(ua_encoded);
if (ua_version_encoded)
{
str = adc_msg_unescape(ua_version_encoded);
if (str)
{
memcpy(user->id.user_agent + offset, str, MIN(strlen(str), MAX_UA_LEN) - offset);
hub_free(str);
}
}
hub_free(ua_name_encoded);
hub_free(ua_version_encoded);
return 0; return 0;
} }
@ -622,7 +638,8 @@ static int hub_handle_info_low_bandwidth(struct hub_info* hub, struct hub_user*
{ {
if (hub->config->low_bandwidth_mode) if (hub->config->low_bandwidth_mode)
{ {
adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_USER_AGENT); adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_USER_AGENT_VERSION);
adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_USER_AGENT_PRODUCT);
adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_SHARED_FILES); adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_SHARED_FILES);
adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_COUNT_HUB_NORMAL); adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_COUNT_HUB_NORMAL);
adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_COUNT_HUB_REGISTER); adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_COUNT_HUB_REGISTER);

View File

@ -508,7 +508,8 @@ void ADC_client_send_info(struct ADC_client* client)
adc_msg_add_named_argument_string(client->info, ADC_INF_FLAG_DESCRIPTION, client->desc); adc_msg_add_named_argument_string(client->info, ADC_INF_FLAG_DESCRIPTION, client->desc);
} }
adc_msg_add_named_argument_string(client->info, ADC_INF_FLAG_USER_AGENT, PRODUCT " " VERSION); adc_msg_add_named_argument_string(client->info, ADC_INF_FLAG_USER_AGENT_PRODUCT, PRODUCT);
adc_msg_add_named_argument_string(client->info, ADC_INF_FLAG_USER_AGENT_VERSION, VERSION);
adc_msg_add_named_argument_int(client->info, ADC_INF_FLAG_UPLOAD_SLOTS, 0); adc_msg_add_named_argument_int(client->info, ADC_INF_FLAG_UPLOAD_SLOTS, 0);
adc_msg_add_named_argument_int(client->info, ADC_INF_FLAG_SHARED_SIZE, 0); adc_msg_add_named_argument_int(client->info, ADC_INF_FLAG_SHARED_SIZE, 0);
adc_msg_add_named_argument_int(client->info, ADC_INF_FLAG_SHARED_FILES, 0); adc_msg_add_named_argument_int(client->info, ADC_INF_FLAG_SHARED_FILES, 0);