{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "proxies": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "port": {
            "type": "integer",
            "description": "Port for the HTTP proxy"
          },
          "proxy_type": {
            "type": "string",
            "enum": ["persist", "duplicate"],
            "description": "Set to 'persist' to save proxy into the configuration file"
          },
          "multiply": {
            "type": "integer",
            "description": "Multiply the port definition given number of times"
          },
          "multiply_ips": {
            "type": "boolean",
            "description": "Create a proxy port for every selected IP from the pool"
          },
          "multiply_vips": {
            "type": "boolean",
            "description": "Create a proxy port for every selected gIP"
          },
          "multiply_users": {
            "type": "boolean",
            "description": "Create a proxy port for every selected user"
          },
          "users": {
            "type": "array",
            "items": {"type": "string"},
            "description": "List of users (use with multiply_users)"
          },
          "ssl": {
            "type": "boolean",
            "description": "Enable SSL analyzing"
          },
          "tls_lib": {
            "type": "string",
            "enum": ["open_ssl", "flex_tls"],
            "description": "SSL library"
          },
          "flex_tls_reject_unauthorized": {
            "type": "boolean",
            "description": "Ignore SSL certificate verification failures"
          },
          "av_check": {
            "type": "boolean",
            "description": "Enable antivirus check"
          },
          "av_server_url": {
            "type": "string",
            "description": "Antivirus server URL"
          },
          "iface": {
            "type": "string",
            "description": "Interface or IP to listen on"
          },
          "zone": {
            "type": "string",
            "description": "Zone name"
          },
          "password": {
            "type": "string",
            "description": "Zone password"
          },
          "proxy": {
            "type": "string",
            "description": "Hostname or IP of super proxy"
          },
          "proxy_port": {
            "type": "integer",
            "description": "Super proxy port"
          },
          "new_proxy_port": {
            "type": "boolean",
            "description": "Use new proxy port 33335"
          },
          "proxy_connection_type": {
            "type": "string",
            "enum": ["http", "https", "socks"],
            "description": "Connection type to Super Proxy"
          },
          "proxy_retry": {
            "type": "integer",
            "description": "Retry count on super proxy failure"
          },
          "proxy_country": {
            "type": "string",
            "description": "Super Proxy location"
          },
          "insecure": {
            "type": "boolean",
            "description": "Enable SSL to insecure hosts"
          },
          "country": {
            "type": "string",
            "description": "Target country"
          },
          "state": {
            "type": "string",
            "description": "Target state"
          },
          "city": {
            "type": "string",
            "description": "Target city"
          },
          "zip": {
            "type": "string",
            "description": "Target zip code"
          },
          "asn": {
            "type": "string",
            "description": "Target ASN"
          },
          "carrier": {
            "type": "string",
            "description": "Target carrier"
          },
          "ip": {
            "type": "string",
            "description": "Data Center IP"
          },
          "vip": {
            "type": "integer",
            "description": "gIP"
          },
          "ips": {
            "type": "array",
            "items": {"type": "string"},
            "description": "List of IPs"
          },
          "ext_proxies": {
            "type": "array",
            "items": {"type": "string"},
            "description": "External proxies [username:password@]ip[:port]"
          },
          "ext_proxy_username": {
            "type": "string",
            "description": "Default username for external proxies"
          },
          "ext_proxy_password": {
            "type": "string",
            "description": "Default password for external proxies"
          },
          "ext_proxy_port": {
            "type": "integer",
            "description": "Default port for external proxies"
          },
          "dns": {
            "type": "string",
            "enum": ["local", "remote"],
            "description": "DNS resolving location"
          },
          "reverse_lookup_dns": {
            "type": "boolean",
            "description": "Reverse DNS lookup via DNS"
          },
          "reverse_lookup_file": {
            "type": "string",
            "description": "Reverse DNS lookup via file"
          },
          "reverse_lookup_values": {
            "type": "array",
            "items": {"type": "string"},
            "description": "Reverse DNS lookup values"
          },
          "session": {
            "type": ["string", "boolean"],
            "pattern": "^[^.\\-]*$",
            "description": "Session ID for requests"
          },
          "sticky_ip": {
            "type": "boolean",
            "description": "Session per requesting host"
          },
          "pool_size": {
            "type": "integer",
            "description": "Session pool size"
          },
          "rotate_session": {
            "type": "boolean",
            "description": "Rotate IPs on each request"
          },
          "throttle": {
            "type": ["integer", "string"],
            "description": "Throttle concurrent requests"
          },
          "route_err": {
            "type": "string",
            "enum": ["pass_dyn", "block"],
            "description": "Route errors through super proxy or block"
          },
          "smtp": {
            "type": "array",
            "items": {"type": "string"},
            "description": "SMTP proxy IPs"
          },
          "override_headers": {
            "type": "boolean",
            "description": "Override request headers"
          },
          "os": {
            "type": "string",
            "description": "Target OS"
          },
          "headers": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {"type": "string"},
                "value": {"type": "string"}
              },
              "required": ["name", "value"],
              "additionalProperties": false
            },
            "description": "Custom request headers"
          },
          "debug": {
            "type": "string",
            "enum": ["full", "none"],
            "description": "Request debug info"
          },
          "lpm_auth": {
            "type": "string",
            "description": "x-lpm-authorization header"
          },
          "const": {
            "type": "boolean",
            "description": "Keep same session on tunnel errors"
          },
          "max_ban_retries": {
            "type": "integer",
            "description": "Maximum retries for banned IPs"
          },
          "preset": {
            "type": "string",
            "description": "Preset configuration"
          },
          "ua": {
            "type": ["boolean", "string"],
            "description": "Unblocker Mobile UA"
          },
          "timezone": {
            "type": "string",
            "description": "Browser timezone ID"
          },
          "resolution": {
            "type": "string",
            "description": "Browser screen size"
          },
          "webrtc": {
            "type": "string",
            "description": "WebRTC behavior"
          },
          "bw_limit": {
            "type": "object",
            "properties": {
              "days": {
                "type": "integer",
                "description": "Renewal period in days"
              },
              "bytes": {
                "type": "integer",
                "description": "Bandwidth limit in bytes"
              },
              "renewable": {
                "type": "boolean",
                "description": "Renew limit each period"
              }
            },
            "additionalProperties": false,
            "description": "Bandwidth limit configuration"
          },
          "follow_redirect": {
            "type": "boolean",
            "description": "Auto redirect on 30x"
          },
          "render": {
            "type": "boolean",
            "description": "Process scripts from HTML"
          },
          "internal_name": {
            "type": "string",
            "description": "Internal name for this port"
          },
          "whitelist_ips": {
            "type": "array",
            "items": {"type": "string"},
            "description": "Whitelist IPs for this port"
          },
          "info": {
            "type": "boolean",
            "description": "Include destination IP in responses"
          },
          "session_termination": {
            "type": "boolean",
            "description": "Stop requests when peer IP unavailable"
          },
          "rules": {
            "type": "array",
            "description": "Proxy request rules",
            "items": {
              "type": "object",
              "additionalProperties": true,
              "properties": {
                "type": {
                  "type": "string",
                  "enum": ["before_send", "after_hdr", "after_body", "timeout"],
                  "description": "When the rule is evaluated"
                },
                "trigger_type": {
                  "type": "string",
                  "enum": ["url", "status", "body", "min_req_time", "max_req_time", "min_conn_time"],
                  "description": "Trigger condition type"
                },
                "trigger_code": {
                  "type": "string",
                  "description": "JavaScript function code for trigger"
                },
                "url": {
                  "type": "string",
                  "description": "URL regex pattern"
                },
                "domain": {
                  "type": "boolean",
                  "description": "Apply regex only to domain"
                },
                "status": {
                  "type": ["string", "integer"],
                  "description": "Status code or regex"
                },
                "body": {
                  "type": "string",
                  "description": "Response body regex"
                },
                "min_req_time": {
                  "type": "integer",
                  "description": "Minimum request time (ms)"
                },
                "max_req_time": {
                  "type": "integer",
                  "description": "Maximum request time (ms)"
                },
                "min_conn_time": {
                  "type": "integer",
                  "description": "Minimum connection time (ms)"
                },
                "action_type": {
                  "type": "string",
                  "enum": ["retry", "retry_same", "retry_port", "ban_ip", "ban_ip_global", 
                           "ban_ip_domain", "refresh_ip", "save_to_pool", "reserve_session",
                           "null_response", "timeout_response", "bypass_proxy", "cache", 
                           "direct", "request_url"],
                  "description": "Action to execute"
                },
                "action": {
                  "type": "object",
                  "additionalProperties": true,
                  "properties": {
                    "retry": {
                      "type": ["boolean", "integer"],
                      "description": "Retry or max retry count"
                    },
                    "retry_same": {
                      "type": "boolean",
                      "description": "Retry with same IP"
                    },
                    "retry_port": {
                      "type": "integer",
                      "description": "Port for retry"
                    },
                    "retries": {
                      "type": "integer",
                      "description": "Max retries override"
                    },
                    "silent": {
                      "type": "boolean",
                      "description": "Silent retry"
                    },
                    "ban_ip": {
                      "type": "integer",
                      "description": "Ban duration (ms, 0=forever)"
                    },
                    "ban_ip_global": {
                      "type": "integer",
                      "description": "Global ban duration (ms)"
                    },
                    "ban_ip_domain": {
                      "type": "integer",
                      "description": "Per-domain ban duration (ms)"
                    },
                    "refresh_ip": {
                      "type": "boolean",
                      "description": "Refresh Data Center IP"
                    },
                    "reserve_session": {
                      "type": "boolean",
                      "description": "Save IP to pool"
                    },
                    "null_response": {
                      "type": "boolean",
                      "description": "Return null response"
                    },
                    "timeout_response": {
                      "type": "boolean",
                      "description": "Return 504 timeout"
                    },
                    "bypass_proxy": {
                      "type": "boolean",
                      "description": "Direct to target"
                    },
                    "direct": {
                      "type": "boolean",
                      "description": "Through super proxy only"
                    },
                    "cache": {
                      "type": "boolean",
                      "description": "Cache response"
                    },
                    "request_url": {
                      "type": "object",
                      "properties": {
                        "url": {
                          "type": "string",
                          "description": "Target URL"
                        },
                        "method": {
                          "type": "string",
                          "enum": ["GET", "POST", "PUT", "DELETE"],
                          "description": "HTTP method"
                        },
                        "payload": {
                          "type": "object",
                          "description": "Request payload (supports $IP substitution)"
                        }
                      },
                      "required": ["url"],
                      "additionalProperties": false,
                      "description": "Request URL action configuration"
                    }
                  },
                  "description": "Action configuration object"
                },
                "active": {
                  "type": "boolean",
                  "description": "Enable/disable rule"
                }
              }
            }
          }
        }
      }
    },
    "_defaults": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "zone": {
          "type": "string",
          "description": "Default zone name"
        },
        "password": {
          "type": "string",
          "description": "Default zone password"
        },
        "token_auth": {
          "type": "string",
          "description": "Token authentication"
        },
        "lpm_token": {
          "type": "string",
          "description": "LPM authorization token"
        },
        "customer": {
          "type": "string",
          "description": "Customer name"
        },
        "customer_id": {
          "type": "string",
          "description": "Customer ID"
        },
        "account_id": {
          "type": "string",
          "description": "Account ID"
        },
        "whitelist_ips": {
          "type": "array",
          "items": {"type": "string"},
          "description": "Default whitelist IPs for all proxies"
        },
        "www_whitelist_ips": {
          "type": "array",
          "items": {"type": "string"},
          "description": "Whitelist IPs for admin UI access"
        },
        "extra_ssl_ips": {
          "type": "array",
          "items": {"type": "string"},
          "description": "Extra IPs for SSL certificate"
        },
        "logs": {
          "type": "integer",
          "description": "Number of request logs to store"
        },
        "logs_settings": {
          "type": "object",
          "description": "Remote logs delivery settings"
        },
        "har_limit": {
          "type": "integer",
          "description": "Bytes to store in HAR"
        },
        "debug": {
          "type": "string",
          "enum": ["full", "none"],
          "description": "Request debug info"
        },
        "lpm_auth": {
          "type": "string",
          "enum": ["full", "none"],
          "description": "x-lpm-authorization header behavior"
        },
        "log": {
          "type": "string",
          "enum": ["error", "warn", "notice", "info", "debug"],
          "description": "Log level"
        },
        "request_stats": {
          "type": "boolean",
          "description": "Enable request statistics"
        },
        "test_url": {
          "type": "string",
          "description": "URL for proxy testing"
        },
        "dropin": {
          "type": "boolean",
          "description": "Enable dropin mode proxy"
        },
        "dropin_port": {
          "type": "integer",
          "description": "Dropin mode port"
        },
        "session_termination": {
          "type": "boolean",
          "description": "Stop requests when peer IP unavailable"
        },
        "reverse_lookup_dns": {
          "type": "boolean",
          "description": "Reverse DNS lookup"
        },
        "local_login": {
          "type": "boolean",
          "description": "Require browser authentication"
        },
        "read_only": {
          "type": "boolean",
          "description": "Prevent config file saves"
        },
        "sync_config": {
          "type": "boolean",
          "description": "Sync config with cloud"
        },
        "sync_zones": {
          "type": "boolean",
          "description": "Sync zones with cloud"
        },
        "sync_stats": {
          "type": "boolean",
          "description": "Sync statistics with cloud"
        },
        "bw_limit_webhook_url": {
          "type": "string",
          "description": "BW limit webhook URL"
        },
        "bw_th_webhook_url": {
          "type": "string",
          "description": "BW threshold webhook URL"
        },
        "api_body_limit": {
          "type": "string",
          "description": "Max request body size"
        },
        "api_parameter_limit": {
          "type": "integer",
          "description": "Max URL parameters"
        },
        "socket_inactivity_timeout": {
          "type": "integer",
          "description": "Socket timeout (ms)"
        },
        "google_token": {
          "type": "string",
          "description": "Google auth token"
        },
        "version": {
          "type": "string",
          "description": "Config version"
        },
        "ask_sync_config": {
          "type": "boolean",
          "description": "Ask about config sync"
        }
      }
    },
    "ts": {
      "type": "integer",
      "description": "Configuration timestamp"
    }
  }
}
