Skip to content

Commit 5f5648d

Browse files
author
pcloudcom
committedNov 18, 2021
Logs cleanup.
1 parent b0144df commit 5f5648d

File tree

1 file changed

+44
-44
lines changed

1 file changed

+44
-44
lines changed
 

‎pCloudCC/lib/pclsync/pdiff.c

+44-44
Original file line numberDiff line numberDiff line change
@@ -146,19 +146,27 @@ static binresult *get_userinfo_user_pass(psync_socket *sock, const char *usernam
146146
size_t ul, i;
147147
unsigned char sha1bin[PSYNC_SHA1_DIGEST_LEN];
148148
char sha1hex[PSYNC_SHA1_DIGEST_HEXLEN];
149+
149150
res=send_command(sock, "getdigest", empty_params);
151+
150152
if (!res)
151153
return res;
154+
152155
if (psync_find_result(res, "result", PARAM_NUM)->num!=0){
153156
psync_free(res);
154157
return NULL;
155158
}
159+
156160
dig=psync_find_result(res, "digest", PARAM_STR);
161+
157162
debug(D_NOTICE, "got digest %s", dig->str);
163+
158164
ul=strlen(username);
159165
uc=psync_new_cnt(unsigned char, ul);
166+
160167
for (i=0; i<ul; i++)
161168
uc[i]=tolower(username[i]);
169+
162170
psync_sha1(uc, ul, sha1bin);
163171
psync_free(uc);
164172
psync_binhex(sha1hex, sha1bin, PSYNC_SHA1_DIGEST_LEN);
@@ -168,7 +176,9 @@ static binresult *get_userinfo_user_pass(psync_socket *sock, const char *usernam
168176
psync_sha1_update(&ctx, dig->str, dig->length);
169177
psync_sha1_final(sha1bin, &ctx);
170178
psync_binhex(sha1hex, sha1bin, PSYNC_SHA1_DIGEST_LEN);
179+
171180
ret=get_userinfo_user_digest(sock, username, ul, sha1hex, dig->str, dig->length, osversion, appversion, deviceid, devicestring);
181+
172182
psync_free(res);
173183
return ret;
174184
}
@@ -261,8 +271,6 @@ static psync_socket *get_connected_socket(){
261271
debug(D_NOTICE, "using deviceid %s", deviceid);
262272
appversion=psync_appname();
263273
devicestring=psync_device_string();
264-
265-
debug(D_NOTICE, "BOBO: AppVersion: [%s]", appversion);
266274

267275
while (1){
268276
psync_free(auth);
@@ -321,8 +329,6 @@ static psync_socket *get_connected_socket(){
321329
osversion=psync_deviceos();
322330

323331
if (psync_my_2fa_token && psync_my_2fa_code_type && psync_my_2fa_code[0]){
324-
debug(D_NOTICE, "BOBO: 2fa.");
325-
326332
const char *method=psync_my_2fa_code_type==1?"tfa_login":"tfa_loginwithrecoverycode";
327333
binparam params[]={P_STR("timeformat", "timestamp"),
328334
P_STR("token", psync_my_2fa_token),
@@ -340,17 +346,10 @@ static psync_socket *get_connected_socket(){
340346
res=send_command(sock, method, params);
341347
}
342348
else if (user && pass && pass[0]){
343-
debug(D_NOTICE, "BOBO: Got user [%s], pass [%s]!", user, pass);
344349
if (digest){
345-
debug(D_NOTICE, "BOBO: Digest. ApiServer: [%s]", apiserver);
346-
debug(D_NOTICE, "BOBO: Osversion: [%s], AppVersion: [%s], DeviceId: [%s], DeviceString: [%s]", osversion, appversion, deviceid, devicestring);
347350
res=get_userinfo_user_pass(sock, user, pass, osversion, appversion, deviceid, devicestring);
348351
}
349352
else{
350-
debug(D_NOTICE, "BOBO: Send login. user:[%s], pass:[%s]", user, pass);
351-
debug(D_NOTICE, "BOBO: Send login. OSversion:[%s], AppVersion:[%s]", osversion, appversion);
352-
debug(D_NOTICE, "BOBO: Send login. deviceid:[%s], devicestring:[%s]", deviceid, devicestring);
353-
354353
binparam params[]={P_STR("timeformat", "timestamp"),
355354
P_STR("username", user),
356355
P_STR("password", pass),
@@ -361,14 +360,12 @@ static psync_socket *get_connected_socket(){
361360
P_BOOL("getauth", 1),
362361
P_BOOL("cryptokeyssign", 1),
363362
P_BOOL("getapiserver", 1),
364-
P_BOOL("getlastsubscription", 1),
363+
P_BOOL("getlastsubscription", 1),
365364
P_NUM("os", P_OS_ID)};
366365
res=send_command(sock, "login", params);
367366
}
368367
}
369368
else {
370-
debug(D_NOTICE, "BOBO: Userinfo.");
371-
372369
binparam params[]={P_STR("timeformat", "timestamp"),
373370
P_STR("auth", auth),
374371
P_STR("osversion", osversion),
@@ -382,6 +379,7 @@ static psync_socket *get_connected_socket(){
382379
P_NUM("os", P_OS_ID)};
383380
res=send_command(sock, "userinfo", params);
384381
}
382+
385383
psync_free(osversion);
386384

387385
if (unlikely_log(!res)){
@@ -392,8 +390,6 @@ static psync_socket *get_connected_socket(){
392390
continue;
393391
}
394392

395-
debug(D_NOTICE, "BOBO: Reset API connection.");
396-
397393
psync_api_conn_fail_reset();
398394
result=psync_find_result(res, "result", PARAM_NUM)->num;
399395

@@ -404,38 +400,40 @@ static psync_socket *get_connected_socket(){
404400
psync_free(psync_my_2fa_token);
405401
psync_my_2fa_token=psync_strdup(psync_find_result(res, "token", PARAM_STR)->str);
406402
psync_my_2fa_has_devices=psync_find_result(res, "hasdevices", PARAM_BOOL)->num;
407-
psync_my_2fa_type=psync_find_result(res, "tfatype", PARAM_NUM)->num;
403+
psync_my_2fa_type=psync_find_result(res, "tfatype", PARAM_NUM)->num;
408404
psync_my_2fa_code_type=0;
409405
psync_my_2fa_code[0]=0;
410406
psync_set_status(PSTATUS_TYPE_AUTH, PSTATUS_AUTH_TFAREQ);
411407
psync_wait_status(PSTATUS_TYPE_AUTH, PSTATUS_AUTH_PROVIDED);
412-
psync_socket_close(sock);
413-
psync_free(res);
408+
psync_socket_close(sock);
409+
psync_free(res);
414410
continue;
415411
}
416-
if (result==2306){
417-
psync_free(psync_my_verify_token);
418-
psync_my_verify_token = psync_strdup(psync_find_result(res, "verifytoken", PARAM_STR)->str);
419-
psync_set_status(PSTATUS_TYPE_AUTH, PSTATUS_AUTH_VERIFYREQ);
420-
psync_wait_status(PSTATUS_TYPE_AUTH, PSTATUS_AUTH_PROVIDED);
421-
psync_socket_close(sock);
422-
psync_free(res);
423-
continue;
424-
}
425-
if (result==2321){
426-
cres=psync_check_result(res, "location", PARAM_HASH);
427-
if (cres){
428-
binapi=psync_strdup(psync_find_result(cres, "binapi", PARAM_STR)->str);
429-
430-
debug(D_NOTICE, "BOBO: Wring server. Suggested server: [%s]", binapi);
431-
432-
locationid=psync_find_result(cres, "id", PARAM_NUM)->num;
433-
psync_set_apiserver(binapi,locationid);
434-
}
435-
psync_socket_close(sock);
436-
psync_free(res);
437-
continue;
438-
}
412+
413+
if (result==2306){
414+
psync_free(psync_my_verify_token);
415+
psync_my_verify_token = psync_strdup(psync_find_result(res, "verifytoken", PARAM_STR)->str);
416+
psync_set_status(PSTATUS_TYPE_AUTH, PSTATUS_AUTH_VERIFYREQ);
417+
psync_wait_status(PSTATUS_TYPE_AUTH, PSTATUS_AUTH_PROVIDED);
418+
psync_socket_close(sock);
419+
psync_free(res);
420+
continue;
421+
}
422+
423+
if (result==2321){
424+
cres=psync_check_result(res, "location", PARAM_HASH);
425+
if (cres){
426+
binapi=psync_strdup(psync_find_result(cres, "binapi", PARAM_STR)->str);
427+
428+
locationid=psync_find_result(cres, "id", PARAM_NUM)->num;
429+
psync_set_apiserver(binapi,locationid);
430+
}
431+
432+
psync_socket_close(sock);
433+
psync_free(res);
434+
continue;
435+
}
436+
439437
if(result==2330){
440438
psync_set_apiserver(PSYNC_API_HOST, PSYNC_LOCATIONID_DEFAULT);
441439
psync_set_status(PSTATUS_TYPE_AUTH, PSTATUS_AUTH_RELOCATING);
@@ -444,8 +442,10 @@ static psync_socket *get_connected_socket(){
444442
psync_free(res);
445443
continue;
446444
}
447-
psync_socket_close(sock);
448-
psync_free(res);
445+
446+
psync_socket_close(sock);
447+
psync_free(res);
448+
449449
if (result==2000 || result==2012 || result==2064 || result==2074 || result==2092){
450450
psync_my_2fa_code_type=0;
451451
psync_my_2fa_code[0]=0;

0 commit comments

Comments
 (0)
Please sign in to comment.