github.com/qiniu/go-sdk/v7@v7.27.0/pili/domain_model.go (about)

     1  package pili
     2  
     3  // GetDomainsListRequest 查询域名列表请求参数
     4  type GetDomainsListRequest struct {
     5  	// Hub 直播空间
     6  	Hub string `json:"-" validate:"required"`
     7  }
     8  
     9  // GetDomainsListResponse 查询域名列表返回值
    10  type GetDomainsListResponse struct {
    11  	// Domains 域名列表
    12  	Domains []GetDomainsListItem `json:"domains"`
    13  }
    14  
    15  // GetDomainsListItem 查询域名列表项
    16  type GetDomainsListItem struct {
    17  	// Type 域名类型
    18  	Type string `json:"type"`
    19  
    20  	// Domain 域名
    21  	Domain string `json:"domain"`
    22  
    23  	// Cname CNAME
    24  	Cname string `json:"cname"`
    25  
    26  	// CertEnable 是否配置 SSL 证书
    27  	CertEnable bool `json:"certEnable"`
    28  
    29  	// CertName 证书名称
    30  	CertName string `json:"certName"`
    31  }
    32  
    33  // GetDomainInfoRequest 查询域名信息请求参数
    34  type GetDomainInfoRequest struct {
    35  	// Hub 直播空间
    36  	Hub string `json:"-" validate:"required"`
    37  
    38  	// Domain 域名
    39  	Domain string `json:"-" validate:"required"`
    40  }
    41  
    42  // GetDomainInfoResponse 查询域名信息返回值
    43  type GetDomainInfoResponse struct {
    44  	// Domain 域名
    45  	Domain string `json:"domain"`
    46  
    47  	// Type 域名类型
    48  	Type string `json:"type"`
    49  
    50  	// Cname CNAME
    51  	Cname string `json:"cname"`
    52  
    53  	// ConnectCallback 开播回调配置
    54  	ConnectCallback DomainCallbackConfig `json:"connectCallback"`
    55  
    56  	// DisconnectCallback 断播回调配置
    57  	DisconnectCallback DomainCallbackConfig `json:"disconnectCallback"`
    58  
    59  	// IPLimit IP 访问限制
    60  	IPLimit DomainIPLimit `json:"ipLimit"`
    61  
    62  	// PlaySecurity 时间戳防盗链配置
    63  	PlaySecurity DomainPlaySecurity `json:"playSecurity"`
    64  
    65  	// DisconnectDelay 断流延迟配置
    66  	// 单位:秒,针对直播流短时间内闪断重连的情况,不触发断流回调,避免因为短时间内频繁断流造成大量回调
    67  	DisconnectDelay int64 `json:"disconnectDelay"`
    68  
    69  	// UrlRewrite URL 改写规则
    70  	UrlRewrite DomainUrlRewrite `json:"urlRewrite"`
    71  
    72  	// CertEnable 是否配置 SSL 证书
    73  	CertEnable bool `json:"certEnable"`
    74  
    75  	// CertName 证书名称
    76  	CertName string `json:"certName"`
    77  
    78  	// Disable 域名是否为禁用状态
    79  	Disable bool `json:"disable"`
    80  }
    81  
    82  // DomainCallbackConfig 域名回调配置
    83  type DomainCallbackConfig struct {
    84  	// Type 回调类型
    85  	// 可选回调类型为
    86  	// - 留空: 不开启回调功能
    87  	// - GET: 发送GET请求回调,请求参数携带在query中
    88  	// - FORM: 发送POST请求回调,请求参数携带在body中,Content-Type 为 application/x-www-form-urlencoded
    89  	// - JSON: 发送POST请求回调,请求参数携带在body中,Content-Type 为 application/json
    90  	Type string `json:"type"`
    91  
    92  	// URL 回调地址
    93  	// 支持魔法变量
    94  	URL string `json:"url"`
    95  
    96  	// Timeout 超时时间
    97  	// 与回调地址的 HTTP 连接超时时间,单位:秒
    98  	// 默认值为 2 秒,配置范围为 0~10 秒
    99  	Timeout int64 `json:"timeout"`
   100  
   101  	// Vars 请求参数
   102  	// 支持魔法变量,至少需要一组请求参数,规则解析出错误的会设置成空字段
   103  	Vars map[string]string `json:"vars"`
   104  
   105  	// RetryTimes 重试次数
   106  	// 可选范围 0~5 次
   107  	RetryTimes int `json:"retryTimes"`
   108  
   109  	// RetryInterval 重试间隔
   110  	// 可选范围 0~5 秒,单位:秒
   111  	RetryInterval int `json:"retryInterval"`
   112  
   113  	// SuccessCode 回调成功的 http code
   114  	// 为 0 表示通配
   115  	SuccessCode int `json:"successCode"`
   116  
   117  	// FailCode 回调失败的 http code
   118  	// 为 0 表示通配,当 SuccessCode 不为 0 的情况下生效
   119  	FailCode int `json:"failCode"`
   120  }
   121  
   122  // DomainIPLimit IP 限制
   123  type DomainIPLimit struct {
   124  	// WhiteList 白名单
   125  	// 允许推拉流的 IP 列表,CIDR 类型
   126  	// 配置白名单后,黑名单列表将失效
   127  	WhiteList []string `json:"whitelist"`
   128  
   129  	// BlackList 黑名单
   130  	// 限制推拉流的 IP 列表,CIDR 类型
   131  	BlackList []string `json:"blacklist"`
   132  }
   133  
   134  // DomainUrlRewrite URL 改写规则配置
   135  type DomainUrlRewrite struct {
   136  	// Rules 规则列表
   137  	Rules []DomainUrlRewriteItem `json:"rules"`
   138  }
   139  
   140  // DomainUrlRewriteItem URL 改写规则项
   141  type DomainUrlRewriteItem struct {
   142  	// Pattern 匹配规则
   143  	Pattern string `json:"pattern"`
   144  
   145  	// Replace 改写规则
   146  	Replace string `json:"replace"`
   147  }
   148  
   149  // DomainPlaySecurity 时间戳防盗链配置
   150  type DomainPlaySecurity struct {
   151  	// Type 防盗链类型
   152  	// 可选防盗链类型为
   153  	// - 留空: 默认类型,表示继承直播空间级别配置
   154  	// - none: 表示关闭鉴权
   155  	// - tsStartMD5: 有效时间从 TsPart 表示的时间戳开始,到 Range 秒后截止
   156  	// - tsExpireMD5: 有效时间从现在当前到 TsPart 表示的时间戳为止
   157  	Type string `json:"type"`
   158  
   159  	// Key1 主密钥
   160  	Key1 string `json:"key1"`
   161  
   162  	// Key2 副密钥
   163  	// 两个密钥将同时生效,便于线上业务替换密钥
   164  	Key2 string `json:"key2"`
   165  
   166  	// Range 有效时间
   167  	// 当 Type 为 "tsStartMD5" 时生效,单位:秒
   168  	Range int `json:"range"`
   169  
   170  	// Rule 签名规则
   171  	// 支持魔法变量的规则,最终签算结果为所有变量的md5
   172  	// - $(key): 密钥
   173  	// - $(path): URL 中的 path 部分
   174  	// - $(streamKey): URL 中的 hub/stream 部分
   175  	// - $(streamTitle): URL 中的 stream 部分
   176  	// - $(path_<number>): URL 中的 path 部分,<number> 表示 path 层级
   177  	// - $(_<query>): URL 中的 query 字段,举例: key1=val,魔法变量中使用 $(_key1) 表示 val
   178  	// 举例:
   179  	// 配置Rule为: $(key)$(path)$(_t)
   180  	// 魔法变量替换完成后: key/hub/streamTitle1634745600
   181  	// 对结果进行md5计算,最终签算值为:3bc26fe6b35f5c7efab87778c5b27993
   182  	Rule string `json:"rule"`
   183  
   184  	// Rule2 签名规则 2
   185  	// 两个签名规则将同时生效,便于线上业务更换签名规则
   186  	Rule2 string `json:"rule2"`
   187  
   188  	// TsPart 时间戳字段
   189  	// URL中表示时间戳的字段名
   190  	TsPart string `json:"tsPart"`
   191  
   192  	// TsBase 时间戳进制
   193  	// 可选进制格式为 2-36,即 2 进制到 36 进制,默认使用16进制
   194  	TsBase int `json:"tsBase"`
   195  
   196  	// SignPart 签名字段
   197  	// URL中表示token的字段名
   198  	SignPart string `json:"signPart"`
   199  
   200  	// GapDuration 时间误差值
   201  	// 针对 tsExpireMD5 生效,避免因签算方与服务器本地时间误差造成的鉴权失败
   202  	GapDuration int `json:"gapDuration"`
   203  }
   204  
   205  // 域名类型
   206  const (
   207  	// DomainPublishRTMP 推流域名
   208  	DomainPublishRTMP = "publishRtmp"
   209  
   210  	// DomainLiveRTMP RTMP 播放域名
   211  	DomainLiveRTMP = "liveRtmp"
   212  
   213  	// DomainLiveHLS HLS 播放域名
   214  	DomainLiveHLS = "liveHls"
   215  
   216  	// DomainLiveHDL HDL 播放域名
   217  	DomainLiveHDL = "liveHdl"
   218  )
   219  
   220  // BindDomainRequest 绑定域名请求参数
   221  type BindDomainRequest struct {
   222  	// Hub 直播空间
   223  	Hub string `json:"-" validate:"required"`
   224  
   225  	// Domain 域名
   226  	Domain string `json:"domain" validate:"required"`
   227  
   228  	// Type 域名类型
   229  	// 可选域名类型为
   230  	// - publishRtmp: RTMP 推流域名
   231  	// - liveRtmp: RTMP 播放域名
   232  	// - liveHls: HLS 播放域名
   233  	// - liveHdl: HDL 播放域名
   234  	Type string `validate:"required,oneof=publishRtmp liveRtmp liveHls liveHdl"`
   235  }
   236  
   237  // UnbindDomainRequest 解绑域名请求参数
   238  type UnbindDomainRequest struct {
   239  	// Hub 直播空间
   240  	Hub string `json:"-" validate:"required"`
   241  
   242  	// Domain 域名
   243  	Domain string `json:"-" validate:"required"`
   244  }
   245  
   246  // BindVodDomainRequest 绑定点播域名请求参数
   247  type BindVodDomainRequest struct {
   248  	// Hub 直播空间
   249  	Hub string `json:"-" validate:"required"`
   250  
   251  	// VodDomain 点播域名
   252  	VodDomain string `json:"vodDomain" validate:"required"`
   253  }
   254  
   255  // SetDomainCertRequest 修改域名证书配置请求参数
   256  type SetDomainCertRequest struct {
   257  	// Hub 直播空间
   258  	Hub string `json:"-" validate:"required"`
   259  
   260  	// Domain 域名
   261  	Domain string `json:"-" validate:"required"`
   262  
   263  	// CertName 证书名称
   264  	// 需要将证书配置到七牛 CDN 服务中
   265  	// 证书配置地址: https://portal.qiniu.com/certificate/ssl
   266  	CertName string `json:"certName" validate:"required"`
   267  }
   268  
   269  // SetDomainURLRewriteRequest 修改域名改写规则配置请求参数
   270  type SetDomainURLRewriteRequest struct {
   271  	// Hub 直播空间
   272  	Hub string `json:"-" validate:"required"`
   273  
   274  	// Domain 域名
   275  	Domain string `json:"-" validate:"required"`
   276  
   277  	// Rules URL 改写规则列表
   278  	Rules []DomainURLRewriteRule `json:"rules" validate:"-"`
   279  }
   280  
   281  // DomainURLRewriteRule URL 改写规则
   282  type DomainURLRewriteRule struct {
   283  	// Pattern 匹配规则
   284  	// 针对完整URL的正则表达式,形式如:(.+)/live/(.+)/playlist.m3u8
   285  	// 括号中的内容允许在 Replace 中使用${n}引用(n表示括号顺序)
   286  	Pattern string `json:"pattern" validate:"required"`
   287  
   288  	// Replace 改写规则
   289  	// 希望得到的改写结果,形式如:${1}/hub/${2}.m3u8
   290  	// 改写后的URL应符合七牛的直播URL规范: <scheme>://<domain>/<hub>/<stream>[<ext>]?<query>
   291  	Replace string `json:"replace" validate:"required"`
   292  }