This commit is contained in:
aozhiwei 2024-08-30 17:56:41 +08:00
parent 2f021e9deb
commit f0a7b02b3a
7 changed files with 14 additions and 118 deletions

View File

@ -1,7 +1,5 @@
{
"gamesapi_url": "https://game2006sapi-test.kingsome.cn",
"redirect_url": "https://game2006api-test.kingsome.cn",
"redirect_secret_key": "~kCu8jYS)rJ5Ay_pZS_rT#&jOl)Qo0m)",
"max_concurrent_num": 10,
"redirect_url": "http://game2006api-test.kingsome.cn",
"max_concurrent_num": 60,
"request_over_time": 30
}

View File

@ -12,7 +12,7 @@ type app struct {
}
func (this *app) GetPkgName() string {
return "gamesapi"
return "apigate"
}
func (this *app) GetHttpListenPort() int32 {
@ -39,29 +39,8 @@ func (this *app) Update() {
}
func (this *app) registerDataSources() {
/* f5.GetGoStyleDb().RegisterDataSource(
constant.MAIL_DB,
mt.Table.MailDb.GetById(0).GetHost(),
mt.Table.MailDb.GetById(0).GetPort(),
mt.Table.MailDb.GetById(0).GetUser(),
mt.Table.MailDb.GetById(0).GetPasswd(),
mt.Table.MailDb.GetById(0).GetDatabase(),
1,
mt.Table.MailDb.GetById(0).GetMaxOpenConns(),
mt.Table.MailDb.GetById(0).GetMaxIdleConns())
f5.GetJsStyleDb().RegisterDataSource(
constant.MAIL_DB,
mt.Table.MailDb.GetById(0).GetHost(),
mt.Table.MailDb.GetById(0).GetPort(),
mt.Table.MailDb.GetById(0).GetUser(),
mt.Table.MailDb.GetById(0).GetPasswd(),
mt.Table.MailDb.GetById(0).GetDatabase(),
1,
mt.Table.MailDb.GetById(0).GetMaxOpenConns(),
mt.Table.MailDb.GetById(0).GetMaxIdleConns()) */
}
func (this *app) HasTask() bool {
return false //GetMailMgr().HasTask()
return false
}

View File

@ -64,7 +64,6 @@ func CaForward(c *gin.Context) {
case "GET":
{
service.SApiForward.IncGetTimes()
u.Set("__sign", service.SApiForward.Sign(params, nonce, nowTime, ""))
newUrl += u.Encode()
httpRequest, createErr = http.NewRequest("GET", newUrl, nil)
if !f5.IsOnlineEnv() {
@ -75,7 +74,6 @@ func CaForward(c *gin.Context) {
{
service.SApiForward.IncPostTimes()
if postData, err := c.GetRawData(); err == nil {
u.Set("__sign", service.SApiForward.Sign(params, nonce, nowTime, string(postData)))
newUrl += u.Encode()
httpRequest, createErr = http.NewRequest("POST", newUrl, bytes.NewBuffer(postData))
contentType := c.GetHeader("Content-Type")

View File

@ -14,25 +14,13 @@ type ConfigTable struct {
selfConf *Config
}
func (this *ConfigTable) GetGameSApiUrl() string {
return this.selfConf.GetGamesapiUrl()
}
func (this *ConfigTable) GetSecretKey() string {
return this.selfConf.GetSecretKey()
}
func (this *ConfigTable) GetMaxConcurrentNum() int32 {
return this.selfConf.GetMaxConcurrentNum()
}
func (this *ConfigTable) GetRedirectSecretKey() string {
return this.selfConf.GetRedirectSecretKey()
}
func (this *ConfigTable) PostInit1() {
this.selfConf = this.GetById(int64(0))
if this.selfConf == nil {
panic("gamesapi config无法读取本服配置")
panic("apigate config无法读取本服配置")
}
}

View File

@ -14,14 +14,9 @@ type GamesapiCluster struct {
}
type Config struct {
gamesapi_url string
secret_key string
gm_open int32
gm_secret_key string
redirect_url string
max_concurrent_num int32
request_over_time int32
redirect_secret_key string
_flags1_ uint64
_flags2_ uint64
@ -51,44 +46,12 @@ func (this *GamesapiCluster) HasHttpListenPort() bool {
return (this._flags1_ & (uint64(1) << 3)) > 0
}
func (this *Config) GetGamesapiUrl() string {
return this.gamesapi_url
}
func (this *Config) HasGamesapiUrl() bool {
return (this._flags1_ & (uint64(1) << 1)) > 0
}
func (this *Config) GetSecretKey() string {
return this.secret_key
}
func (this *Config) HasSecretKey() bool {
return (this._flags1_ & (uint64(1) << 2)) > 0
}
func (this *Config) GetGmOpen() int32 {
return this.gm_open
}
func (this *Config) HasGmOpen() bool {
return (this._flags1_ & (uint64(1) << 3)) > 0
}
func (this *Config) GetGmSecretKey() string {
return this.gm_secret_key
}
func (this *Config) HasGmSecretKey() bool {
return (this._flags1_ & (uint64(1) << 4)) > 0
}
func (this *Config) GetRedirectUrl() string {
return this.redirect_url
}
func (this *Config) HasRedirectUrl() bool {
return (this._flags1_ & (uint64(1) << 5)) > 0
return (this._flags1_ & (uint64(1) << 1)) > 0
}
func (this *Config) GetMaxConcurrentNum() int32 {
@ -96,7 +59,7 @@ func (this *Config) GetMaxConcurrentNum() int32 {
}
func (this *Config) HasMaxConcurrentNum() bool {
return (this._flags1_ & (uint64(1) << 6)) > 0
return (this._flags1_ & (uint64(1) << 2)) > 0
}
func (this *Config) GetRequestOverTime() int32 {
@ -104,15 +67,7 @@ func (this *Config) GetRequestOverTime() int32 {
}
func (this *Config) HasRequestOverTime() bool {
return (this._flags1_ & (uint64(1) << 7)) > 0
}
func (this *Config) GetRedirectSecretKey() string {
return this.redirect_secret_key
}
func (this *Config) HasRedirectSecretKey() bool {
return (this._flags1_ & (uint64(1) << 8)) > 0
return (this._flags1_ & (uint64(1) << 3)) > 0
}
@ -123,12 +78,7 @@ func (this *GamesapiCluster) LoadFromKv(kv map[string]interface{}) {
}
func (this *Config) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.gamesapi_url, "gamesapi_url", &this._flags1_, 1, kv)
f5.ReadMetaTableField(&this.secret_key, "secret_key", &this._flags1_, 2, kv)
f5.ReadMetaTableField(&this.gm_open, "gm_open", &this._flags1_, 3, kv)
f5.ReadMetaTableField(&this.gm_secret_key, "gm_secret_key", &this._flags1_, 4, kv)
f5.ReadMetaTableField(&this.redirect_url, "redirect_url", &this._flags1_, 5, kv)
f5.ReadMetaTableField(&this.max_concurrent_num, "max_concurrent_num", &this._flags1_, 6, kv)
f5.ReadMetaTableField(&this.request_over_time, "request_over_time", &this._flags1_, 7, kv)
f5.ReadMetaTableField(&this.redirect_secret_key, "redirect_secret_key", &this._flags1_, 8, kv)
f5.ReadMetaTableField(&this.redirect_url, "redirect_url", &this._flags1_, 1, kv)
f5.ReadMetaTableField(&this.max_concurrent_num, "max_concurrent_num", &this._flags1_, 2, kv)
f5.ReadMetaTableField(&this.request_over_time, "request_over_time", &this._flags1_, 3, kv)
}

View File

@ -11,12 +11,7 @@ message GamesapiCluster
message Config
{
optional string gamesapi_url = 1;
optional string secret_key = 2;
optional int32 gm_open = 3;
optional string gm_secret_key = 4;
optional string redirect_url = 5;
optional int32 max_concurrent_num = 6;
optional int32 request_over_time = 7;
optional string redirect_secret_key = 8;
optional string redirect_url = 1;
optional int32 max_concurrent_num = 2;
optional int32 request_over_time = 3;
}

View File

@ -128,18 +128,6 @@ func (this *sApiForward) getOrCreate(c *SApiForwardLockCache, accountId string)
}
}
func (this *sApiForward) Sign(params []*[]string, nonce string, timeStamp int64, postData string) string {
signData := ""
q5.Sort(params, func(a *[]string, b *[]string) bool {
return (*a)[0] < (*b)[0]
})
for _, v := range params {
signData += (*v)[0] + "=" + (*v)[1] + "&"
}
signData += nonce + q5.ToString(timeStamp) + postData + mt.Table.Config.GetRedirectSecretKey()
return q5.Md5Str(signData)
}
func (this *sApiForward) outputMonitorLog() {
logtimes := 0
for {