30 lines
757 B
Go
30 lines
757 B
Go
package main
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"time"
|
||
|
|
|
||
|
|
"chis_osi/config"
|
||
|
|
"chis_osi/osi"
|
||
|
|
)
|
||
|
|
|
||
|
|
// buildOSIClient 用配置里的 OSI 段组装带签名/代理的薄客户端,供验证入口与 server 模式复用。
|
||
|
|
func buildOSIClient(cfg config.Config) (*osi.Client, error) {
|
||
|
|
transport, err := osi.NewTransport(osi.TransportConfig{
|
||
|
|
Timeout: time.Duration(cfg.OSI.TimeoutSec) * time.Second,
|
||
|
|
Socks5Proxy: cfg.OSI.Socks5Proxy,
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
return osi.NewClient(osi.ClientConfig{
|
||
|
|
BaseURL: cfg.OSI.BaseURL,
|
||
|
|
OrgCode: cfg.OSI.OrgCode,
|
||
|
|
DeviceSN: cfg.OSI.DeviceSN,
|
||
|
|
UserName: cfg.OSI.UserName,
|
||
|
|
Ask: cfg.OSI.Ask,
|
||
|
|
OperateUser: cfg.OSI.OperateUser,
|
||
|
|
OperateUnit: cfg.OSI.OrgCode,
|
||
|
|
Transport: transport,
|
||
|
|
}), nil
|
||
|
|
}
|