This commit is contained in:
suyl
2021-07-13 15:54:17 +08:00
parent 1690888782
commit 27655b80a5

View File

@@ -12,6 +12,7 @@ import (
"git.rosy.net.cn/jx-callback/globals"
"github.com/astaxie/beego/client/orm"
"github.com/astaxie/beego/server/web"
"net/http"
"net/url"
"reflect"
"strings"
@@ -249,7 +250,7 @@ func (c *ApiController) UpdatePrinter(dataMap map[string]interface{}) (data, err
printNo, name, sim, sound string
appID, volume int
)
globals.SugarLogger.Debugf("Begin API UpdatePrinter data: [%v]", utils.Format4Output(dataMap, false))
globals.SugarLogger.Debugf("Begin API UpdatePrinter data: [%v], ip: %v", utils.Format4Output(dataMap, false), getRealRemoteIP(c.Ctx.Request))
if _, ok := dataMap[keyPrintNo].(string); !ok {
return buildParamErrCodeAndErr(keyPrintNo)
} else {
@@ -377,3 +378,18 @@ func (c *ApiController) GetPrinterStatus(dataMap map[string]interface{}) (data,
}
return data, errCode, err
}
func getRealRemoteIP(r *http.Request) (ip string) {
if r != nil {
ip = r.Header.Get("X-Forwarded-For")
if ip == "" {
ip = r.Header.Get("X-real-ip")
}
if ip == "" {
ip = strings.Split(r.RemoteAddr, ":")[0]
} else {
ip = strings.Split(ip, ",")[0]
}
}
return ip
}