授權規則

獲取授權規則列表

URI

GET /admin-api/socks5_proxy/{id}/auth_rules

URI 引數

  • detail

    type: integer

    required: no

    description: 獲取詳細的 DNS 應用資訊

  • page

    type: integer

    required: no

    description: 第幾頁,從 1 開始

  • page_size

    type: integer

    required: no

    description: 每頁大小,預設 20

請求示例

Shell

curl http://{admin-site}/admin-api/socks5_proxy/3/auth_rules?page=1&page_size=20&detail=1

響應示例

Status: 200 OK
{
    "data": [
        {
            "_modified_unix": 1621832319.6485,
            "dst_type": "-",
            "lua": "local _M = {}\n\n--[[\n  Entry point of Lua rule\n  @config: config of socks5 application\n  @rule: socks5 rule that includes this Lua code\n  return: true, false, nil and error message\n]]\nfunction _M.run(config, rule)\n  -- do something\n  return true\nend\n\nreturn _M",
            "start_time": 1621832280,
            "id": 2,
            "rule_type": "basic",
            "dst": [
                "-"
            ],
            "src_type": "-",
            "bandwidth": 30,
            "enabled": true,
            "type": "permit",
            "end_time": 1621832280,
            "src": [
                "-"
            ],
            "_created_unix": 1621832319.6485,
            "order": 0
        }
    ],
    "status": 0
}

新增授權規則

URI

POST /admin-api/socks5_proxy/{id}/auth_rules

JSON Body 引數

  • enabled

    type: boolean

    required: no

    description: 啟用/禁用

  • type

    type: string

    required: yes

    description: 動作型別,permit 或 deny

  • rule_type

    type: string

    required: yes

    description: 規則型別,lua 或 basic

  • bandwidth

    type: integer

    required: yes

    description: 頻寬

  • start_time

    type: integer

    required: yes

    description: 規則有效起始時間

  • end_time

    type: integer

    required: yes

    description: 規則有效結束時間

  • dst_port

    type: integer

    required: no

    description: 目標埠

  • src

    type: string

    required: yes

    description: 源

  • dst

    type: string

    required: yes

    description: 目標

請求示例

Shell

curl -X POST http://{admin-site}/admin-api/socks5_proxy/{id}/auth_rules -d
'
{
    "enabled": true,
    "type": "permit",
    "rule_type": "basic",
    "lua": "local _M = {}\n\n--[[\n  Entry point of Lua rule\n  @config: config of socks5 application\n  @rule: socks5 rule that includes this Lua code\n  return: true, false, nil and error message\n]]\nfunction _M.run(config, rule)\n  -- do something\n  return true\nend\n\nreturn _M",
    "src": [
        "-"
    ],
    "dst": [
        "-"
    ],
    "bandwidth": 30,
    "src_type": "-",
    "dst_type": "-",
    "start_time": 1621832280,
    "end_time": 1621832280,
    "dst_port": null
}
'

響應示例

Status: 200 OK
{
    "status": 0,
    "data": {
        "id": 1
    }
}

修改授權規則

URI

PUT /admin-api/socks5_proxy/{id}/auth_rules/{id}

JSON Body 引數

  • enabled

    type: boolean

    required: no

    description: 啟用/禁用

  • type

    type: string

    required: yes

    description: 動作型別,permit 或 deny

  • rule_type

    type: string

    required: yes

    description: 規則型別,lua 或 basic

  • bandwidth

    type: integer

    required: yes

    description: 頻寬

  • start_time

    type: integer

    required: yes

    description: 規則有效起始時間

  • end_time

    type: integer

    required: yes

    description: 規則有效結束時間

  • dst_port

    type: integer

    required: no

    description: 目標埠

  • src

    type: string

    required: yes

    description: 源

  • dst

    type: string

    required: yes

    description: 目標

請求示例

Shell

curl -X PUT http://{admin-site}/admin-api/socks5_proxy/{id}/auth_rules/{id} -d
'{
    "data": [
        {
            "_modified_unix": 1621838858.0789,
            "dst_type": "-",
            "lua": "local _M = {}\n\n--[[\n  Entry point of Lua rule\n  @config: config of socks5 application\n  @rule: socks5 rule that includes this Lua code\n  return: true, false, nil and error message\n]]\nfunction _M.run(config, rule)\n  -- do something\n  return true\nend\n\nreturn _M",
            "start_time": 1621832280,
            "id": 2,
            "rule_type": "basic",
            "dst": [
                "-"
            ],
            "src_type": "-",
            "bandwidth": 301,
            "enabled": true,
            "type": "permit",
            "end_time": 1621832280,
            "src": [
                "-"
            ],
            "_created_unix": 1621832319.6485,
            "order": 0
        }
    ],
    "status": 0
}
'

響應示例

Status: 200 OK
{
    "status": 0
}

刪除授權規則

URI

DELETE /admin-api/socks5_proxy/{id}/auth_rules/{id}

請求示例

Shell

curl -X DELETE http://{admin-site}/admin-api/socks5_proxy/{id}/auth_rules/{id}

響應示例

Status: 200 OK
{
    "status": 0
}