Giter Site home page Giter Site logo

aker's People

Contributors

bill1600 avatar cableramki avatar guruchandru avatar knair410 avatar kraj avatar manderiasian avatar mend-bolt-for-github[bot] avatar sadhyama avatar schmidtw avatar shilpa24balaji avatar sivapalan-ayyappan avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aker's Issues

A duplicate schedule time can result in an infinite loop

If a duplicate time entry is specified it can result in an infinite loop. Below is an example of how to cause the problem:

char decode_buffer_4[] = "\x85"
                            "\xa6""weekly"
                                "\x95"
                                    "\x82"
                                        "\xa4""time" /*: */ "\x0a"
                                        "\xa7""indexes"
                                            "\x93" /* [ */ "\x00" "\x01" "\x03" /* ] */
                                    "\x82"
                                        "\xa4""time" /*: */ "\x14"
                                        "\xa7""indexes"
                                            "\x92" /* [ */ "\x00" "\x04" /* ] */
                                    "\x82"
                                        "\xa4""time" /*: */ "\x1e"
                                        "\xa7""indexes" "\xc0"
                                    "\x82"
                                        "\xa4""time" /*: */ "\x28"
                                        "\xa7""indexes"
                                            "\x91" /* [ */ "\x00" /* ] */
                                    "\x82"
                                        "\xa4""time" /*: */ "\x0a"  /*<----- Duplicate time that causes the infinite loop */
                                        "\xa7""indexes"
                                            "\x93" /* [ */ "\x03" "\x05" "\xcd\x03\x8f" /* ] */
                            "\xa4""macs"
                                "\x9a"
                                    "\xb1""11:22:33:44:55:aa"
                                    "\xb1""22:33:44:55:66:bb"
                                    "\xb1""33:44:55:66:77:cc"
                                    "\xb1""44:55:66:77:88:dd"
                                    "\xb1""55:33:44:55:66:bb"
                                    "\xb1""66:44:55:66:77:cc"
                                    "\xb1""77:55:66:77:88:dd"
                                    "\xb1""88:33:44:55:66:bb"
                                    "\xb1""99:44:55:66:77:cc"
                                    "\xb1""00:55:66:77:88:dd"
                            "\xa8""absolute"
                                "\x91"
                                    "\x82"
                                        "\xa9""unix_time" /* : */ "\xce""\x5a\x0b\x4a\xa8"
                                        "\xa7""indexes"   /* : */ "\x93" /* [ */ "\x00" "\x02" "\x09" /* ] */
                            "\xab""report_rate" /* : */ "\xcd""\x0e\x10"
                            "\xa6""ignore"      /* : */ "\xae""this parameter";

Add md5 calculation, storage and verification

We want to calculate the MD5 checksum and store it on disk upon receipt and storage of the file. Upon reading of the data file from disk, we want to re-check the MD5 to ensure the data was not corrupted.

Scheduler should imply last weekly event if there is one

schedule {
   s->mac_count: 3
       [0]: '11:22:33:44:55:66'
       [1]: '22:33:44:55:66:aa'
       [2]: '33:44:55:66:aa:BB'
   s->absolute:
       time: ????, block_count: 2 [2, 1] #absolute time of week time 25
       time: ????, block_count: 1 [2] #absolute time of week time 32
   s->weekly:
       time: 0, block_count: 0 []  <---- implied - this is wrong, we should imply the last weekly scheduled event
       time: 23, block_count: 1 [0]
       time: 30, block_count: 1 [1]
}

There should be no implied event at time 0 for the relative schedule. Instead we want to use the last time from the previous week are in place until the first event.

Unixtime to weekly time needs to be written.

Right now the actual converter does nothing, but the unixtime to weekly time needs to be finished. Of note - we need to ensure that the time changes are accounted for correctly.

Correct behavior for the time change:

  • Only the most recent event in the window of time that is truncated is applied
  • During the repeated windows of time, the schedule is also repeated as thou that there was not an immediate repeat.
  • Ensure that the correct next event window is calculated so Aker doesn't sleep for too long.

An empty list is not accepted.

If an empty list is passed for weekly or absolute the schedule is not accepted as part of the logic added to prevent the infinite loop.

Rename master branch to main

Also have to change references to the branch in .travis.yml, README, and CONTRIBUTING. Double check any other markdown files as well - sometimes links have the branch name in them.

Handling of new schedule message

  1. Message owner of schedule using a message queue.
  2. Replace schedule.
  3. If step # 2 is success, write the new schedule msgpack binary to file.

Add support for `zoneinfo` specification.

For devices that do not have space for the entire tzdata, we need a mechanism for supplying the zoneinfo file. We need to add the following:
[ ] add an optional value to the payload named zoneinfo field that expects a binary blob
[ ] add to the command line interface an option: --overwrite-zoneinfo dir

If the --overwrite-zone directory is specified and the zoneinfo field is present in the /aker/schedule request, then the blob specified will be written as the file: ${cli-dir}/${time_zone} where ${cli-dir} is the directory name specified with the --overwrite-zone option and the ${time_zone} is the string specified in the schedule.

This behavior should be performed each time the schedule is set.

If the schedule is deleted, the file should also be deleted.

If the --overwrite-zone option is not specified, Aker should happily use what POSIX and friends gives us.

Add Assurance Metrics

We would like to better understand how well Aker is performing. To enable this understanding we'd like to collect the following:

  • the count of the number of devices put on the block list
  • the count of the number of transitions between different blocking windows
  • the count of the number of times the schedule is set
  • the count of the number of times a schedule failed to decode
  • the count of the number of times the md5 check as failed
  • the current timezone as set by the schedule
  • the timezone offset based on the timezone applied to the schedule
  • the time the process started

The reporting times may be added to the schedule so the cloud can coordinate the events.

Schedule Schema

Below is an example schema represented in JSON for clarity, then MsgPack for accuracy.

  • ps - required - The unix time the process started running. This should not change except when the process is restarted.
  • id - required - The device-id running this instance of Aker.
  • rows - required - The array of rows of data. The default is to provide the last 3 data points (typically 24h worth of data).
  • ts - required - The unix time of the data set in UTC time.
  • off - required - The offset in seconds based on the schedule specified timezone.
  • dbc - required - The device block count is the number of device ids that have been blocked since the program started.
  • wtc - required - The window transition count is the number of times a transition between defined blocking windows has been encountered since the program started.
  • ssc - required - The schedule set count is the number of times a schedule has been set since the program started.
  • md5 - required - The md5 check failure count is the number of times the md5 did not match the file since the program started.
  • tz - required - The timezone string is the most recently specified timezone from the schedule in effect.
{
    "ps": 1622763073,
    "id": "mac:112233445566",
    "rows": [
        {
            "ts": 1622761073,
            "off": 28800,
            "dbc": 5312,
            "wtc": 204,
            "ssc": 3,
            "md5": 0,
            "tz": "PST8PDT"
        }, {
            "ts": 1622674673,
            "off": 28800,
            "dbc": 4612,
            "wtc": 123,
            "ssc": 2,
            "md5": 0,
            "tz": "PST8PDT"
        }, {
            "ts": 1622588273,
            "off": 28800,
            "dbc": 2212,
            "wtc": 54,
            "ssc": 1,
            "md5": 0,
            "tz": "PST8PDT"
        }
    ]
}

Hex MsgPack:

00000000: 82a2 7073 ce60 aeac 29a4 726f 7773 9387  ..ps.`..).rows..
00000010: a274 73ce 60b9 5e71 a36f 6666 cd70 80a3  .ts.`.^q.off.p..
00000020: 6462 63cd 14c0 a377 7463 cccc a373 7363  dbc....wtc...ssc
00000030: 03a3 6d64 3500 a274 7aa7 5053 5438 5044  ..md5..tz.PST8PD
00000040: 5487 a274 73ce 60b8 0cf1 a36f 6666 cd70  T..ts.`....off.p
00000050: 80a3 6462 63cd 1204 a377 7463 7ba3 7373  ..dbc....wtc{.ss
00000060: 6302 a36d 6435 00a2 747a a750 5354 3850  c..md5..tz.PST8P
00000070: 4454 87a2 7473 ce60 b6bb 71a3 6f66 66cd  DT..ts.`..q.off.
00000080: 7080 a364 6263 cd08 a4a3 7774 6336 a373  p..dbc....wtc6.s
00000090: 7363 01a3 6d64 3500 a274 7aa7 5053 5438  sc..md5..tz.PST8
000000a0: 5044 54                                  PDT

Add new endpoint for aker version

/aker/service/version/upstream should return the github repo commit hash in msgpack format like:

{
    "upstream": "8c310fcae2a35fd1dc139584ce9d5b289736e1a8"
}

Binary payload is not interpreted correctly

The binary payload below is not being interpreted correctly and is being discarded:
84 A9 74 69 6D 65 5F 7A 6F 6E 65 B0 41 6D 65 72 69 63 61 2F 4E 65 77 5F 59 6F 72 6B A6 77 65 65 6B 6C 79 93 82 A4 74 69 6D 65 0A A7 69 6E 64 65 78 65 73 93 00 01 03 82 A4 74 69 6D 65 14 A7 69 6E 64 65 78 65 73 91 00 82 A4 74 69 6D 65 1E A7 69 6E 64 65 78 65 73 C0 A4 6D 61 63 73 94 B1 31 31 3A 32 32 3A 33 33 3A 34 34 3A 35 35 3A 61 61 B1 32 32 3A 33 33 3A 34 34 3A 35 35 3A 36 36 3A 62 62 B1 33 33 3A 34 34 3A 35 35 3A 36 36 3A 37 37 3A 63 63 B1 34 34 3A 35 35 3A 36 36 3A 37 37 3A 38 38 3A 64 64 A8 61 62 73 6F 6C 75 74 65 91 82 A9 75 6E 69 78 5F 74 69 6D 65 CE 59 E5 83 17 A7 69 6E 64 65 78 65 73 92 00 02

Clean up log messages

We want to make sure that the log messages are useful and helpful when debugging problems. We need to ensure they are valuable and not too chatty.

Add time_zone support in MsgPack

  • Add time_zone type string to MsgPack structure
  • Add the code to actually use the new timezone data as described below (for the weekly schedule times only).

Suggested place to start:

int main (int argc, char *argv[])
{
   struct tm *mt;
   time_t mtt;
   char ftime[10];

   setenv("TZ", "America/New_York", 1);
   tzset();
   mtt = time(NULL);
   mt = localtime(&mtt);
   strftime(ftime,sizeof(ftime),"%Z %H%M",mt);

   printf("%s\n", ftime);
}

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.