clburlison / dmon

iOS jailbreak monitoring & update solution
MIT License
4 stars 1 forks source link

Better check for PoGo running #19

Open VampireSilence opened 1 year ago

VampireSilence commented 1 year ago

Sometimes PoGo stops working even though it's opened and the frontmost app, so a better approach would be to check if PoGo is actually doing something. Those functions check the last log time of GC and then checks if it's more than 5 minutes in the past. We can further tweak that time frame in the future.

#include <asl.h>
#include <time.h>

int pogo_work_state(time_t log_time)
{
    time_t current_time = time(NULL);
    return (difftime(current_time, log_time) > 300);
}

time_t get_last_log_time()
{
    aslclient client = asl_open(NULL, "com.gocheats.jb", 0);
    aslmsg query = asl_new(ASL_TYPE_QUERY);
    asl_set_query(query, ASL_KEY_SENDER, "com.gocheats.jb", ASL_QUERY_OP_EQUAL);
    aslresponse response = asl_search(client, query);
    aslmsg msg;

    time_t last_time = 0;
    while ((msg = aslresponse_next(response)) != NULL)
    {
        const char *time_str = asl_get(msg, ASL_KEY_TIME);
        time_t time_val = (time_t)strtoll(time_str, NULL, 10);
        if (time_val > last_time)
        {
            last_time = time_val;
        }
    }

    aslresponse_free(response);
    asl_free(query);
    asl_close(client);

    return last_time;
}
clburlison commented 1 year ago

Was hoping we wouldn't have to do this. Now that I got the stupid version checking & downloads working as intended this will be next. Your code looks correct so hopefully I'll only need to do a little testing.

clburlison commented 1 year ago

Still want to investigate this but one core issue I have seen is the launchDaemon stopping with a non-zero exit code. Pretty sure calling the killall binary is one of the issues since kernbypass blocks that process.

Will have a new update out in a few days that hopefully improves the monitoring aspect. It's been more stable on my four test devices the last 24hrs.

If this is still an issue after that update I'll look into monitoring the log.