修改
This commit is contained in:
parent
b5c9643f33
commit
97cd8e0bc7
@ -46,14 +46,13 @@ func CaCheck(c *gin.Context) {
|
|||||||
cache = &pcache
|
cache = &pcache
|
||||||
}
|
}
|
||||||
|
|
||||||
info := new(RedirectInfo)
|
|
||||||
info.ori_req = c.Copy()
|
|
||||||
|
|
||||||
if !strings.HasSuffix(action, "S") {
|
if !strings.HasSuffix(action, "S") {
|
||||||
CaForward(info)
|
CaForward(c, "", "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
info := new(RedirectInfo)
|
||||||
|
info.ori_req = c
|
||||||
info.sigtime = f5.GetApp().GetRealSeconds()
|
info.sigtime = f5.GetApp().GetRealSeconds()
|
||||||
info.trace_id = fmt.Sprintf("%x%02x-%s", info.sigtime, len(*cache), accountId)
|
info.trace_id = fmt.Sprintf("%x%02x-%s", info.sigtime, len(*cache), accountId)
|
||||||
info.sig = q5.Md5Str(c.Request.URL.RawQuery + info.trace_id)
|
info.sig = q5.Md5Str(c.Request.URL.RawQuery + info.trace_id)
|
||||||
@ -133,7 +132,7 @@ func CheckRedirect() {
|
|||||||
|
|
||||||
if req != nil {
|
if req != nil {
|
||||||
redirectRequest.Store(account, req)
|
redirectRequest.Store(account, req)
|
||||||
CaForward(req)
|
CaForward(req.ori_req, req.sig, req.trace_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(requests) == 0 {
|
if len(requests) == 0 {
|
||||||
|
@ -9,22 +9,22 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CaForward(c *RedirectInfo) {
|
func CaForward(c *gin.Context, sig string, traceid string) {
|
||||||
|
|
||||||
queryParams := c.ori_req.Request.URL.Query()
|
queryParams := c.Request.URL.Query()
|
||||||
params := map[string]string{}
|
params := map[string]string{}
|
||||||
for k, v := range queryParams {
|
for k, v := range queryParams {
|
||||||
params[k] = v[0]
|
params[k] = v[0]
|
||||||
}
|
}
|
||||||
if c.sig != "" {
|
if sig != "" {
|
||||||
params["sig"] = c.sig
|
params["sig"] = sig
|
||||||
params["trace_id"] = c.trace_id
|
params["trace_id"] = traceid
|
||||||
}
|
}
|
||||||
|
|
||||||
fullrequrl := mt.Table.Config.GetById(0).GetRedirectUrl() + c.ori_req.Request.URL.Path
|
fullrequrl := mt.Table.Config.GetById(0).GetRedirectUrl() + c.Request.URL.Path
|
||||||
cb := func(rsp f5.HttpCliResponse) {
|
cb := func(rsp f5.HttpCliResponse) {
|
||||||
if rsp.GetErr() != nil {
|
if rsp.GetErr() != nil {
|
||||||
c.ori_req.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"errcode": 1004,
|
"errcode": 1004,
|
||||||
"errmsg": rsp.GetErr(),
|
"errmsg": rsp.GetErr(),
|
||||||
})
|
})
|
||||||
@ -32,10 +32,10 @@ func CaForward(c *RedirectInfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fmt.Println("saved ori context:", c.ori_req)
|
// fmt.Println("saved ori context:", c.ori_req)
|
||||||
c.ori_req.JSON(http.StatusOK, rsp.GetRawData())
|
c.JSON(http.StatusOK, rsp.GetRawData())
|
||||||
}
|
}
|
||||||
|
|
||||||
switch c.ori_req.Request.Method {
|
switch c.Request.Method {
|
||||||
case "GET":
|
case "GET":
|
||||||
f5.GetHttpCliMgr().SendGoStyleRequest(
|
f5.GetHttpCliMgr().SendGoStyleRequest(
|
||||||
fullrequrl,
|
fullrequrl,
|
||||||
@ -45,15 +45,15 @@ func CaForward(c *RedirectInfo) {
|
|||||||
f5.GetHttpCliMgr().SendGoStylePost(
|
f5.GetHttpCliMgr().SendGoStylePost(
|
||||||
fullrequrl,
|
fullrequrl,
|
||||||
params,
|
params,
|
||||||
c.ori_req.ContentType(),
|
c.ContentType(),
|
||||||
q5.GetPostBody(c.ori_req.Request),
|
q5.GetPostBody(c.Request),
|
||||||
cb)
|
cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.sig != "" {
|
if sig != "" {
|
||||||
account := c.ori_req.DefaultQuery("account_id", "")
|
account := c.DefaultQuery("account_id", "")
|
||||||
v, exist := redirectRequest.Load(account)
|
v, exist := redirectRequest.Load(account)
|
||||||
if exist && (*v).trace_id == c.trace_id {
|
if exist && (*v).trace_id == traceid {
|
||||||
redirectRequest.Delete(account)
|
redirectRequest.Delete(account)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user