{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "description": "The server (smtpd) startup configuration",
    "markdownDescription": "The server (`smtpd`) [startup configuration](https://docs.halon.io/manual/archive/master/config_startup.html)",
    "additionalProperties": false,
    "required": [
        "version"
    ],
    "properties": {
        "version": {
            "type": "string",
            "enum": [
                "6.11"
            ],
            "description": "The software version the configuration was created for"
        },
        "servers": {
            "type": "array",
            "uniqueItems": true,
            "description": "The virtual servers (listeners)",
            "items": {
                "type": "object",
                "required": [
                    "id"
                ],
                "additionalProperties": false,
                "allOf": [
                    {
                        "if": {
                            "required": [
                                "type"
                            ],
                            "properties": {
                                "type": {
                                    "enum": [
                                        "http",
                                        "https"
                                    ]
                                }
                            }
                        },
                        "then": {
                            "allOf": [
                                {
                                    "not": {
                                        "required": [
                                            "proxyprotocol"
                                        ]
                                    }
                                },
                                {
                                    "properties": {
                                        "listeners": {
                                            "maxItems": 1
                                        }
                                    }
                                },
                                {
                                    "properties": {
                                        "threads": {
                                            "properties": {
                                                "event": {
                                                    "not": {
                                                        "type": "object",
                                                        "required": [
                                                            "id"
                                                        ]
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    },
                    {
                        "if": {
                            "required": [
                                "type"
                            ],
                            "properties": {
                                "type": {
                                    "enum": [
                                        "plugin"
                                    ]
                                }
                            }
                        },
                        "then": {
                            "allOf": [
                                {
                                    "not": {
                                        "required": [
                                            "listeners"
                                        ]
                                    }
                                },
                                {
                                    "not": {
                                        "required": [
                                            "proxyprotocol"
                                        ]
                                    }
                                },
                                {
                                    "properties": {
                                        "threads": {
                                            "not": {
                                                "required": [
                                                    "event"
                                                ]
                                            }
                                        }
                                    }
                                }
                            ]
                        },
                        "else": {
                            "required": [
                                "listeners"
                            ]
                        }
                    }
                ],
                "properties": {
                    "id": {
                        "$ref": "#/definitions/objectid",
                        "description": "Server ID"
                    },
                    "type": {
                        "enum": [
                            "smtp",
                            "http",
                            "https",
                            "plugin"
                        ],
                        "default": "smtp"
                    },
                    "listeners": {
                        "type": "array",
                        "uniqueItems": true,
                        "minItems": 1,
                        "description": "The IP addresses and ports to listen on. If no IP addresses are specificed it will bind to any (both IPv4 and IPv6)",
                        "items": {
                            "oneOf": [
                                {
                                    "type": "object",
                                    "required": [
                                        "port"
                                    ],
                                    "additionalProperties": false,
                                    "properties": {
                                        "id": {
                                            "$ref": "#/definitions/objectid",
                                            "description": "The listen ID, referenced by running configuration"
                                        },
                                        "port": {
                                            "type": "integer",
                                            "maximum": 65535,
                                            "minimum": 1,
                                            "description": "Port number"
                                        },
                                        "address": {
                                            "description": "IP address",
                                            "anyOf": [
                                                {
                                                    "$ref": "#/definitions/ipv4"
                                                },
                                                {
                                                    "$ref": "#/definitions/ipv6"
                                                }
                                            ]
                                        },
                                        "backlog": {
                                            "type": "integer",
                                            "maximum": 65535,
                                            "minimum": 1,
                                            "description": "Listen backlog"
                                        }
                                    }
                                },
                                {
                                    "type": "object",
                                    "required": [
                                        "path"
                                    ],
                                    "additionalProperties": false,
                                    "properties": {
                                        "id": {
                                            "$ref": "#/definitions/objectid",
                                            "description": "The listen ID, referenced by running configuration"
                                        },
                                        "path": {
                                            "type": "string",
                                            "description": "Socket path"
                                        },
                                        "owner": {
                                            "type": "string",
                                            "description": "Socket owner"
                                        },
                                        "group": {
                                            "type": "string",
                                            "description": "Socket group"
                                        },
                                        "chmod": {
                                            "$ref": "#/definitions/mode",
                                            "description": "Socket chmod"
                                        },
                                        "backlog": {
                                            "type": "integer",
                                            "maximum": 65535,
                                            "minimum": 1,
                                            "description": "Listen backlog"
                                        }
                                    }
                                }
                            ]
                        }
                    },
                    "proxyprotocol": {
                        "description": "Allow use of the PROXY protocol (v1 and v2) from IP(s)",
                        "default": false,
                        "anyOf": [
                            {
                                "type": "array",
                                "uniqueItems": true,
                                "items": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/definitions/ipv4"
                                        },
                                        {
                                            "$ref": "#/definitions/ipv4net"
                                        },
                                        {
                                            "$ref": "#/definitions/ipv6"
                                        },
                                        {
                                            "$ref": "#/definitions/ipv6net"
                                        }
                                    ]
                                },
                                "description": "A list of IP addresses"
                            },
                            {
                                "type": "boolean",
                                "description": "true is any IP address and false is disabled",
                                "markdownDescription": "`true` is any IP address and `false` is disabled"
                            }
                        ]
                    },
                    "threads": {
                        "type": "object",
                        "description": "Thread pool settings",
                        "additionalProperties": false,
                        "properties": {
                            "event": {
                                "oneOf": [
                                    {
                                        "type": "integer",
                                        "minimum": 1,
                                        "default": 4,
                                        "description": "Number of event loop threads"
                                    },
                                    {
                                        "type": "object",
                                        "additionalProperties": false,
                                        "properties": {
                                            "count": {
                                                "type": "integer",
                                                "minimum": 1,
                                                "default": 4,
                                                "description": "Number of event loop threads"
                                            },
                                            "priority": {
                                                "type": "integer",
                                                "minimum": -20,
                                                "maximum": 19,
                                                "default": 0,
                                                "description": "The thread priority (nice) value"
                                            }
                                        }
                                    },
                                    {
                                        "type": "object",
                                        "additionalProperties": false,
                                        "required": [
                                            "id"
                                        ],
                                        "properties": {
                                            "id": {
                                                "$ref": "#/definitions/objectid",
                                                "description": "The thread pool ID"
                                            }
                                        }
                                    }
                                ]
                            },
                            "script": {
                                "oneOf": [
                                    {
                                        "type": "integer",
                                        "minimum": 1,
                                        "default": 32,
                                        "description": "Number of script pool threads"
                                    },
                                    {
                                        "type": "object",
                                        "additionalProperties": false,
                                        "required": [
                                            "id"
                                        ],
                                        "properties": {
                                            "id": {
                                                "$ref": "#/definitions/objectid",
                                                "description": "The default thread pool ID"
                                            },
                                            "hooks": {
                                                "type": "object",
                                                "additionalProperties": false,
                                                "description": "The hooks thread pool ID",
                                                "properties": {
                                                    "connect": {
                                                        "$ref": "#/definitions/objectid"
                                                    },
                                                    "proxy": {
                                                        "$ref": "#/definitions/objectid"
                                                    },
                                                    "helo": {
                                                        "$ref": "#/definitions/objectid"
                                                    },
                                                    "auth": {
                                                        "$ref": "#/definitions/objectid"
                                                    },
                                                    "mailfrom": {
                                                        "$ref": "#/definitions/objectid"
                                                    },
                                                    "rcptto": {
                                                        "$ref": "#/definitions/objectid"
                                                    },
                                                    "eod": {
                                                        "$ref": "#/definitions/objectid"
                                                    },
                                                    "disconnect": {
                                                        "$ref": "#/definitions/objectid"
                                                    }
                                                }
                                            }
                                        }
                                    }
                                ]
                            }
                        }
                    },
                    "scripting": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                            "concurrency": {
                                "type": "integer",
                                "minimum": 1,
                                "description": "Number of scripts running using cooperative multitasking"
                            },
                            "stacksize": {
                                "oneOf": [
                                    {
                                        "type": "integer",
                                        "minimum": 1,
                                        "default": 2097152,
                                        "description": "Script stacksize (in bytes)"
                                    },
                                    {
                                        "$ref": "#/definitions/byteformat",
                                        "description": "Script stacksize (in byte format)"
                                    }
                                ]
                            }
                        }
                    }
                }
            }
        },
        "queues": {
            "type": "object",
            "description": "Queue settings",
            "additionalProperties": false,
            "properties": {
                "threads": {
                    "type": "object",
                    "description": "Thread pool settings",
                    "additionalProperties": false,
                    "properties": {
                        "event": {
                            "oneOf": [
                                {
                                    "type": "integer",
                                    "minimum": 1,
                                    "default": 4,
                                    "description": "Number of event loop threads"
                                },
                                {
                                    "type": "object",
                                    "additionalProperties": false,
                                    "properties": {
                                        "count": {
                                            "type": "integer",
                                            "minimum": 1,
                                            "default": 4,
                                            "description": "Number of event loop threads"
                                        },
                                        "priority": {
                                            "type": "integer",
                                            "minimum": -20,
                                            "maximum": 19,
                                            "default": 0,
                                            "description": "The thread priority (nice) value"
                                        }
                                    }
                                }
                            ]
                        },
                        "script": {
                            "oneOf": [
                                {
                                    "type": "integer",
                                    "minimum": 1,
                                    "default": 32,
                                    "description": "Number of script pool threads"
                                },
                                {
                                    "type": "object",
                                    "additionalProperties": false,
                                    "required": [
                                        "id"
                                    ],
                                    "properties": {
                                        "id": {
                                            "$ref": "#/definitions/objectid",
                                            "description": "The default thread pool ID"
                                        },
                                        "hooks": {
                                            "type": "object",
                                            "additionalProperties": false,
                                            "description": "The hooks thread pool ID",
                                            "properties": {
                                                "predelivery": {
                                                    "$ref": "#/definitions/objectid"
                                                },
                                                "postdelivery": {
                                                    "$ref": "#/definitions/objectid"
                                                }
                                            }
                                        }
                                    }
                                }
                            ]
                        },
                        "pickup": {
                            "oneOf": [
                                {
                                    "type": "integer",
                                    "minimum": 1,
                                    "default": 1,
                                    "description": "Number of queue pickup threads"
                                },
                                {
                                    "type": "object",
                                    "additionalProperties": false,
                                    "properties": {
                                        "count": {
                                            "type": "integer",
                                            "minimum": 1,
                                            "default": 1,
                                            "description": "Number of queue pickup threads"
                                        },
                                        "priority": {
                                            "type": "integer",
                                            "minimum": -20,
                                            "maximum": 19,
                                            "default": 0,
                                            "description": "The thread priority (nice) value"
                                        }
                                    }
                                }
                            ]
                        },
                        "fetch": {
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {
                                "priority": {
                                    "type": "integer",
                                    "minimum": -20,
                                    "maximum": 19,
                                    "default": 0,
                                    "description": "The thread priority (nice) value"
                                }
                            }
                        },
                        "release": {
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {
                                "priority": {
                                    "type": "integer",
                                    "minimum": -20,
                                    "maximum": 19,
                                    "default": 0,
                                    "description": "The thread priority (nice) value"
                                }
                            }
                        },
                        "rate": {
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {
                                "priority": {
                                    "type": "integer",
                                    "minimum": -20,
                                    "maximum": 19,
                                    "default": 0,
                                    "description": "The thread priority (nice) value"
                                }
                            }
                        }
                    }
                },
                "scripting": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                        "concurrency": {
                            "type": "integer",
                            "minimum": 1,
                            "description": "Number of scripts running using cooperative multitasking"
                        },
                        "stacksize": {
                            "oneOf": [
                                {
                                    "type": "integer",
                                    "minimum": 1,
                                    "default": 2097152,
                                    "description": "Script stacksize (in bytes)"
                                },
                                {
                                    "$ref": "#/definitions/byteformat",
                                    "description": "Script stacksize (in byte format)"
                                }
                            ]
                        }
                    }
                }
            }
        },
        "pki": {
            "type": "object",
            "description": "The X.509 certificates and private keys",
            "additionalProperties": false,
            "properties": {
                "private": {
                    "type": "array",
                    "uniqueItems": true,
                    "description": "Private keys, possibly with X.509 certificates",
                    "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                            "id",
                            "privatekey"
                        ],
                        "properties": {
                            "id": {
                                "$ref": "#/definitions/objectid",
                                "description": "The key ID"
                            },
                            "certificate": {
                                "oneOf": [
                                    {
                                        "type": "object",
                                        "additionalProperties": false,
                                        "required": [
                                            "data"
                                        ],
                                        "properties": {
                                            "data": {
                                                "type": "string",
                                                "minLength": 1,
                                                "description": "The PKCS #8 PEM data"
                                            }
                                        }
                                    },
                                    {
                                        "type": "object",
                                        "additionalProperties": false,
                                        "required": [
                                            "path"
                                        ],
                                        "properties": {
                                            "path": {
                                                "type": "string",
                                                "minLength": 1,
                                                "description": "The PKCS #8 PEM path"
                                            }
                                        }
                                    }
                                ]
                            },
                            "privatekey": {
                                "oneOf": [
                                    {
                                        "type": "object",
                                        "additionalProperties": false,
                                        "required": [
                                            "data"
                                        ],
                                        "properties": {
                                            "data": {
                                                "type": "string",
                                                "minLength": 1,
                                                "description": "The private key data"
                                            }
                                        }
                                    },
                                    {
                                        "type": "object",
                                        "additionalProperties": false,
                                        "required": [
                                            "path"
                                        ],
                                        "properties": {
                                            "path": {
                                                "type": "string",
                                                "minLength": 1,
                                                "description": "The private key path"
                                            }
                                        }
                                    }
                                ]
                            }
                        }
                    }
                }
            }
        },
        "plugins": {
            "type": "array",
            "uniqueItems": true,
            "description": "A list of following plugins",
            "items": {
                "type": "object",
                "required": [
                    "id"
                ],
                "additionalProperties": false,
                "properties": {
                    "id": {
                        "$ref": "#/definitions/objectid",
                        "description": "Plugin ID"
                    },
                    "path": {
                        "type": "string",
                        "minLength": 1,
                        "description": "The plugin (.so) path. The default path is /opt/halon/plugins/"
                    },
                    "config": {
                        "oneOf": [
                            {
                                "type": "object",
                                "additionalProperties": true,
                                "description": "The plugin config"
                            },
                            {
                                "type": "string",
                                "description": "A path to the configuration"
                            }
                        ]
                    }
                }
            }
        },
        "threads": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "scripts": {
                    "type": "array",
                    "uniqueItems": true,
                    "description": "A list of script thread pools",
                    "items": {
                        "type": "object",
                        "required": [
                            "id"
                        ],
                        "additionalProperties": false,
                        "properties": {
                            "id": {
                                "$ref": "#/definitions/objectid",
                                "description": "Thread pool ID"
                            },
                            "count": {
                                "type": "integer",
                                "minimum": 1,
                                "default": 32,
                                "description": "Number of script pool threads"
                            },
                            "priority": {
                                "type": "integer",
                                "minimum": -20,
                                "maximum": 19,
                                "default": 0,
                                "description": "The thread priority (nice) value"
                            },
                            "concurrency": {
                                "type": "integer",
                                "minimum": 1,
                                "description": "Number of scripts running using cooperative multitasking"
                            },
                            "stacksize": {
                                "oneOf": [
                                    {
                                        "type": "integer",
                                        "minimum": 1,
                                        "default": 2097152,
                                        "description": "Script stacksize (in bytes)"
                                    },
                                    {
                                        "$ref": "#/definitions/byteformat",
                                        "description": "Script stacksize (in byte format)"
                                    }
                                ]
                            }
                        }
                    }
                },
                "events": {
                    "type": "array",
                    "uniqueItems": true,
                    "description": "A list of event thread pools",
                    "items": {
                        "type": "object",
                        "required": [
                            "id"
                        ],
                        "additionalProperties": false,
                        "properties": {
                            "id": {
                                "$ref": "#/definitions/objectid",
                                "description": "Thread pool ID"
                            },
                            "count": {
                                "type": "integer",
                                "minimum": 1,
                                "default": 4,
                                "description": "Number of event pool threads"
                            },
                            "priority": {
                                "type": "integer",
                                "minimum": -20,
                                "maximum": 19,
                                "default": 0,
                                "description": "The thread priority (nice) value"
                            }
                        }
                    }
                }
            }
        },
        "scripting": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "ffi": {
                    "type": "boolean",
                    "description": "Allow use of the FFI functions",
                    "default": false
                },
                "rootpath": {
                    "type": "string",
                    "description": "File root path for file access"
                },
                "cache": {
                    "type": "object",
                    "description": "Scripting cache [] settings",
                    "additionalProperties": false,
                    "properties": {
                        "scope": {
                            "type": "string",
                            "enum": [
                                "global",
                                "config"
                            ],
                            "default": "config",
                            "description": "The scope of the cache"
                        }
                    }
                }
            }
        },
        "resolver": {
            "type": "object",
            "description": "DNS resolver settings",
            "additionalProperties": false,
            "properties": {
                "threads": {
                    "type": "object",
                    "description": "Thread pool settings",
                    "additionalProperties": false,
                    "properties": {
                        "event": {
                            "type": "integer",
                            "minimum": 1,
                            "default": 1,
                            "description": "Number of event loop threads"
                        }
                    }
                },
                "ednsbuffersize": {
                    "type": "integer",
                    "default": 1280,
                    "description": "The EDNS buffer size"
                }
            }
        },
        "spool": {
            "type": "object",
            "additionalProperties": false,
            "anyOf": [
                {
                    "not": {
                        "required": [
                            "path",
                            "paths"
                        ]
                    }
                },
                {
                    "required": [
                        "path"
                    ],
                    "not": {
                        "required": [
                            "paths"
                        ]
                    }
                },
                {
                    "required": [
                        "paths"
                    ],
                    "not": {
                        "required": [
                            "path"
                        ]
                    }
                }
            ],
            "properties": {
                "path": {
                    "type": "string",
                    "default": "/var/spool/halon/queue",
                    "description": "Mail spool path"
                },
                "paths": {
                    "type": "array",
                    "uniqueItems": true,
                    "description": "Mail spool paths",
                    "items": {
                        "type": "object",
                        "required": [
                            "path"
                        ],
                        "additionalProperties": false,
                        "properties": {
                            "path": {
                                "type": "string",
                                "description": "Mail spool path"
                            },
                            "write": {
                                "type": "boolean",
                                "default": true,
                                "description": "Use this path to write new mail"
                            }
                        }
                    }
                },
                "minfree": {
                    "type": "object",
                    "description": "Minimum free requirements on the spool disk",
                    "additionalProperties": false,
                    "properties": {
                        "inodes": {
                            "type": "integer",
                            "minimum": 0,
                            "description": "Number of free inodes"
                        },
                        "bytes": {
                            "oneOf": [
                                {
                                    "type": "integer",
                                    "minimum": 0,
                                    "description": "Number of free bytes"
                                },
                                {
                                    "$ref": "#/definitions/byteformat",
                                    "description": "Number of free bytes (in byte format)"
                                }
                            ]
                        }
                    }
                },
                "fsync": {
                    "type": "boolean",
                    "default": true,
                    "description": "Commits queued messages to storage device, necessary for transaction safety and durability"
                },
                "loader": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                        "threads": {
                            "type": "object",
                            "description": "Thread pool settings",
                            "additionalProperties": false,
                            "properties": {
                                "count": {
                                    "type": "integer",
                                    "minimum": 1,
                                    "default": 32,
                                    "description": "Number of loader threads"
                                },
                                "priority": {
                                    "type": "integer",
                                    "minimum": -20,
                                    "maximum": 19,
                                    "default": 0,
                                    "description": "The thread priority (nice) value"
                                }
                            }
                        },
                        "wait": {
                            "type": "boolean",
                            "default": true,
                            "description": "Wait for spool in to finish"
                        },
                        "rate": {
                            "description": "The maximum rate too spool in messages from disk during startup",
                            "oneOf": [
                                {
                                    "type": "string",
                                    "pattern": "^[0-9]+(/[0-9]+(\\.[0-9]+)?)?$",
                                    "minLength": 1
                                },
                                {
                                    "type": "number",
                                    "minimum": 1
                                }
                            ]
                        },
                        "corrupt": {
                            "type": "string",
                            "enum": [
                                "unlink",
                                "rename",
                                "ignore"
                            ],
                            "default": "unlink",
                            "description": "The default action on corrupt queue files"
                        }
                    }
                },
                "update": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                        "threads": {
                            "type": "object",
                            "description": "Thread pool settings",
                            "additionalProperties": false,
                            "properties": {
                                "count": {
                                    "type": "integer",
                                    "minimum": 1,
                                    "default": 32,
                                    "description": "Number of update threads"
                                },
                                "priority": {
                                    "type": "integer",
                                    "minimum": -20,
                                    "maximum": 19,
                                    "default": 0,
                                    "description": "The thread priority (nice) value"
                                }
                            }
                        },
                        "background": {
                            "type": "object",
                            "description": "Background update settings",
                            "additionalProperties": false,
                            "properties": {
                                "threads": {
                                    "type": "object",
                                    "description": "Thread pool settings",
                                    "additionalProperties": false,
                                    "properties": {
                                        "count": {
                                            "type": "integer",
                                            "minimum": 1,
                                            "default": 2,
                                            "description": "Number of update threads"
                                        },
                                        "priority": {
                                            "type": "integer",
                                            "minimum": -20,
                                            "maximum": 19,
                                            "default": 0,
                                            "description": "The thread priority (nice) value"
                                        }
                                    }
                                },
                                "rate": {
                                    "description": "The maximum rate too update messages during bulk updates",
                                    "oneOf": [
                                        {
                                            "type": "string",
                                            "pattern": "^[0-9]+(/[0-9]+(\\.[0-9]+)?)?$",
                                            "minLength": 1
                                        },
                                        {
                                            "type": "number",
                                            "minimum": 1
                                        }
                                    ]
                                }
                            }
                        }
                    }
                },
                "rate": {
                    "description": "The maximum rate too spool in messages from disk during startup",
                    "oneOf": [
                        {
                            "type": "string",
                            "pattern": "^[0-9]+(/[0-9]+(\\.[0-9]+)?)?$",
                            "minLength": 1
                        },
                        {
                            "type": "number",
                            "minimum": 1
                        }
                    ]
                },
                "corrupt": {
                    "type": "string",
                    "enum": [
                        "unlink",
                        "rename",
                        "ignore"
                    ],
                    "default": "unlink",
                    "description": "The default action on corrupt queue files"
                },
                "threads": {
                    "type": "object",
                    "description": "Thread pool settings",
                    "additionalProperties": false,
                    "properties": {
                        "loader": {
                            "oneOf": [
                                {
                                    "type": "integer",
                                    "minimum": 1,
                                    "default": 32,
                                    "description": "Number of loader threads"
                                },
                                {
                                    "type": "object",
                                    "additionalProperties": false,
                                    "properties": {
                                        "count": {
                                            "type": "integer",
                                            "minimum": 1,
                                            "default": 32,
                                            "description": "Number of loader threads"
                                        },
                                        "priority": {
                                            "type": "integer",
                                            "minimum": -20,
                                            "maximum": 19,
                                            "default": 0,
                                            "description": "The thread priority (nice) value"
                                        },
                                        "wait": {
                                            "type": "boolean",
                                            "default": true,
                                            "description": "Wait for spool in to finish"
                                        }
                                    }
                                }
                            ]
                        },
                        "update": {
                            "type": "integer",
                            "minimum": 1,
                            "default": 32,
                            "description": "Number of update threads"
                        }
                    }
                }
            }
        },
        "environment": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "syslog": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                        "ident": {
                            "type": "string",
                            "description": "Syslog identity"
                        },
                        "pid": {
                            "type": "boolean",
                            "default": false,
                            "description": "Log with pid"
                        },
                        "mask": {
                            "type": "number",
                            "description": "Mask log levels"
                        },
                        "facility": {
                            "oneOf": [
                                {
                                    "type": "string",
                                    "enum": [
                                        "daemon",
                                        "mail",
                                        "user",
                                        "local0",
                                        "local1",
                                        "local2",
                                        "local3",
                                        "local4",
                                        "local5",
                                        "local6",
                                        "local7"
                                    ],
                                    "default": "mail",
                                    "description": "Log facility"
                                },
                                {
                                    "type": "integer",
                                    "description": "Numeric log facility"
                                }
                            ]
                        }
                    }
                },
                "controlsocket": {
                    "oneOf": [
                        {
                            "type": "object",
                            "markdownDescription": "[Control socket](https://docs.halon.io/manual/archive/master/comp_install.html#control-sockets) ([Protocol Buffers](https://docs.halon.io/go/protobufschemas))",
                            "description": "Control socket (Protocol Buffers)",
                            "additionalProperties": false,
                            "properties": {
                                "path": {
                                    "type": "string",
                                    "default": "/var/run/halon/smtpd.ctl",
                                    "description": "Socket path"
                                },
                                "owner": {
                                    "type": "string",
                                    "description": "Socket owner"
                                },
                                "group": {
                                    "type": "string",
                                    "description": "Socket group"
                                },
                                "chmod": {
                                    "$ref": "#/definitions/mode",
                                    "description": "Socket chmod"
                                },
                                "backlog": {
                                    "type": "integer",
                                    "maximum": 65535,
                                    "minimum": 1,
                                    "description": "Listen backlog"
                                },
                                "logging": {
                                    "type": "object",
                                    "description": "The logging related settings",
                                    "additionalProperties": false,
                                    "properties": {
                                        "audit": {
                                            "type": "boolean",
                                            "default": true,
                                            "description": "Enable audit logging"
                                        }
                                    }
                                }
                            }
                        },
                        {
                            "type": "object",
                            "markdownDescription": "[Control socket](https://docs.halon.io/manual/archive/master/comp_install.html#control-sockets) ([Protocol Buffers](https://docs.halon.io/go/protobufschemas))",
                            "description": "Control socket (Protocol Buffers)",
                            "additionalProperties": false,
                            "required": [
                                "port"
                            ],
                            "properties": {
                                "port": {
                                    "type": "integer",
                                    "maximum": 65535,
                                    "minimum": 1,
                                    "description": "Port number"
                                },
                                "address": {
                                    "description": "IP address",
                                    "anyOf": [
                                        {
                                            "$ref": "#/definitions/ipv4"
                                        },
                                        {
                                            "$ref": "#/definitions/ipv6"
                                        }
                                    ]
                                },
                                "backlog": {
                                    "type": "integer",
                                    "maximum": 65535,
                                    "minimum": 1,
                                    "description": "Listen backlog"
                                },
                                "logging": {
                                    "type": "object",
                                    "description": "The logging related settings",
                                    "additionalProperties": false,
                                    "properties": {
                                        "audit": {
                                            "type": "boolean",
                                            "default": true,
                                            "description": "Enable audit logging"
                                        }
                                    }
                                },
                                "tls": {
                                    "type": "object",
                                    "additionalProperties": false,
                                    "required": [
                                        "cert"
                                    ],
                                    "oneOf": [
                                        {
                                            "required": [
                                                "clientcerts"
                                            ]
                                        },
                                        {
                                            "required": [
                                                "clientnames"
                                            ]
                                        }
                                    ],
                                    "properties": {
                                        "cert": {
                                            "$ref": "#/definitions/objectid",
                                            "description": "The key ID"
                                        },
                                        "client": {
                                            "type": "object",
                                            "additionalProperties": false,
                                            "required": [
                                                "certificate",
                                                "privatekey"
                                            ],
                                            "properties": {
                                                "certificate": {
                                                    "oneOf": [
                                                        {
                                                            "type": "object",
                                                            "additionalProperties": false,
                                                            "required": [
                                                                "data"
                                                            ],
                                                            "properties": {
                                                                "data": {
                                                                    "type": "string",
                                                                    "minLength": 1,
                                                                    "description": "The PKCS #8 PEM data"
                                                                }
                                                            }
                                                        },
                                                        {
                                                            "type": "object",
                                                            "additionalProperties": false,
                                                            "required": [
                                                                "path"
                                                            ],
                                                            "properties": {
                                                                "path": {
                                                                    "type": "string",
                                                                    "minLength": 1,
                                                                    "description": "The PKCS #8 PEM path"
                                                                }
                                                            }
                                                        }
                                                    ]
                                                },
                                                "privatekey": {
                                                    "oneOf": [
                                                        {
                                                            "type": "object",
                                                            "additionalProperties": false,
                                                            "required": [
                                                                "data"
                                                            ],
                                                            "properties": {
                                                                "data": {
                                                                    "type": "string",
                                                                    "minLength": 1,
                                                                    "description": "The private key data"
                                                                }
                                                            }
                                                        },
                                                        {
                                                            "type": "object",
                                                            "additionalProperties": false,
                                                            "required": [
                                                                "path"
                                                            ],
                                                            "properties": {
                                                                "path": {
                                                                    "type": "string",
                                                                    "minLength": 1,
                                                                    "description": "The private key path"
                                                                }
                                                            }
                                                        }
                                                    ]
                                                },
                                                "verify": {
                                                    "type": "boolean",
                                                    "description": "Verify remote peer",
                                                    "default": true
                                                },
                                                "verifyname": {
                                                    "type": "string",
                                                    "description": "Hostname to verify against"
                                                }
                                            }
                                        },
                                        "cacerts": {
                                            "type": "array",
                                            "uniqueItems": true,
                                            "description": "List of CA to trust",
                                            "items": {
                                                "oneOf": [
                                                    {
                                                        "type": "object",
                                                        "additionalProperties": false,
                                                        "required": [
                                                            "data"
                                                        ],
                                                        "properties": {
                                                            "data": {
                                                                "type": "string",
                                                                "minLength": 1,
                                                                "description": "The PKCS #8 PEM path"
                                                            }
                                                        }
                                                    },
                                                    {
                                                        "type": "object",
                                                        "additionalProperties": false,
                                                        "required": [
                                                            "path"
                                                        ],
                                                        "properties": {
                                                            "path": {
                                                                "type": "string",
                                                                "minLength": 1,
                                                                "description": "The PKCS #8 PEM path"
                                                            }
                                                        }
                                                    }
                                                ]
                                            }
                                        },
                                        "crls": {
                                            "type": "array",
                                            "uniqueItems": true,
                                            "description": "List of CRLs",
                                            "items": {
                                                "oneOf": [
                                                    {
                                                        "type": "object",
                                                        "additionalProperties": false,
                                                        "required": [
                                                            "data"
                                                        ],
                                                        "properties": {
                                                            "data": {
                                                                "type": "string",
                                                                "minLength": 1,
                                                                "description": "The PKCS #8 PEM path"
                                                            }
                                                        }
                                                    },
                                                    {
                                                        "type": "object",
                                                        "additionalProperties": false,
                                                        "required": [
                                                            "path"
                                                        ],
                                                        "properties": {
                                                            "path": {
                                                                "type": "string",
                                                                "minLength": 1,
                                                                "description": "The PKCS #8 PEM path"
                                                            }
                                                        }
                                                    }
                                                ]
                                            }
                                        },
                                        "clientcerts": {
                                            "type": "array",
                                            "uniqueItems": true,
                                            "description": "List of clientcertificates to allow",
                                            "items": {
                                                "oneOf": [
                                                    {
                                                        "type": "object",
                                                        "additionalProperties": false,
                                                        "required": [
                                                            "data"
                                                        ],
                                                        "properties": {
                                                            "data": {
                                                                "type": "string",
                                                                "minLength": 1,
                                                                "description": "The PKCS #8 PEM path"
                                                            }
                                                        }
                                                    },
                                                    {
                                                        "type": "object",
                                                        "additionalProperties": false,
                                                        "required": [
                                                            "path"
                                                        ],
                                                        "properties": {
                                                            "path": {
                                                                "type": "string",
                                                                "minLength": 1,
                                                                "description": "The PKCS #8 PEM path"
                                                            }
                                                        }
                                                    }
                                                ]
                                            }
                                        },
                                        "clientnames": {
                                            "type": "array",
                                            "uniqueItems": true,
                                            "description": "List of clientcertificates names to allow (supports wildcards, eg. .example.com)",
                                            "items": {
                                                "type": "string"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    ]
                },
                "privdrop": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                        "user": {
                            "type": "string",
                            "description": "Privdrop user"
                        },
                        "group": {
                            "type": "string",
                            "description": "Privdrop group"
                        }
                    }
                },
                "appconf": {
                    "type": "string",
                    "default": "/etc/halon/smtpd-app.yaml",
                    "markdownDescription": "[Running configuration](https://docs.halon.io/manual/archive/master/config_smtpd.html) path",
                    "description": "Running configuration path"
                },
                "policyconf": {
                    "type": "string",
                    "default": "/etc/halon/smtpd-policy.yaml",
                    "description": "Active queue policy configuration path"
                },
                "suspendconf": {
                    "type": "string",
                    "default": "/etc/halon/smtpd-suspend.yaml",
                    "description": "Active queue suspend configuration path"
                },
                "deliveryconf": {
                    "type": "string",
                    "default": "/etc/halon/smtpd-delivery.yaml",
                    "description": "Delivery configuration path"
                },
                "pluginspath": {
                    "type": "string",
                    "default": "/etc/halon/plugins",
                    "description": "The path to search for plugins"
                },
                "licensekey": {
                    "type": "string",
                    "default": "/etc/halon/license.key",
                    "description": "The license key path"
                },
                "publicsuffix": {
                    "type": "string",
                    "default": "/usr/share/publicsuffix/public_suffix_list.dat",
                    "description": "Path to public_suffix_list.dat used for DMARC etc"
                },
                "umask": {
                    "$ref": "#/definitions/mode",
                    "description": "The umask to use after privdrop"
                },
                "rlimit": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                        "nofile": {
                            "type": "number",
                            "description": "Max number of open file descriptors"
                        },
                        "nice": {
                            "type": "integer",
                            "minimum": -20,
                            "maximum": 19,
                            "default": 0,
                            "description": "Lowest priority (nice) value of a thread"
                        }
                    }
                },
                "uuid": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                        "version": {
                            "type": "number",
                            "enum": [
                                1,
                                4
                            ],
                            "default": 1,
                            "description": "UUID version"
                        }
                    }
                }
            }
        },
        "cluster": {
            "type": "object",
            "description": "Cluster service settings",
            "additionalProperties": false,
            "properties": {
                "address": {
                    "anyOf": [
                        {
                            "$ref": "#/definitions/ipv4"
                        },
                        {
                            "$ref": "#/definitions/ipv6"
                        },
                        {
                            "$ref": "#/definitions/domain"
                        }
                    ],
                    "description": "The cluster address"
                },
                "port": {
                    "type": "integer",
                    "maximum": 65535,
                    "minimum": 1,
                    "default": 2530,
                    "description": "The cluster port number"
                },
                "policy": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                        "sharedconcurrency": {
                            "type": "boolean",
                            "description": "Apply a shared concurrency (this is the opposite of evenly divide)",
                            "default": true
                        }
                    }
                },
                "tls": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                        "id": {
                            "$ref": "#/definitions/objectid",
                            "description": "The x509 privatekey (used as client certificate)"
                        },
                        "verify": {
                            "type": "boolean",
                            "description": "Verify remote peer",
                            "default": true
                        },
                        "verifyname": {
                            "type": "string",
                            "description": "Hostname to verify against"
                        }
                    }
                },
                "startup": {
                    "type": "object",
                    "additionalProperties": false,
                    "description": "Startup settings related to the cluster service",
                    "properties": {
                        "hosts": {
                            "type": "integer",
                            "minimum": 1,
                            "description": "Start with an assumed number of hosts instead of exiting if cluster service is down"
                        }
                    }
                }
            }
        },
        "monitor": {
            "type": "object",
            "description": "Monitoring interface settings",
            "additionalProperties": false,
            "required": [
                "listener"
            ],
            "properties": {
                "type": {
                    "enum": [
                        "http",
                        "https"
                    ],
                    "default": "http"
                },
                "listener": {
                    "description": "The IP address and port to listen on. If no IP address is specificed it will bind to any (both IPv4 and IPv6)",
                    "oneOf": [
                        {
                            "type": "object",
                            "required": [
                                "port"
                            ],
                            "additionalProperties": false,
                            "properties": {
                                "port": {
                                    "type": "integer",
                                    "maximum": 65535,
                                    "minimum": 1,
                                    "description": "Port number"
                                },
                                "address": {
                                    "description": "IP address",
                                    "anyOf": [
                                        {
                                            "$ref": "#/definitions/ipv4"
                                        },
                                        {
                                            "$ref": "#/definitions/ipv6"
                                        }
                                    ]
                                },
                                "backlog": {
                                    "type": "integer",
                                    "maximum": 65535,
                                    "minimum": 1,
                                    "description": "Listen backlog"
                                }
                            }
                        },
                        {
                            "type": "object",
                            "required": [
                                "path"
                            ],
                            "additionalProperties": false,
                            "properties": {
                                "path": {
                                    "type": "string",
                                    "description": "Socket path"
                                },
                                "owner": {
                                    "type": "string",
                                    "description": "Socket owner"
                                },
                                "group": {
                                    "type": "string",
                                    "description": "Socket group"
                                },
                                "chmod": {
                                    "$ref": "#/definitions/mode",
                                    "description": "Socket chmod"
                                },
                                "backlog": {
                                    "type": "integer",
                                    "maximum": 65535,
                                    "minimum": 1,
                                    "description": "Listen backlog"
                                }
                            }
                        }
                    ]
                }
            }
        }
    },
    "definitions": {
        "objectid": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9-_.]+$",
            "minLength": 1,
            "maxLength": 64
        },
        "mode": {
            "type": "string",
            "pattern": "^[0-7][0-7][0-7][0-7]$",
            "minLength": 4,
            "maxLength": 4
        },
        "ipv4": {
            "type": "string",
            "pattern": "^(?!(?:\/.*\/|#.*|.*[*].*)$)(?:(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])(\\.(?!$)|$)){4}$",
            "minLength": 7
        },
        "ipv4net": {
            "type": "string",
            "pattern": "^(?!(?:\/.*\/|#.*|.*[*].*)$)(?:(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])(\\.(?!$)|\/[0-9]+$)){4}$",
            "minLength": 9
        },
        "ipv6": {
            "type": "string",
            "pattern": "^(?!(?:\/.*\/|#.*|.*[*].*)$)(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$",
            "minLength": 3
        },
        "ipv6net": {
            "type": "string",
            "pattern": "^(?!(?:\/.*\/|#.*|.*[*].*)$)(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/[0-9]+$",
            "minLength": 3
        },
        "domain": {
            "type": "string",
            "pattern": "^(?!(?:\/.*\/|#.*|.*[*].*)$)[a-zA-Z0-9_.-]+$",
            "minLength": 1
        },
        "byteformat": {
            "type": "string",
            "pattern": "^([0-9]+)(B|KiB|MiB|GiB|TiB)$",
            "minLength": 2
        }
    }
}