{ "swagger": "2.0", "info": { "description": "iptables-helper 的 swagger", "title": "iptables-helper API", "termsOfService": "http://swagger.io/terms/", "contact": { "name": "Shikong", "email": "919411476@qq.com" }, "license": { "name": "Apache 2.0", "url": "http://www.apache.org/licenses/LICENSE-2.0.html" }, "version": "1.0" }, "basePath": "/", "paths": { "/if/info": { "get": { "description": "获取 网卡 信息", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Info" ], "summary": "获取 网卡 信息", "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/resp.Response" }, { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/definitions/net.InterfaceStat" } } } } ] } }, "default": { "description": "", "schema": { "$ref": "#/definitions/errorx.CodeErrorResponse" } } } } }, "/info": { "get": { "description": "获取 iptables 规则 信息", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Info" ], "summary": "获取 iptables 规则 信息", "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/resp.Response" }, { "type": "object", "properties": { "data": { "$ref": "#/definitions/iptables.Info" } } } ] } }, "default": { "description": "", "schema": { "$ref": "#/definitions/errorx.CodeErrorResponse" } } } } }, "/rule/add": { "post": { "description": "添加 iptables 规则", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Info" ], "summary": "添加 iptables 规则", "parameters": [ { "description": "规则", "name": "vo", "in": "body", "required": true, "schema": { "$ref": "#/definitions/iptables.Rule" } } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/resp.Response" }, { "type": "object", "properties": { "data": { "type": "string" } } } ] } }, "default": { "description": "", "schema": { "$ref": "#/definitions/errorx.CodeErrorResponse" } } } } }, "/rule/del/cmd": { "delete": { "description": "删除 iptables 规则", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Info" ], "summary": "删除 iptables 规则", "parameters": [ { "type": "string", "description": "根据 cmd 命令参数 删除指定规则", "name": "cmd", "in": "query", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/resp.Response" }, { "type": "object", "properties": { "data": { "type": "string" } } } ] } }, "default": { "description": "", "schema": { "$ref": "#/definitions/errorx.CodeErrorResponse" } } } } } }, "definitions": { "errorx.CodeErrorResponse": { "type": "object", "properties": { "code": { "description": "状态码", "type": "integer", "example": 200 }, "data": { "description": "数据" }, "msg": { "description": "信息", "type": "string", "example": "OK" } } }, "iptables.Info": { "type": "object", "properties": { "chains": { "type": "array", "items": { "type": "string" } }, "policies": { "type": "array", "items": { "$ref": "#/definitions/iptables.Policy" } }, "rules": { "type": "array", "items": { "$ref": "#/definitions/iptables.Rule" } } } }, "iptables.Policy": { "type": "object", "properties": { "name": { "type": "string" }, "target": { "type": "string" } } }, "iptables.Rule": { "type": "object", "properties": { "chain": { "type": "string" }, "cmd": { "type": "string" }, "destination": { "description": "-d [dest] example: 192.168.1.1, 192.168.1.0/24", "type": "string" }, "dstPort": { "description": "--dport example: 80", "type": "string" }, "dstPorts": { "description": "--dports example: 45000:46000", "type": "string" }, "excludeDestination": { "description": "! -d [source] example: 192.168.1.1, 192.168.1.0/24", "type": "string" }, "excludeInputInterface": { "description": "! -i [interface]", "type": "string" }, "excludeOutputInterface": { "description": "! -o [interface]", "type": "string" }, "excludeProtocol": { "description": "! -p [proto] example: all, tcp, udp, icmp", "type": "string" }, "excludeSource": { "description": "! -s [source] example: 192.168.1.1, 192.168.1.0/24", "type": "string" }, "goto": { "description": "-g [chain Chain]", "type": "string" }, "inputInterface": { "description": "-i [interface]", "type": "string" }, "jump": { "description": "-j [target Chain]", "type": "string" }, "limit": { "description": "--limit example: 3/min", "type": "string" }, "match": { "description": "-m [match] 用于匹配扩展模块 example: tcp udp icmp", "type": "string" }, "outputInterface": { "description": "-o [interface]", "type": "string" }, "protocol": { "description": "-p [proto] example: all, tcp, udp, icmp", "type": "string" }, "source": { "description": "-s [source] example: 192.168.1.1, 192.168.1.0/24", "type": "string" }, "srcPort": { "description": "--sport example: 22 80", "type": "string" }, "srcPorts": { "description": "--sports example: 20000:40000", "type": "string" } } }, "net.InterfaceAddr": { "type": "object", "properties": { "addr": { "type": "string" } } }, "net.InterfaceStat": { "type": "object", "properties": { "addrs": { "type": "array", "items": { "$ref": "#/definitions/net.InterfaceAddr" } }, "flags": { "description": "e.g., FlagUp, FlagLoopback, FlagMulticast", "type": "array", "items": { "type": "string" } }, "hardwareaddr": { "description": "IEEE MAC-48, EUI-48 and EUI-64 form", "type": "string" }, "index": { "type": "integer" }, "mtu": { "description": "maximum transmission unit", "type": "integer" }, "name": { "description": "e.g., \"en0\", \"lo0\", \"eth0.100\"", "type": "string" } } }, "resp.Response": { "type": "object", "properties": { "code": { "description": "状态码", "type": "integer", "example": 200 }, "data": { "description": "数据" }, "msg": { "description": "信息", "type": "string", "example": "OK" } } } } }