jda / nanofi

Low-overhead controller for Ubiquiti UniFi devices
MIT License
7 stars 0 forks source link

Implement essential config support #1

Open jda opened 2 years ago

jda commented 2 years ago

Sort config support for basic adoption flow, including:

  1. What devices are adoptable?
  2. How to generate and store keys per device
  3. How to store config of desired state and current state (per most recent inform)
jda commented 2 years ago

Thinking three files per device: desired config, current config, and authkeylog (most recent key wins)

jda commented 2 years ago

General config could be CLI flags or config file. Use CLI flags for first rev.

Need one config file containing mac addresses that we are willing to service. One per line. Read at program startup only (worry about SIGHUP or whatever later).

Need config flag for the inform URL we provide to devices when they try to adopt.

Need config flag for dir to hold per-device configs.

Dump json that device sends us in inform to ${MACADDR}.json in config dir. Every time we adopt or rotate device creds, append cred to ${MACADDR}.auth

Device handling should be stateless. Request comes in. Check if mac is in list of mac we want to service. If it is, check for ${MACADDR}.auth file. If it exists, read it and try to decrypt based on keys in file. If no .auth file, generate new key, add it to file, and reply with adopt/set config to new key.