diff --git a/server/gamesapi/service/sapi_forward.go b/server/gamesapi/service/sapi_forward.go index 417a8ef6..6f3a6977 100644 --- a/server/gamesapi/service/sapi_forward.go +++ b/server/gamesapi/service/sapi_forward.go @@ -9,8 +9,15 @@ import ( "time" ) +type downStreamHost struct { + host string + port int32 + url string +} + type sApiForward struct { userCache []*SApiForwardLockCache + downStreams []*downStreamHost insessTimes int32 total int32 getTimes int32 @@ -35,6 +42,7 @@ type SApiForwardLock struct { } func (this *sApiForward) init() { + q5.NewSlice(&this.downStreams, 0, 20) q5.NewSlice(&this.userCache, 1024, 1024) for i := 0; i < len(this.userCache); i++ { p := new(SApiForwardLockCache) @@ -176,6 +184,11 @@ func (this *sApiForward) outputMonitorLog() { } func (this *sApiForward) GetDownStreamHost() (string, string) { - newUrl := mt.Table.Config.GetById(0).GetRedirectUrl() - return newUrl, "" + downStreams := this.downStreams + if len(downStreams) <= 0 { + newUrl := mt.Table.Config.GetById(0).GetRedirectUrl() + return newUrl, "" + } + downStream := downStreams[0] + return downStream.url, downStream.host }