198 lines
5.4 KiB
Markdown
198 lines
5.4 KiB
Markdown
# proxy.dll 使用教程
|
||
## 1.创建DLL工具实例
|
||
### 加载DLL文件
|
||
```gotemplate
|
||
// ProxyDLL 代理DLL结构
|
||
type proxyDLL struct {
|
||
dll *syscall.DLL
|
||
proxyTypeManager *syscall.Proc // 获取代理服务器
|
||
getMachineCode *syscall.Proc // 获取机器码
|
||
rechargeCard *syscall.Proc // 充值卡密
|
||
getProxies *syscall.Proc // 获取代理服务器
|
||
checkTailCardSecretExpired *syscall.Proc // 检查卡密是否过期
|
||
freeCString *syscall.Proc // 释放C字符串内存
|
||
}
|
||
|
||
// 初始化代理DLL
|
||
func InitProxyDLL() (*proxyDLL, error) {
|
||
dllPath := filepath.Join("dll", "proxy1.dll")
|
||
log.Printf("[DEBUG] 调用proxy.dll文件,文件路径: %s", dllPath)
|
||
if _, err := os.Stat(dllPath); os.IsNotExist(err) {
|
||
return nil, fmt.Errorf("proxy DLL 不存在: %s", dllPath)
|
||
}
|
||
if dll, err := syscall.LoadDLL(dllPath); err != nil {
|
||
return nil, fmt.Errorf("加载proxy DLL 失败: %s", err)
|
||
} else {
|
||
return &proxyDLL{
|
||
dll: dll,
|
||
proxyTypeManager: dll.MustFindProc("ProxyTypeManager"),
|
||
getMachineCode: dll.MustFindProc("GetMachineCode"),
|
||
rechargeCard: dll.MustFindProc("RechargeCard"),
|
||
getProxies: dll.MustFindProc("GetProxies"),
|
||
checkTailCardSecretExpired: dll.MustFindProc("CheckTailCardSecretExpired"),
|
||
freeCString: dll.MustFindProc("FreeCString"),
|
||
}, nil
|
||
}
|
||
}
|
||
|
||
// 函数调用
|
||
dll, err := InitProxyDLL()
|
||
if err != nil {
|
||
return "", err
|
||
}
|
||
```
|
||
|
||
### 获取C字符串
|
||
```gotemplate
|
||
// cStr 获取C字符串
|
||
func (m *kongfzDLL) cStr(p uintptr) string {
|
||
if p == 0 {
|
||
return ""
|
||
}
|
||
b := []byte{}
|
||
for i := uintptr(0); ; i++ {
|
||
c := *(*byte)(unsafe.Pointer(p + i))
|
||
if c == 0 {
|
||
break
|
||
}
|
||
b = append(b, c)
|
||
}
|
||
s := string(b)
|
||
if m.freeCString != nil {
|
||
m.freeCString.Call(p)
|
||
}
|
||
return s
|
||
}
|
||
```
|
||
|
||
## 2.使用dll函数示例
|
||
```gotemplate
|
||
// ProxyTypeManager 获取代理服务器
|
||
func (m *proxyDLL) ProxyTypeManager(proxyType, username, password, machineCode string) (string, error) {
|
||
proc, err := m.dll.FindProc("ProxyTypeManager")
|
||
if err != nil {
|
||
return "", fmt.Errorf("找不到函数 ProxyTypeManager: %v", err)
|
||
}
|
||
proxyTypePtr, _ := syscall.BytePtrFromString(proxyType)
|
||
usernamePtr, _ := syscall.BytePtrFromString(username)
|
||
passwordPtr, _ := syscall.BytePtrFromString(password)
|
||
machineCodePtr, _ := syscall.BytePtrFromString(machineCode)
|
||
info, _, err := proc.Call(
|
||
uintptr(unsafe.Pointer(proxyTypePtr)),
|
||
uintptr(unsafe.Pointer(usernamePtr)),
|
||
uintptr(unsafe.Pointer(passwordPtr)),
|
||
uintptr(unsafe.Pointer(machineCodePtr)))
|
||
if err != nil && err.Error() != "The operation completed successfully." {
|
||
return "", fmt.Errorf("调用函数 ProxyTypeManager 失败: %v", err)
|
||
}
|
||
return m.cStr(info), nil
|
||
}
|
||
```
|
||
|
||
# 接口详情
|
||
## 1.获取代理服务器--ProxyTypeManager
|
||
### 请求信息
|
||
```gotemplate
|
||
dll.ProxyTypeManager(proxyType, username, password, machineCode)
|
||
```
|
||
### 请求参数
|
||
| 参数名 | 类型 | 必填 | 说明 |
|
||
|--|--|--|-----------------------------------------------|
|
||
| proxyType | string | 是 | 代理类型 小象代理:CALF_ELEPHANT_PROXY 内置代理:TAIL_PROXY |
|
||
| username | string | 是 | 小象账号 |
|
||
| password | string | 是 | 小象密码 |
|
||
| machineCode | string | 是 | 内置代理机器码 |
|
||
### 响应示例
|
||
```
|
||
代理服务器字符串示例
|
||
http://18434270290:JWt15lWW@183.7.131.66:36806
|
||
```
|
||
|
||
## 2.查询机器码--GetMachineCode
|
||
### 请求信息
|
||
```gotemplate
|
||
dll.GetMachineCode(tailCardSecret)
|
||
```
|
||
### 请求参数
|
||
| 参数名 | 类型 | 必填 | 说明 |
|
||
|--|--|--|----|
|
||
| tailCardSecret | string | 是 | 卡密 |
|
||
### 响应示例
|
||
```json
|
||
{
|
||
"code": 200,
|
||
"message": "success",
|
||
"data": {
|
||
"machine_code": "07f4d0fbcff99966c2b37b0c1fb7f01c",
|
||
"ip_exp_time": "2025-12-12 10:35:06",
|
||
"ip_thread": 5,
|
||
"ip_card_code": "DL_5_TK_021c06ac87434a66a857a55baac28494"
|
||
}
|
||
}
|
||
```
|
||
|
||
## 3.充值卡密--RechargeCard
|
||
### 请求信息
|
||
```gotemplate
|
||
dll.RechargeCard(tailCardSecret,machineCode)
|
||
```
|
||
### 请求参数
|
||
| 参数名 | 类型 | 必填 | 说明 |
|
||
|--|--|--|-----|
|
||
| tailCardSecret | string | 是 | 卡密 |
|
||
| machineCode | string | 是 | 机器码 |
|
||
### 响应示例
|
||
```json
|
||
{
|
||
"success": true,
|
||
"message": "充值成功",
|
||
"machine_code": "e88c2c4210a2667866aab824cdfd2a9c"
|
||
}
|
||
```
|
||
|
||
## 4.获取代理服务器列表--GetProxies
|
||
### 请求信息
|
||
```gotemplate
|
||
dll.GetProxies(machineCode)
|
||
```
|
||
### 请求参数
|
||
| 参数名 | 类型 | 必填 | 说明 |
|
||
|--|--|--|-----|
|
||
| machineCode | string | 是 | 机器码 |
|
||
### 响应示例
|
||
```json
|
||
{
|
||
"success": true,
|
||
"count": 4,
|
||
"proxies": ["",""]
|
||
}
|
||
```
|
||
|
||
## 5.检查卡密是否过期--CheckTailCardSecretExpired
|
||
### 请求信息
|
||
```gotemplate
|
||
dll.CheckTailCardSecretExpired(tailCardSecret)
|
||
```
|
||
### 请求参数
|
||
| 参数名 | 类型 | 必填 | 说明 |
|
||
|--|--|--|----|
|
||
| tailCardSecret | string | 是 | 卡密 |
|
||
### 响应示例
|
||
```json
|
||
{
|
||
"is_valid": true,
|
||
"count": 4
|
||
}
|
||
```
|
||
|
||
## 6.释放C字符串内存--FreeCString
|
||
### 请求信息
|
||
```gotemplate
|
||
dll.FreeCString(str)
|
||
```
|
||
### 请求参数
|
||
| 参数名 | 类型 | 必填 | 说明 |
|
||
|--|--|--|----------|
|
||
| str | string | 是 | 需要释放的字符串 |
|
||
|