网络查询
计算 IPv4 或 IPv6 CIDR 地址范围
POST
/cidr公开访问
访问类别:匿名 API,可携带 Token 使用独立额度
请求体
application/jsoncidr必填- string · IPv4 使用四段十进制;IPv6 不带区域标识;省略前缀时表示单个地址 · 最短:1 字符 · 最长:128 字符
响应
200 计算结果
application/json
{
"type": "object",
"properties": {
"version": {
"type": "string",
"enum": [
"IPv4",
"IPv6"
]
},
"address": {
"type": "string"
},
"network": {
"type": "string"
},
"prefix": {
"type": "integer",
"minimum": 0,
"maximum": 128
},
"mask": {
"type": "string"
},
"first": {
"type": "string"
},
"last": {
"type": "string"
},
"broadcast": {
"type": [
"string",
"null"
]
},
"total": {
"type": "string",
"pattern": "^\\d+$"
},
"hosts": {
"type": "string",
"pattern": "^\\d+$"
}
},
"required": [
"version",
"address",
"network",
"prefix",
"mask",
"first",
"last",
"broadcast",
"total",
"hosts"
]
}400 请求校验或执行失败
application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}401 凭据无效、停用、过期或缺少所需 Token
application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}403 需要管理员 Token
application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}413 请求校验或执行失败
application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}415 请求校验或执行失败
application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}429 请求过于频繁,Retry-After 为建议等待秒数;匿名额度及认证保护在各 Cloudflare 地点近似计数,Token 业务额度使用 D1 原子计数
application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}500 内部执行失败
application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}响应示例
运行命令前,将环境变量 BASE_URL 设置为站点地址。
成功响应
printf '%s' '{"cidr":"192.168.1.9/24"}' | curl --silent --show-error -X POST -H 'User-Agent: simpleWebUtils-example/1.1.0' -H 'Content-Type: application/json' -H 'Accept: application/json' "$BASE_URL"'/cidr' --data-binary @-HTTP 200
content-type: application/json
content-encoding: gzip
cache-control: no-store
{
"version": "IPv4",
"address": "192.168.1.9",
"network": "192.168.1.0",
"prefix": 24,
"mask": "255.255.255.0",
"first": "192.168.1.0",
"last": "192.168.1.255",
"broadcast": "192.168.1.255",
"total": "256",
"hosts": "254"
}错误示例
printf '%s' '{}' | curl --silent --show-error -X POST -H 'User-Agent: simpleWebUtils-example/1.1.0' -H 'Content-Type: application/json' -H 'Accept: application/json' "$BASE_URL"'/cidr' --data-binary @-HTTP 400
content-type: application/json
content-encoding: gzip
cache-control: no-store
{
"error": {
"code": "INVALID_INPUT",
"message": "参数无效",
"issues": [
{
"location": "body",
"field": "cidr",
"code": "invalid_type",
"message": "需要 字符串 类型"
}
]
}
}在线调试
调用示例
curl -X POST 'https://oit.sh/cidr' \
-H 'Content-Type: application/json' \
--data-raw '{"cidr":"192.168.1.9/24"}'响应
等待发送请求
配置上方请求参数后点击「发送请求」查看实时响应
快捷键:Ctrl / ⌘ + Enter