DDOS实例
更新时间:2025-05-15
查询DDoS基础防护列表
- 查询用户账户下所有公网IP基础防护信息
- 支持按公网IP地址和公网IP类型筛选查询
- 结果支持marker分页,分页大小默认为1000,可通过maxKeys参数指定
函数声明
Go
1type ListDdosRequest struct {
2 Ips string `json:"-"`
3 Type string `json:"-"`
4 Marker string `json:"-"`
5 MaxKeys int32 `json:"-"`
6}
7
8type ListDdosResponse struct {
9 DdosList *[]DdosModel `json:"ddosList,omitempty"`
10 Marker string `json:"marker,omitempty"`
11 IsTruncated bool `json:"isTruncated,omitempty"`
12 NextMarker string `json:"nextMarker,omitempty"`
13 MaxKeys int32 `json:"maxKeys,omitempty"`
14}
15
16type DdosModel struct {
17 Ip string `json:"ip,omitempty"`
18 Status string `json:"status,omitempty"`
19 BindInstanceType string `json:"bindInstanceType,omitempty"`
20 BindInstanceId string `json:"bindInstanceId,omitempty"`
21 IpCleanMbps int64 `json:"ipCleanMbps,omitempty"`
22 IpCleanPps int64 `json:"ipCleanPps,omitempty"`
23 ThresholdType string `json:"thresholdType,omitempty"`
24 MaximumThreshold int64 `json:"maximumThreshold,omitempty"`
25}
26
27func (c *Client) ListDdos(request *ListDdosRequest) (*ListDdosResponse, error)
参数含义
请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/Jlhag6ez3
返回值
操作成功:
JSON
1{
2 "marker": "x.x.x.x",
3 "maxKeys": 1000,
4 "nextMarker": "",
5 "isTruncated": false,
6 "ddosList": [
7 {
8 "ip": "x.x.x.x",
9 "status": "available",
10 "bindInstanceType": "BCC",
11 "bindInstanceId": "i-IyWRtII8",
12 "bindInstanceName": "xxx",
13 "ipCleanMbps": 200,
14 "ipCleanPps": 100000,
15 "thresholdType": "bandwidth",
16 "maximumThreshold": 5
17 },
18 ...
19 ]
20}
操作失败:
抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4
代码示例
具体代码示例参考:example_ddos_list_ddos.go
查询DDoS基础防护攻击列表
- 查询指定公网IP DDoS基础防护攻击记录
函数声明
Go
1type ListDdosAttackRecordRequest struct {
2 Ip string `json:"-"`
3 StartTime string `json:"-"`
4 Marker string `json:"-"`
5 MaxKeys int32 `json:"-"`
6}
7
8type ListDdosAttackRecordResponse struct {
9 AttackRecordList *[]DdosAttackRecordModel `json:"attackRecordList,omitempty"`
10}
11
12type DdosAttackRecordModel struct {
13 Ip string `json:"ip,omitempty"`
14 StartTime string `json:"startTime,omitempty"`
15 EndTime string `json:"endTime,omitempty"`
16 AttackType []string `json:"attackType,omitempty"`
17 AttackPeakMbps int64 `json:"attackPeakMbps,omitempty"`
18 AttackPeakPps int64 `json:"attackPeakPps,omitempty"`
19 AttackPeakQps int64 `json:"attackPeakQps,omitempty"`
20 AttackStatus string `json:"attackStatus,omitempty"`
21}
22
23func (c *Client) ListDdosAttackRecord(request *ListDdosAttackRecordRequest) (*ListDdosAttackRecordResponse, error)
参数含义
请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/tlhaglzfn
返回值
操作成功:
JSON
1{
2 "marker": "123456",
3 "maxKeys": 1000,
4 "nextMarker": "",
5 "isTruncated": false,
6 "attackRecordList": [
7 {
8 "ip": "x.x.x.x",
9 "startTime": "2022-11-06T04:34:49Z",
10 "endTime": "2022-11-16T04:34:49Z",
11 "attackType": [
12 "ATTACK_TYPE_CONNECTION"
13 ],
14 "attackPeakMbps": 801.89
15 "attackPeakPps": xxx,
16 "attackPeakQps": xxx
17 },
18 ...
19 ]
20}
操作失败:
抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4
代码示例
具体代码示例参考:example_ddos_list_ddos_attack_record.go
修改DDoS基础防护阈值
- 修改指定公网IP防护阈值
函数声明
Go
1type ModifyDdosThresholdRequest struct {
2 Ip string `json:"-"`
3 ClientToken string `json:"-"`
4 ThresholdType string `json:"thresholdType"`
5 IpCleanMbps int64 `json:"ipCleanMbps"`
6 IpCleanPps int64 `json:"ipCleanPps"`
7}
8
9func (c *Client) ModifyDdosThreshold(request *ModifyDdosThresholdRequest) error
参数含义
请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/alhagbhi0
返回值
操作成功:
无特殊返回参数
操作失败:
抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4
代码示例