Giter Club home page Giter Club logo

dmon's People

Contributors

clburlison avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

lordjavi

dmon's Issues

Sending telemetric data to DCM

Sending telemetric data to DCM (or any other backend) could provide better traceability of random device reboots etc.
If desired, i can make a backend that can retrieve that data and generate graphs for each device and parameter.

int sendTelemetricData (void)
{
    // Device name
    NSString *deviceName = [[UIDevice currentDevice] name];
	
    // Battery percentage
    UIDevice *device = [UIDevice currentDevice];
    device.batteryMonitoringEnabled = YES;
    float batteryLevel = [device batteryLevel] * 100.0f;
    
    // CPU temperature
    int mib[2];
    mib[0] = CTL_HW;
    mib[1] = HW_CPU_TEMPERATURE;
    int64_t temperature;
    size_t length = sizeof(temperature);
    sysctl(mib, 2, &temperature, &length, NULL, 0);
    float cpuTemp = temperature / 100.0f;
    
    // Init
    CURL *curl;
    CURLcode res;
    curl_global_init(CURL_GLOBAL_ALL);
    curl = curl_easy_init();
    
    if (curl)
	{
        curl_easy_setopt(curl, CURLOPT_URL, "http://YOUR_DCM_URL");
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "device_name=%f&battery_percentage=%f&cpu_temperature=%f", [deviceName UTF8String], batteryLevel, cpuTemp);
        
        res = curl_easy_perform(curl);
        if (res != CURLE_OK) {
            fprintf(stderr, "dmon: curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
        }
        
        curl_easy_cleanup(curl);
    }
    
    curl_global_cleanup();
    return 0;
}

Download error handling

Right now if the webserver doesn't have a valid path curl is still exiting with return code 0. Need to add some better error handling. Also make sure we don't save an empty file to disk.

Reset display brightness to 0

I'd appreciate it if dmon also constantly reset the display brightness to 0. Some devices keep bugging me with that.

#import <UIKit/UIKit.h>

int dimDisplayBrightness (void)
{
    @autoreleasepool
    {
        UIScreen *mainScreen = [UIScreen mainScreen];
        mainScreen.brightness = 0.0f;
    }
    return 0;
}

Failed Pokemon Go detection

Bug

The following method of detecting if Pokemon Go is running is flawed

dmon/src/usr/bin/dmon

Lines 3 to 8 in d873255

# Not perfect. It takes iOS ~10 seconds to register
# the application has been sent to the background
# or crashed.
check_pogo_running() {
ps aux | grep -i "PokmonGO.app/PokmonGO" | grep -v grep
}

Even with the game closed the process can still be running. Didn't catch this edge case initially.

root# ps aux | grep -i "PokmonGO.app/PokmonGO" | grep -v grep
mobile         23398   0.0  0.2 408075872   3888   ??  Ss   11:45PM   0:00.50 /var/containers/Bundle/Application/42E6155C-F220-4682-9CBC-25ECAB5BD2DC/PokmonGO.app/PokmonGO

Potential fix

Initially I wanted to do game detection via the proper Apple API. But no matter what I try I always get null as the output. Tried a few different varaiations in the following file to get [(SpringBoard *)UIApplication.sharedApplication _accessibilityFrontMostApplication]; to work but never got anything usable.

https://github.com/clburlison/dmon/blob/current_app/tools/current_app.m

https://www.reddit.com/r/jailbreakdevelopers/comments/q9d0w4/comment/hgv41k9/?utm_source=share&utm_medium=web2x&context=3

Better check for PoGo running

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;
}

Update function for dmon itself

Just flat forgot. The LaunchD unload/reload is the only piece I'm a little concerned about. If dmon is subbing out to popen & the daemon is unloaded I'm not sure if the rest of the postinstall script will run.

DCM integration

Since GC already requires DCM it might make sense to have it host the packages.

If someone wants to work on this the version.txt file should likely stay the same format? Just have nodejs build the config map on get request. Also I'd like to make it optional so users can use basic web server or DCM.

I am not scheduled work for this. Resource limited at the moment but will accept a PR.

Install substitute on setup

Bug

In order for substitute to properly install we need to apt update & apt upgrade on the phone. Ideally we want this to occur silently but unsure if there are any supported CLI flags that will do this.

dmon/bin/setup

Lines 30 to 34 in d873255

# Requires https://repo.palera.in which should be added by default
ssh root@localhost -p 2222 'apt update'
ssh root@localhost -p 2222 'apt upgrade -y --allow-unauthenticated'
ssh root@localhost -p 2222 'apt install -y --allow-unauthenticated com.saurik.substrate.safemode'
ssh root@localhost -p 2222 'apt install -y --allow-unauthenticated com.ex.substitute'

Potential fix

If we can't get the following to work we should link the two correct .debs in the readme. The downside it they can't be easily updated via apt update.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.