@@ -146,19 +146,27 @@ static binresult *get_userinfo_user_pass(psync_socket *sock, const char *usernam
146
146
size_t ul , i ;
147
147
unsigned char sha1bin [PSYNC_SHA1_DIGEST_LEN ];
148
148
char sha1hex [PSYNC_SHA1_DIGEST_HEXLEN ];
149
+
149
150
res = send_command (sock , "getdigest" , empty_params );
151
+
150
152
if (!res )
151
153
return res ;
154
+
152
155
if (psync_find_result (res , "result" , PARAM_NUM )-> num != 0 ){
153
156
psync_free (res );
154
157
return NULL ;
155
158
}
159
+
156
160
dig = psync_find_result (res , "digest" , PARAM_STR );
161
+
157
162
debug (D_NOTICE , "got digest %s" , dig -> str );
163
+
158
164
ul = strlen (username );
159
165
uc = psync_new_cnt (unsigned char , ul );
166
+
160
167
for (i = 0 ; i < ul ; i ++ )
161
168
uc [i ]= tolower (username [i ]);
169
+
162
170
psync_sha1 (uc , ul , sha1bin );
163
171
psync_free (uc );
164
172
psync_binhex (sha1hex , sha1bin , PSYNC_SHA1_DIGEST_LEN );
@@ -168,7 +176,9 @@ static binresult *get_userinfo_user_pass(psync_socket *sock, const char *usernam
168
176
psync_sha1_update (& ctx , dig -> str , dig -> length );
169
177
psync_sha1_final (sha1bin , & ctx );
170
178
psync_binhex (sha1hex , sha1bin , PSYNC_SHA1_DIGEST_LEN );
179
+
171
180
ret = get_userinfo_user_digest (sock , username , ul , sha1hex , dig -> str , dig -> length , osversion , appversion , deviceid , devicestring );
181
+
172
182
psync_free (res );
173
183
return ret ;
174
184
}
@@ -261,8 +271,6 @@ static psync_socket *get_connected_socket(){
261
271
debug (D_NOTICE , "using deviceid %s" , deviceid );
262
272
appversion = psync_appname ();
263
273
devicestring = psync_device_string ();
264
-
265
- debug (D_NOTICE , "BOBO: AppVersion: [%s]" , appversion );
266
274
267
275
while (1 ){
268
276
psync_free (auth );
@@ -321,8 +329,6 @@ static psync_socket *get_connected_socket(){
321
329
osversion = psync_deviceos ();
322
330
323
331
if (psync_my_2fa_token && psync_my_2fa_code_type && psync_my_2fa_code [0 ]){
324
- debug (D_NOTICE , "BOBO: 2fa." );
325
-
326
332
const char * method = psync_my_2fa_code_type == 1 ?"tfa_login" :"tfa_loginwithrecoverycode" ;
327
333
binparam params []= {P_STR ("timeformat" , "timestamp" ),
328
334
P_STR ("token" , psync_my_2fa_token ),
@@ -340,17 +346,10 @@ static psync_socket *get_connected_socket(){
340
346
res = send_command (sock , method , params );
341
347
}
342
348
else if (user && pass && pass [0 ]){
343
- debug (D_NOTICE , "BOBO: Got user [%s], pass [%s]!" , user , pass );
344
349
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 );
347
350
res = get_userinfo_user_pass (sock , user , pass , osversion , appversion , deviceid , devicestring );
348
351
}
349
352
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
-
354
353
binparam params []= {P_STR ("timeformat" , "timestamp" ),
355
354
P_STR ("username" , user ),
356
355
P_STR ("password" , pass ),
@@ -361,14 +360,12 @@ static psync_socket *get_connected_socket(){
361
360
P_BOOL ("getauth" , 1 ),
362
361
P_BOOL ("cryptokeyssign" , 1 ),
363
362
P_BOOL ("getapiserver" , 1 ),
364
- P_BOOL ("getlastsubscription" , 1 ),
363
+ P_BOOL ("getlastsubscription" , 1 ),
365
364
P_NUM ("os" , P_OS_ID )};
366
365
res = send_command (sock , "login" , params );
367
366
}
368
367
}
369
368
else {
370
- debug (D_NOTICE , "BOBO: Userinfo." );
371
-
372
369
binparam params []= {P_STR ("timeformat" , "timestamp" ),
373
370
P_STR ("auth" , auth ),
374
371
P_STR ("osversion" , osversion ),
@@ -382,6 +379,7 @@ static psync_socket *get_connected_socket(){
382
379
P_NUM ("os" , P_OS_ID )};
383
380
res = send_command (sock , "userinfo" , params );
384
381
}
382
+
385
383
psync_free (osversion );
386
384
387
385
if (unlikely_log (!res )){
@@ -392,8 +390,6 @@ static psync_socket *get_connected_socket(){
392
390
continue ;
393
391
}
394
392
395
- debug (D_NOTICE , "BOBO: Reset API connection." );
396
-
397
393
psync_api_conn_fail_reset ();
398
394
result = psync_find_result (res , "result" , PARAM_NUM )-> num ;
399
395
@@ -404,38 +400,40 @@ static psync_socket *get_connected_socket(){
404
400
psync_free (psync_my_2fa_token );
405
401
psync_my_2fa_token = psync_strdup (psync_find_result (res , "token" , PARAM_STR )-> str );
406
402
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 ;
408
404
psync_my_2fa_code_type = 0 ;
409
405
psync_my_2fa_code [0 ]= 0 ;
410
406
psync_set_status (PSTATUS_TYPE_AUTH , PSTATUS_AUTH_TFAREQ );
411
407
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 );
414
410
continue ;
415
411
}
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
+
439
437
if (result == 2330 ){
440
438
psync_set_apiserver (PSYNC_API_HOST , PSYNC_LOCATIONID_DEFAULT );
441
439
psync_set_status (PSTATUS_TYPE_AUTH , PSTATUS_AUTH_RELOCATING );
@@ -444,8 +442,10 @@ static psync_socket *get_connected_socket(){
444
442
psync_free (res );
445
443
continue ;
446
444
}
447
- psync_socket_close (sock );
448
- psync_free (res );
445
+
446
+ psync_socket_close (sock );
447
+ psync_free (res );
448
+
449
449
if (result == 2000 || result == 2012 || result == 2064 || result == 2074 || result == 2092 ){
450
450
psync_my_2fa_code_type = 0 ;
451
451
psync_my_2fa_code [0 ]= 0 ;
0 commit comments