Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b0144df

Browse files
author
pcloudcom
committedNov 17, 2021
Intermediate commit.
1 parent 982d110 commit b0144df

File tree

3 files changed

+56
-21
lines changed

3 files changed

+56
-21
lines changed
 

‎pCloudCC/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ target_link_libraries(sqlite3 z dl)
5454

5555
add_library(pcloudcc_lib SHARED pclsync_lib_c.cpp pclsync_lib.cpp control_tools.cpp ${OVERLAY_CLENT_PATH}/overlay_client.c ${OVERLAY_CLENT_PATH}/debug.c )
5656

57-
target_link_libraries(pcloudcc_lib ${PCLSYNC_PATH}/libpsynclib.a ${MBEDTLS_PATH}/library/libmbedtls.a fuse pthread sqlite3
57+
target_link_libraries(pcloudcc_lib ${PCLSYNC_PATH}/psynclib.a ${MBEDTLS_PATH}/library/libmbedtls.a fuse pthread sqlite3 udev
5858
)
5959

6060
add_executable(pcloudcc main.cpp)

‎pCloudCC/lib/pclsync/pdiff.c

+38-16
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ static psync_socket *get_connected_socket(){
261261
debug(D_NOTICE, "using deviceid %s", deviceid);
262262
appversion=psync_appname();
263263
devicestring=psync_device_string();
264+
265+
debug(D_NOTICE, "BOBO: AppVersion: [%s]", appversion);
264266

265267
while (1){
266268
psync_free(auth);
@@ -319,27 +321,37 @@ static psync_socket *get_connected_socket(){
319321
osversion=psync_deviceos();
320322

321323
if (psync_my_2fa_token && psync_my_2fa_code_type && psync_my_2fa_code[0]){
324+
debug(D_NOTICE, "BOBO: 2fa.");
325+
322326
const char *method=psync_my_2fa_code_type==1?"tfa_login":"tfa_loginwithrecoverycode";
323327
binparam params[]={P_STR("timeformat", "timestamp"),
324-
P_STR("token", psync_my_2fa_token),
325-
P_STR("code", psync_my_2fa_code),
326-
P_BOOL("trustdevice", psync_my_2fa_trust),
327-
P_STR("osversion", osversion),
328-
P_STR("appversion", appversion),
329-
P_STR("deviceid", deviceid),
330-
P_STR("device", devicestring),
331-
P_BOOL("getauth", 1),
332-
P_BOOL("cryptokeyssign", 1),
333-
P_BOOL("getapiserver", 1),
334-
P_BOOL("getlastsubscription", 1),
335-
P_NUM("os", P_OS_ID)};
328+
P_STR("token", psync_my_2fa_token),
329+
P_STR("code", psync_my_2fa_code),
330+
P_BOOL("trustdevice", psync_my_2fa_trust),
331+
P_STR("osversion", osversion),
332+
P_STR("appversion", appversion),
333+
P_STR("deviceid", deviceid),
334+
P_STR("device", devicestring),
335+
P_BOOL("getauth", 1),
336+
P_BOOL("cryptokeyssign", 1),
337+
P_BOOL("getapiserver", 1),
338+
P_BOOL("getlastsubscription", 1),
339+
P_NUM("os", P_OS_ID)};
336340
res=send_command(sock, method, params);
337341
}
338342
else if (user && pass && pass[0]){
339-
if (digest)
343+
debug(D_NOTICE, "BOBO: Got user [%s], pass [%s]!", user, pass);
344+
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);
340347
res=get_userinfo_user_pass(sock, user, pass, osversion, appversion, deviceid, devicestring);
348+
}
341349
else{
342-
binparam params[]={P_STR("timeformat", "timestamp"),
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+
binparam params[]={P_STR("timeformat", "timestamp"),
343355
P_STR("username", user),
344356
P_STR("password", pass),
345357
P_STR("osversion", osversion),
@@ -355,6 +367,8 @@ static psync_socket *get_connected_socket(){
355367
}
356368
}
357369
else {
370+
debug(D_NOTICE, "BOBO: Userinfo.");
371+
358372
binparam params[]={P_STR("timeformat", "timestamp"),
359373
P_STR("auth", auth),
360374
P_STR("osversion", osversion),
@@ -364,20 +378,25 @@ static psync_socket *get_connected_socket(){
364378
P_BOOL("getauth", 1),
365379
P_BOOL("cryptokeyssign", 1),
366380
P_BOOL("getapiserver", 1),
367-
P_BOOL("getlastsubscription", 1),
381+
P_BOOL("getlastsubscription", 1),
368382
P_NUM("os", P_OS_ID)};
369383
res=send_command(sock, "userinfo", params);
370384
}
371385
psync_free(osversion);
386+
372387
if (unlikely_log(!res)){
373388
psync_socket_close(sock);
374389
psync_set_status(PSTATUS_TYPE_ONLINE, PSTATUS_ONLINE_OFFLINE);
375390
psync_milisleep(PSYNC_SLEEP_BEFORE_RECONNECT);
376391
psync_api_conn_fail_inc();
377392
continue;
378393
}
394+
395+
debug(D_NOTICE, "BOBO: Reset API connection.");
396+
379397
psync_api_conn_fail_reset();
380398
result=psync_find_result(res, "result", PARAM_NUM)->num;
399+
381400
if (unlikely(result)){
382401
debug(D_NOTICE, "userinfo returned error %lu %s", (unsigned long)result, psync_find_result(res, "error", PARAM_STR)->str);
383402
// here we only handle statuses that need to access the result
@@ -407,7 +426,10 @@ static psync_socket *get_connected_socket(){
407426
cres=psync_check_result(res, "location", PARAM_HASH);
408427
if (cres){
409428
binapi=psync_strdup(psync_find_result(cres, "binapi", PARAM_STR)->str);
410-
locationid=psync_find_result(cres, "id", PARAM_NUM)->num;
429+
430+
debug(D_NOTICE, "BOBO: Wring server. Suggested server: [%s]", binapi);
431+
432+
locationid=psync_find_result(cres, "id", PARAM_NUM)->num;
411433
psync_set_apiserver(binapi,locationid);
412434
}
413435
psync_socket_close(sock);

‎pCloudCC/pclsync_lib.cpp

+17-4
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ static char const * status2string (uint32_t status){
170170
static void status_change(pstatus_t* status) {
171171
static int cryptocheck=0;
172172
static int mount_set=0;
173+
174+
char *err;
175+
err = (char*)malloc(1024);
176+
173177
std::cout << "Down: " << status->downloadstr << "| Up: " << status->uploadstr <<", status is " << status2string(status->status) << std::endl;
174178
*clib::pclsync_lib::get_lib().status_ = *status;
175179
if (status->status==PSTATUS_LOGIN_REQUIRED){
@@ -186,7 +190,13 @@ static void status_change(pstatus_t* status) {
186190
}
187191
else {
188192
std::cout << "registering" << std::endl;
189-
if (psync_register(clib::pclsync_lib::get_lib().get_username().c_str(), clib::pclsync_lib::get_lib().get_password().c_str(),1, NULL)){
193+
if (psync_register(clib::pclsync_lib::get_lib().get_username().c_str(),
194+
clib::pclsync_lib::get_lib().get_password().c_str(),
195+
1,
196+
"bineapi.pcloud.com",
197+
2,
198+
&err)
199+
){
190200
std::cout << "both login and registration failed" << std::endl;
191201
exit(1);
192202
}
@@ -229,11 +239,14 @@ int clib::pclsync_lib::list_sync_folders (const char* path, void * rep) {
229239
memcpy(rep, folders, sizeof(folders));
230240

231241
}
232-
static const std::string client_name = " Console Client v.2.0.1";
242+
static const std::string client_name = "pCloud CC v3.0.0";
233243
int clib::pclsync_lib::init()//std::string& username, std::string& password, std::string* crypto_pass, int setup_crypto, int usesrypto_userpass)
234244
{
235-
std::string software_string = exec("lsb_release -ds");
236-
psync_set_software_string(software_string.append(client_name).c_str());
245+
std::string software_string;
246+
//std::string software_string = exec("lsb_release -ds");
247+
248+
psync_set_software_string(client_name.c_str());
249+
237250
if (setup_crypto_ && crypto_pass_.empty() )
238251
return 3;
239252

0 commit comments

Comments
 (0)
Please sign in to comment.