云算提交任务添加ip信息

This commit is contained in:
zhangwei 2025-02-17 21:53:56 +08:00
parent dea9e77de5
commit 1c7090ccb4
3 changed files with 5 additions and 4 deletions

View File

@ -7,6 +7,7 @@ import (
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
"k8s.io/apimachinery/pkg/util/json"
"net/http"
)
@ -20,8 +21,8 @@ func CommitGeneralTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return
}
// 获取ip信息
//ip := utils.GetClientIP(r)
//req.UserIp = ip
ip := utils.GetClientIP(r)
req.UserIp = ip
// 获取token信息
token := r.Header.Get("Authorization")
req.Token = token

View File

@ -140,7 +140,7 @@ func (l *CommitGeneralTaskLogic) CommitGeneralTask(req *types.GeneralTaskReq) er
return err
}
remoteUtil.Evidence(remoteUtil.EvidenceParam{
//UserIp: req.UserIp,
UserIp: req.UserIp,
Url: l.svcCtx.Config.BlockChain.Url,
ContractAddress: l.svcCtx.Config.BlockChain.ContractAddress,
FunctionName: l.svcCtx.Config.BlockChain.FunctionName,

View File

@ -20,7 +20,7 @@ func Evidence(EvidenceParam EvidenceParam) error {
fmt.Println("输出的user ip为" + EvidenceParam.UserIp)
httpClient := resty.New().R()
_, err := httpClient.SetHeader("Content-Type", "application/json").
//SetHeader("X-Forwarded-For", EvidenceParam.UserIp).
SetHeader("X-Forwarded-For", EvidenceParam.UserIp).
SetHeader("Authorization", EvidenceParam.Token).
SetBody(&EvidenceParam).
Post(EvidenceParam.Url)