Skip to content

Commit

Permalink
Revert "AWS backup"
Browse files Browse the repository at this point in the history
This reverts commit b7d5c4a.
  • Loading branch information
nirhen committed Dec 2, 2024
1 parent 6ee7610 commit 6479f06
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 90 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ltmain.sh
missing
mkinstalldirs
libtool
*Makefile
py-compile
stamp-h1
src/.libs
Expand Down
23 changes: 7 additions & 16 deletions src/asr.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
#define ASR_FEC_SLICE_STRIDE 40
#define ASR_PACKETS_PER_FEC 25
#define ASR_PAYLOAD_PACKET_SIZE 1450
#define ASR_PAYLOAD_CHUNK_SIZE 32768
#define ASR_CHECKSUM_CHUNK_SIZE 32768
#define ASR_PAYLOAD_CHUNK_SIZE 131072
#define ASR_CHECKSUM_CHUNK_SIZE 131072

int asr_open_with_timeout(idevice_t device, asr_client_t* asr, uint16_t port)
{
Expand Down Expand Up @@ -354,11 +354,9 @@ int asr_handle_oob_data_request(asr_client_t asr, plist_t packet, ipsw_file_hand
free(oob_data);
return 0;
}
int g_count = 0 ;

int asr_send_payload(asr_client_t asr, ipsw_file_handle_t file)
{
g_count++;
info("asr_send_payload small packets") ;
char *data = NULL;
uint64_t i, length, bytes = 0;
double progress = 0;
Expand All @@ -377,20 +375,18 @@ int asr_send_payload(asr_client_t asr, ipsw_file_handle_t file)
if (i < ASR_PAYLOAD_CHUNK_SIZE) {
size = i;
}
//info("\r\nipsw_file_read");

if (ipsw_file_read(file, data, size) != (int64_t)size) {
info("Error reading filesystem\n");
error("Error reading filesystem\n");
retry--;
continue;
}
//info("ipsw_file_read read done");

sendsize = size;
if (asr->checksum_chunks) {
sha1((unsigned char*)data, size, (unsigned char*)(data+size));
sendsize += 20;
}

// info("\r\nasr_send_buffer");
if (asr_send_buffer(asr, data, sendsize) < 0) {
error("Unable to send filesystem payload chunk, retrying...\n");
retry--;
Expand All @@ -405,13 +401,8 @@ int asr_send_payload(asr_client_t asr, ipsw_file_handle_t file)
}

i -= size;
if(g_count%20==0)
Sleep(1) ;
//info("again");
}
info("\r\nfree");

free(data);
info("\r\nreturn");
return (i == 0) ? 0 : -1;

}
17 changes: 0 additions & 17 deletions src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,6 @@ static FILE* debug_stream = NULL;
static int info_disabled = 0;
static int error_disabled = 0;
static int debug_disabled = 0;
void printTime()
{
time_t rawtime;
struct tm * timeinfo;
time(&rawtime);
timeinfo = localtime(&rawtime);
// Print current time in human-readable format
printf("\nCurrent time: %02d:%02d:%02d\n %d", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
}

static mutex_t log_mutex;
static thread_once_t init_once = THREAD_ONCE_INIT;
Expand All @@ -106,11 +97,8 @@ void info(const char* format, ...)
va_start(vargs, format);
vfprintf((info_stream) ? info_stream : stdout, format, vargs);
va_end(vargs);
printTime() ;
fflush(info_stream?info_stream:stdout);

mutex_unlock(&log_mutex);

}

void error(const char* format, ...)
Expand All @@ -126,11 +114,8 @@ void error(const char* format, ...)
vfprintf((error_stream) ? error_stream : stderr, format, vargs2);
}
va_end(vargs2);
printTime() ;

fflush(error_stream?error_stream:stderr);
mutex_unlock(&log_mutex);

}

void debug(const char* format, ...)
Expand All @@ -145,10 +130,8 @@ void debug(const char* format, ...)
va_start(vargs, format);
vfprintf((debug_stream) ? debug_stream : stderr, format, vargs);
va_end(vargs);
printTime();
fflush(debug_stream?debug_stream:stderr);
mutex_unlock(&log_mutex);

}

void idevicerestore_set_info_stream(FILE* strm)
Expand Down
23 changes: 8 additions & 15 deletions src/dfu.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,16 +465,19 @@ int dfu_enter_recovery(struct idevicerestore_client_t* client, plist_t build_ide
}
dfu_client_free(client);

int tries = 3;
if (client->build_major > 8) {
/* reconnect */
debug("Waiting for device to disconnect...\n");
cond_wait_timeout(&client->device_event_cond, &client->device_event_mutex, 10000);
tries = 3 ;
while(tries-- && ((client->mode != MODE_DFU && client->mode != MODE_RECOVERY) || (client->flags & FLAG_QUIT))) {
debug("cond_wait_timeout retry\n");
cond_wait_timeout(&client->device_event_cond, &client->device_event_mutex, 3000);
if (client->mode != MODE_UNKNOWN || (client->flags & FLAG_QUIT)) {
mutex_unlock(&client->device_event_mutex);
if (!(client->flags & FLAG_QUIT)) {
error("ERROR: Device did not disconnect. Possibly invalid iBSS. Reset device and try again.\n");
}
return -1;
}
debug("Waiting for device to reconnect...\n");
cond_wait_timeout(&client->device_event_cond, &client->device_event_mutex, 10000);
if ((client->mode != MODE_DFU && client->mode != MODE_RECOVERY) || (client->flags & FLAG_QUIT)) {
mutex_unlock(&client->device_event_mutex);
if (!(client->flags & FLAG_QUIT)) {
Expand Down Expand Up @@ -641,11 +644,6 @@ int dfu_enter_recovery(struct idevicerestore_client_t* client, plist_t build_ide

debug("Waiting for device to disconnect...\n");
cond_wait_timeout(&client->device_event_cond, &client->device_event_mutex, 10000);
tries = 3 ;
while(tries-- && (client->mode != MODE_UNKNOWN || (client->flags & FLAG_QUIT))) {
debug("cond_wait_timeout retry\n");
cond_wait_timeout(&client->device_event_cond, &client->device_event_mutex, 3000);
}
if (client->mode != MODE_UNKNOWN || (client->flags & FLAG_QUIT)) {
mutex_unlock(&client->device_event_mutex);
if (!(client->flags & FLAG_QUIT)) {
Expand All @@ -654,11 +652,6 @@ int dfu_enter_recovery(struct idevicerestore_client_t* client, plist_t build_ide
return -1;
}
debug("Waiting for device to reconnect in recovery mode...\n");
tries = 3 ;
while(tries-- && (client->mode != MODE_RECOVERY || (client->flags & FLAG_QUIT))) {
debug("cond_wait_timeout retry\n");
cond_wait_timeout(&client->device_event_cond, &client->device_event_mutex, 3000);
}
cond_wait_timeout(&client->device_event_cond, &client->device_event_mutex, 10000);
if (client->mode != MODE_RECOVERY || (client->flags & FLAG_QUIT)) {
mutex_unlock(&client->device_event_mutex);
Expand Down
2 changes: 1 addition & 1 deletion src/fdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ int fdr_poll_and_handle_message(fdr_client_t fdr)
return -1;
}

device_error = idevice_connection_receive_timeout(fdr->connection, (char *)&cmd, sizeof(cmd), &bytes, 40000);
device_error = idevice_connection_receive_timeout(fdr->connection, (char *)&cmd, sizeof(cmd), &bytes, 20000);
#ifdef HAVE_IDEVICE_E_TIMEOUT
if (device_error == IDEVICE_E_TIMEOUT || (device_error == IDEVICE_E_SUCCESS && bytes != sizeof(cmd)))
#else
Expand Down
20 changes: 1 addition & 19 deletions src/idevicerestore.c
Original file line number Diff line number Diff line change
Expand Up @@ -1436,11 +1436,6 @@ int idevicerestore_start(struct idevicerestore_client_t* client)

debug("Waiting for device to disconnect...\n");
cond_wait_timeout(&client->device_event_cond, &client->device_event_mutex, 60000);
int tries = 3 ;
while(tries-- && (client->mode != MODE_UNKNOWN || (client->flags & FLAG_QUIT))) {
debug("cond_wait_timeout retry\n");
cond_wait_timeout(&client->device_event_cond, &client->device_event_mutex, 3000);
}
if (client->mode != MODE_UNKNOWN || (client->flags & FLAG_QUIT)) {
mutex_unlock(&client->device_event_mutex);

Expand All @@ -1452,11 +1447,6 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
recovery_client_free(client);
debug("Waiting for device to reconnect in recovery mode...\n");
cond_wait_timeout(&client->device_event_cond, &client->device_event_mutex, 60000);
tries = 3 ;
while(tries-- && (client->mode != MODE_RECOVERY || (client->flags & FLAG_QUIT))) {
debug("cond_wait_timeout retry\n");
cond_wait_timeout(&client->device_event_cond, &client->device_event_mutex, 3000);
}
if (client->mode != MODE_RECOVERY || (client->flags & FLAG_QUIT)) {
mutex_unlock(&client->device_event_mutex);
if (!(client->flags & FLAG_QUIT)) {
Expand Down Expand Up @@ -1520,18 +1510,14 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
plist_free(client->tss);
return -2;
}
recovery_client_free(client);
}
idevicerestore_progress(client, RESTORE_STEP_PREPARE, 0.9);

if (client->mode != MODE_RESTORE) {
mutex_lock(&client->device_event_mutex);
info("Waiting for device to enter restore mode...\n");
cond_wait_timeout(&client->device_event_cond, &client->device_event_mutex, 180000);
int tries = 13 ;
while(tries-- && (client->mode != MODE_RESTORE || (client->flags & FLAG_QUIT))) {
debug("cond_wait_timeout retry\n");
cond_wait_timeout(&client->device_event_cond, &client->device_event_mutex, 3000);
}
if (client->mode != MODE_RESTORE || (client->flags & FLAG_QUIT)) {
mutex_unlock(&client->device_event_mutex);
error("ERROR: Device failed to enter restore mode.\n");
Expand Down Expand Up @@ -1741,12 +1727,9 @@ void plain_progress_cb(int step, double step_progress, void* userdata)
{
printf("progress: %u %f\n", step, step_progress);
fflush(stdout);
fflush(stderr);
}

int main(int argc, char* argv[]) {
//setbuf(stdout, NULL);
//setbuf(stderr, NULL);
int opt = 0;
int optindex = 0;
char* ipsw = NULL;
Expand Down Expand Up @@ -1984,7 +1967,6 @@ int main(int argc, char* argv[]) {

irecv_device_t get_irecv_device(struct idevicerestore_client_t *client)
{
info("get_irecv_device");
int mode = _MODE_UNKNOWN;

if (client->mode) {
Expand Down
10 changes: 0 additions & 10 deletions src/normal.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,6 @@ int normal_enter_recovery(struct idevicerestore_client_t* client)
mutex_lock(&client->device_event_mutex);
debug("DEBUG: Waiting for device to disconnect...\n");
cond_wait_timeout(&client->device_event_cond, &client->device_event_mutex, 60000);
int tries = 3 ;
while(tries-- && (client->mode == MODE_NORMAL || (client->flags & FLAG_QUIT))) {
debug("cond_wait_timeout retry\n");
cond_wait_timeout(&client->device_event_cond, &client->device_event_mutex, 3000);
}
if (client->mode == MODE_NORMAL || (client->flags & FLAG_QUIT)) {
mutex_unlock(&client->device_event_mutex);
error("ERROR: Failed to place device in recovery mode\n");
Expand All @@ -273,11 +268,6 @@ int normal_enter_recovery(struct idevicerestore_client_t* client)

debug("DEBUG: Waiting for device to connect in recovery mode...\n");
cond_wait_timeout(&client->device_event_cond, &client->device_event_mutex, 60000);
tries = 3 ;
while(tries-- && (client->mode != MODE_RECOVERY || (client->flags & FLAG_QUIT))) {
debug("cond_wait_timeout retry\n");
cond_wait_timeout(&client->device_event_cond, &client->device_event_mutex, 3000);
}
if (client->mode != MODE_RECOVERY || (client->flags & FLAG_QUIT)) {
mutex_unlock(&client->device_event_mutex);
error("ERROR: Failed to enter recovery mode\n");
Expand Down
7 changes: 1 addition & 6 deletions src/recovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,7 @@ int recovery_enter_restore(struct idevicerestore_client_t* client, plist_t build
}

debug("DEBUG: Waiting for device to disconnect...\n");
cond_wait_timeout(&client->device_event_cond, &client->device_event_mutex, 40000);
int tries = 13 ;
while(tries-- && (client->mode == MODE_RECOVERY || (client->flags & FLAG_QUIT))) {
debug("cond_wait_timeout retry\n");
cond_wait_timeout(&client->device_event_cond, &client->device_event_mutex, 3000);
}
cond_wait_timeout(&client->device_event_cond, &client->device_event_mutex, 30000);
if (client->mode == MODE_RECOVERY || (client->flags & FLAG_QUIT)) {
mutex_unlock(&client->device_event_mutex);
error("ERROR: Failed to place device in restore mode\n");
Expand Down
7 changes: 1 addition & 6 deletions src/restore.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,6 @@ int restore_reboot(struct idevicerestore_client_t* client)
restored_client_free(client->restore->client);

cond_wait_timeout(&client->device_event_cond, &client->device_event_mutex, 30000);
int tries = 3 ;
while(tries-- && (client->mode == MODE_RECOVERY || (client->flags & FLAG_QUIT))) {
debug("cond_wait_timeout retry\n");
cond_wait_timeout(&client->device_event_cond, &client->device_event_mutex, 3000);
}
if (client->mode == MODE_RESTORE) {
mutex_unlock(&client->device_event_mutex);
return -1;
Expand Down Expand Up @@ -5710,4 +5705,4 @@ int restore_device(struct idevicerestore_client_t* client, plist_t build_identit

restore_client_free(client);
return err;
}
}

0 comments on commit 6479f06

Please sign in to comment.