{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "description": "The rate (rated) settings",
    "markdownDescription": "The [rate](https://docs.halon.io/hsl/functions.html#core.rate) (`rated`) settings",
    "additionalProperties": false,
    "required": ["version"],
    "properties": {
        "version": {
            "type": "string",
            "enum": ["5.3"],
            "description": "The software version the configuration was created for"
        },
        "key": {
            "type": "string",
            "minLength": 40,
            "maxLength": 128,
            "pattern": "^[a-f0-9]+$",
            "description": "Used for rate synchronization between units"
        },
        "listen": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "address": {
                    "description": "Listen address",
                    "anyOf": [
                        {
                            "type": "string",
                            "format": "ipv4",
                            "description": "The IPv4 address"
                        },
                        {
                            "type": "string",
                            "format": "ipv6",
                            "description": "The IPv6 address"
                        }
                    ]
                }
            }
        },
        "environment": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "socket": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                        "path": {
                            "type": "string",
                            "default": "/var/run/halon/rated.sock",
                            "description": "socket path"
                        },
                        "owner": {
                            "type": "string",
                            "description": "socket owner"
                        },
                        "group": {
                            "type": "string",
                            "description": "socket group"
                        },
                        "chmod": {
                            "$ref": "#/definitions/mode",
                            "description": "socket chmod"
                        }
                    }
                },
                "controlsocket": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                        "path": {
                            "type": "string",
                            "default": "/var/run/halon/rated.ctl",
                            "description": "socket path"
                        },
                        "owner": {
                            "type": "string",
                            "description": "socket owner"
                        },
                        "group": {
                            "type": "string",
                            "description": "socket group"
                        },
                        "chmod": {
                            "$ref": "#/definitions/mode",
                            "description": "socket chmod"
                        }
                    }
                },
                "privdrop": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                        "user": {
                            "type": "string",
                            "description": "Privdrop user"
                        },
                        "group": {
                            "type": "string",
                            "description": "Privdrop group"
                        }
                    }
                },
                "appconf": {
                    "type": "string",
                    "default": "/etc/halon/rated-app.yaml",
                    "description": "Application conf path"
                }
            }
        }
    },
    "definitions": {
        "mode": {
            "type": "string",
            "pattern": "^[0-7][0-7][0-7][0-7]$",
            "minLength": 4,
            "maxLength": 4
        }
    }
}