Skip to content

Commit

Permalink
fix: 放开更多iptv相关参数,可自定义配置
Browse files Browse the repository at this point in the history
  • Loading branch information
super321 committed Dec 22, 2024
1 parent eb58ea8 commit 4519a17
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 28 deletions.
24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,32 @@ IPTV工具,功能列表如下:
"interfaceName": "",
"serverHost": "182.138.3.142:8082",
"ip": "",
"x-requested-with": "",
"userID": "",
"lang": "",
"netUserId": "",
"stbType": "",
"stbVersion": "",
"conntype": "",
"stbID": "",
"templateName": "",
"areaId": "",
"userGroupId": "",
"productPackageId": "",
"mac": "",
"userField": "",
"softwareVersion": "",
"x-requested-with": ""
"isSmartStb": ""
}
```

| 字段 | 说明 |
|---------------|----------------------------------------------------------------------------------------------------|
| key | 不是Authenticator,而是生成Authenticator的秘钥,每个IPTV机顶盒可能都不同,可通过工具根据某次抓包获取的Authenticator反向破解key,具体见下面的使用介绍。 |
| interfaceName | 设备的网络接口名称,和ip字段二选一,优先使用该字段的值。当工具运行在软路由上时,可通过配置自动获取指定接口的IPv4地址。用于获取软路由上某接口被自动分配的IPTV线路的IP地址。 |
| serverHost | 工具请求的IPTV服务器地址,注意需要走IPTV专用网络才能访问通。 |
| ip | 客户端的ip,可任意配置,生成Authenticator所需。当interfaceName已配置时,优先通过interfaceName获取。 |
| 其他字段 | 均可通过抓包获取注意x-requested-with可通过抓包HTTP请求头拿到 |
| 字段 | 说明 |
|---------------|----------------------------------------------------------------------------------------------------------------------------|
| key | 不是Authenticator,而是生成Authenticator的秘钥,每个IPTV机顶盒可能都不同,可通过工具根据某次抓包获取的Authenticator反向破解key,具体见下面的使用介绍。 |
| interfaceName | 设备的网络接口名称,和ip字段二选一,优先使用该字段的值。当工具运行在软路由上时,可通过配置自动获取指定接口的IPv4地址。用于获取软路由上某接口被自动分配的IPTV线路的IP地址。 |
| serverHost | 工具请求的IPTV服务器地址,注意需要走IPTV专用网络才能访问通。 |
| ip | 客户端的ip,可任意配置,生成Authenticator所需。当interfaceName已配置时,优先通过interfaceName获取。 |
| 其他字段 | 均可通过抓包获取注意x-requested-with可通过抓包HTTP请求头拿到)。 必填字段:userID,stbType,stbVersion,conntype,stbID,templateName,mac,softwareVersion |

### 使用介绍

Expand Down
16 changes: 8 additions & 8 deletions internal/app/iptv/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,23 +156,23 @@ func (c *Client) validAuthenticationHWCTC(ctx context.Context, encryptToken stri
// 组装请求数据
data := map[string]string{
"UserID": c.config.UserID,
"Lang": "",
"Lang": c.config.Lang,
"SupportHD": "1",
"NetUserID": "",
"NetUserID": c.config.NetUserID,
"Authenticator": authenticator,
"STBType": c.config.STBType,
"STBVersion": c.config.STBVersion,
"conntype": "dhcp",
"conntype": c.config.Conntype,
"STBID": c.config.STBID,
"templateName": "ftth",
"templateName": c.config.TemplateName,
"areaId": c.config.AreaId,
"userToken": encryptToken,
"userGroupId": "",
"productPackageId": "",
"userGroupId": c.config.UserGroupId,
"productPackageId": c.config.ProductPackageId,
"mac": c.config.MAC,
"UserField": "",
"UserField": c.config.UserField,
"SoftwareVersion": c.config.SoftwareVersion,
"IsSmartStb": "",
"IsSmartStb": c.config.IsSmartStb,
"desktopId": "",
"stbmaker": "",
"XMPPCapability": "",
Expand Down
33 changes: 23 additions & 10 deletions internal/app/iptv/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,26 @@ type Config struct {
Key string `json:"key"` // 8位数字,加密Authenticator的秘钥,每个机顶盒可能都不同,获取频道列表必须使用
InterfaceName string `json:"interfaceName"` // 网络接口的名称。若配置则生成Authenticator时,优先使用该接口对应的IPv4地址,而不使用`ip`字段的值。
// 以下信息均可通过抓包获取
ServerHost string `json:"serverHost"` // HTTP请求的服务器地址端口
IP string `json:"ip"` // 生成Authenticator所需的IP地址。可随便一个地址,或者通过配置`interfaceName`动态获取
UserID string `json:"userID"`
STBType string `json:"stbType"`
STBVersion string `json:"stbVersion"`
STBID string `json:"stbID"` // 机顶盒背面可查
AreaId string `json:"areaId"`
MAC string `json:"mac"` // 机顶盒背面可查
SoftwareVersion string `json:"softwareVersion"`
XRequestedWith string `json:"x-requested-with"` // HTTP请求时需要携带的请求头,可抓包查看
ServerHost string `json:"serverHost"` // HTTP请求的服务器地址端口
IP string `json:"ip"` // 生成Authenticator所需的IP地址。可随便一个地址,或者通过配置`interfaceName`动态获取
// HTTP请求时需要携带的请求头,找不到可不填写
XRequestedWith string `json:"x-requested-with,omitempty"`
// 以下信息均可通过抓包请求ValidAuthenticationHWCTC.jsp的参数拿到
UserID string `json:"userID"`
Lang string `json:"lang,omitempty"` // 如果没有可以不填
NetUserID string `json:"netUserId,omitempty"` // 如果没有可以不填
STBType string `json:"stbType"`
STBVersion string `json:"stbVersion"`
Conntype string `json:"conntype"`
STBID string `json:"stbID"` // 机顶盒背面也可查
TemplateName string `json:"templateName"`
AreaId string `json:"areaId"`
UserGroupId string `json:"userGroupId,omitempty"`
ProductPackageId string `json:"productPackageId,omitempty"`
MAC string `json:"mac"` // 机顶盒背面也可查
UserField string `json:"userField,omitempty"`
SoftwareVersion string `json:"softwareVersion"`
IsSmartStb string `json:"isSmartStb,omitempty"`
}

func (c *Config) Validate() error {
Expand All @@ -28,10 +38,13 @@ func (c *Config) Validate() error {
c.UserID == "" ||
c.STBType == "" ||
c.STBVersion == "" ||
c.Conntype == "" ||
c.STBID == "" ||
c.TemplateName == "" ||
c.MAC == "" ||
c.SoftwareVersion == "" {
return errors.New("invalid IPTV Client config")
}

return nil
}
2 changes: 0 additions & 2 deletions internal/app/iptv/iptv.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,5 @@ func (c *Client) setCommonHeaders(req *http.Request) {
req.Header.Set("Accept-Language", "zh-CN,en-US;q=0.8")
if c.config.XRequestedWith != "" {
req.Header.Set("X-Requested-With", c.config.XRequestedWith)
} else {
req.Header.Set("X-Requested-With", "com.fiberhome.iptv")
}
}

0 comments on commit 4519a17

Please sign in to comment.