From f0a7b02b3af8c6321301f5bc80fe4e6ecba3eb39 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 30 Aug 2024 17:56:41 +0800 Subject: [PATCH] 1 --- bin/apigate/config/config.json | 6 +-- server/apigate/app/app.go | 25 +---------- server/apigate/middleware/caforward.go | 2 - server/apigate/mt/Config.go | 14 +----- server/apigate/mtb/mtb.auto_gen.go | 62 +++----------------------- server/apigate/proto/mt.proto | 11 ++--- server/apigate/service/sapi_forward.go | 12 ----- 7 files changed, 14 insertions(+), 118 deletions(-) diff --git a/bin/apigate/config/config.json b/bin/apigate/config/config.json index 409fa2b7..1e14c157 100644 --- a/bin/apigate/config/config.json +++ b/bin/apigate/config/config.json @@ -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 } diff --git a/server/apigate/app/app.go b/server/apigate/app/app.go index 10ff2f13..79c9b12c 100644 --- a/server/apigate/app/app.go +++ b/server/apigate/app/app.go @@ -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 } diff --git a/server/apigate/middleware/caforward.go b/server/apigate/middleware/caforward.go index 2a0b2bfb..fc2dd235 100644 --- a/server/apigate/middleware/caforward.go +++ b/server/apigate/middleware/caforward.go @@ -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") diff --git a/server/apigate/mt/Config.go b/server/apigate/mt/Config.go index 323fb68f..97c41d11 100644 --- a/server/apigate/mt/Config.go +++ b/server/apigate/mt/Config.go @@ -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无法读取本服配置") } } diff --git a/server/apigate/mtb/mtb.auto_gen.go b/server/apigate/mtb/mtb.auto_gen.go index 5e7f8578..62393f6e 100644 --- a/server/apigate/mtb/mtb.auto_gen.go +++ b/server/apigate/mtb/mtb.auto_gen.go @@ -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) } diff --git a/server/apigate/proto/mt.proto b/server/apigate/proto/mt.proto index f5392619..b9a74a9f 100644 --- a/server/apigate/proto/mt.proto +++ b/server/apigate/proto/mt.proto @@ -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; } diff --git a/server/apigate/service/sapi_forward.go b/server/apigate/service/sapi_forward.go index 45027915..b598d345 100644 --- a/server/apigate/service/sapi_forward.go +++ b/server/apigate/service/sapi_forward.go @@ -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 {