Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-userCenter
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujiebin
hilo-userCenter
Commits
32a658c5
Commit
32a658c5
authored
Sep 13, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/4.4.0' into 'master'
Feature/4.4.0 See merge request
!2
parents
0e434326
92e76fe6
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
214 additions
and
1000 deletions
+214
-1000
config.go
common/config/config.go
+12
-467
debug.ini
debug.ini
+3
-159
local.ini
local.ini
+3
-152
main.go
main.go
+110
-55
userManager.go
manager/userManager.go
+72
-0
userCenter.proto
protocol/userCenter.proto
+11
-0
release.ini
release.ini
+3
-167
No files found.
common/config/config.go
View file @
32a658c5
This diff is collapsed.
Click to expand it.
debug.ini
View file @
32a658c5
...
...
@@ -11,166 +11,10 @@ MYSQL_DB=hilo_code
[REDIS]
REDIS_HOST
=
47.244.34.27:6379
REDIS_PASSWORD
=
8QZ9JD1zLvPR3yHf
REDIS_CLUSTER_HOST
=
47.244.34.27:6379
REDIS_CLUSTER_PASSWORD
=
8QZ9JD1zLvPR3yHf
[JWT]
SECRET
=
hilo1632
ISSUER_API
=
hiloApi
ISSUER_Mgr
=
hiloMgr
EXPIRE
=
240h
\ No newline at end of file
[APP]
MASTER
=
true
BIZ_SECRET
=
biz
WEB_SECRET
=
webHilo1258
OPERATION_SECRET
=
operation1258236
SUPERUSER
=
2701,2831,4504
OFFICIAL_STAFF
=
2701,2831,3411,2511
OFFICIAL_GROUP
=
@TGS#3FDW3MPHZ
MINIMAL_VERSION_ANDROID
=
22001
MINIMAL_VERSION_IOS
=
22000
MODERATE
=
TENCENT
[OSS]
OSS_ACCESS_KEY_ID
=
LTAIxdazV2pCuV3T
OSS_ACCESS_KEY_SECRET
=
zuAnreAXQ6vlAKnvvmolFLfb1N5w5S
OSS_ROLE_ARN
=
acs:ram::1509841556585969:role/aliyunosstokengeneratorrole
OSS_END_POINT
=
http://oss-accelerate.aliyuncs.com
OSS_BUCKET
=
starvoice
OSS_CDN
=
https://oss.chathot.me/
OSS_EXPIRED_TIME
=
3600
OSS_STS_POINT
=
me-east-1
OSS_STS
=
sts-faceline-demo
OSS_STS_AES
=
484194d4d0f968a7
[AWS]
AWS_BUCKET
=
starchat
AWS_CDN
=
https://image.whoisamy.shop/
AWS_DIR
=
hilo/
CONFIDENCE
=
80
[RONGYUN]
RONG_CLOUD_APP_KEY
=
pvxdm17jpe9tr
RONG_CLOUD_APP_SECRET
=
rI4giiKWaBS4
RONG_CLOUD_URL
=
https://api-sg01.ronghub.com
[TENCENTYUN]
TENCENTYUN_APP_ID
=
1400548270
TENCENTYUN_KEY
=
321bd60f73096b059c7350f1cd97d51028850b34fa58c5c0d26bb4a19e783de8
TX_OVERSEA_APP_ID
=
40000066
TX_OVERSEA_KEY
=
3ab68ea5bddc8774d90b8c764ae71188914bd5fd06f30b28790c51e44ca7885c
[EMAS]
REGION_ID
=
cn-hangzhou
ACCESS_KEY_ID
=
LTAIdQZv5H1kNZp5
ACCESS_KEY_SECRET
=
UnwY0ClDkqBMLwPx3OJJiLYyk9xYLO
ANDROID_APP_KEY
=
30250713
ANDROID_APP_SECRET
=
cae7b9a9d3e54577d2c3b60bf6d23047
IOS_APP_KEY
=
30790728
IOS_APP_SECRET
=
4fd69ca084c67d4b5a8d15452f0af26a
APNS
=
DEV
[AGORA]
APP_ID
=
fc3e087f701b4f788099e1924c3cc7b0
APP_CERTIFICATE
=
ff29c100a613433db82324e8411eabc8
CUSTOMER_KEY
=
6b132c0ff7164560a2bc53fda06ea85a
CUSTOMER_SECRET
=
eedad2cd16d24834990d5450ace9f1ce
CALLBACK_SECRET
=
n_ZizS_N8
[CHECKOUT]
AUTHORIZATION
=
sk_test_9b5e771c-5a3f-4a8d-a4da-31b19bd43d83
URL
=
https://api.sandbox.checkout.com/hosted-payments
H5
=
https://test.chathot.me/action/hiloHtml/22_05_30_recharge/topup.html
HILO_SECRET_KEY
=
sk_test_dfbaa3b6-135d-4376-9996-2089b7d8a086
[MATCH]
MATCH_FREE_TIME
=
60
MATCH_FREE_TIME_VIP
=
60
MATCH_ADD_TIME_FREE
=
90
MATCH_AGORA_TIME
=
30
MATCH_CYCLE
=
8
MATCH_USER_EXPIRES
=
480
MATCH_SUCCESS_WAIT_DURATION
=
10
MATCH_SUCCESS_SINGLE_WAIT_TIME_IN_SEC
=
12
MATCH_SUCCESS_DUAL_WAIT_TIME_IN_SEC
=
15
[ONLINE]
ONLINE_CYCLE
=
600
ONLINE_USER_EXPIRES
=
259200
[VIDEO]
VIDEO_DAILY_FREE_NUM
=
20
VIDEO_FREE_TIME
=
60
VIDEO_FREE_TIME_VIP
=
300
VIDEO_ADD_TIME_FREE
=
60
VIDEO_AGORA_TIME
=
30
VIDEO_MINUTE_NORMAL
=
30
VIDEO_MINUTE_UNION
=
30
[SESSION]
SESSION_DAILY_FREE_NUM
=
50
GUILD_USER_HELLO_DAY
=
30
[BEAN]
DIAMOND_BEAN_RATE
=
90
[GEM]
DIAMOND_GEM_RATE
=
10
[H5]
USER_LEVEL
=
http://test.chathot.me/action/hiloHtml/hiloUserLevel/index.html
GROUP_SUPPORT
=
http://test.chathot.me/action/activityhtml/21_12_06/page.html
LUCKY_WHEEL
=
https://test.chathot.me/action/activityhtml/21_12_30/page.html
WEEKLY_STAR
=
http://test.chathot.me/action/hiloHtml/lxt_h5/page.html
WEEKLY_CP
=
https://test.chathot.me/action/hiloHtml/Valentines_22_1_18/page.html
COUNTRY_STAR
=
https://test.chathot.me/action/hiloHtml/22_08_18_nation_star/page.html
NOBLE_BUY_IOS
=
https://test.chathot.me/action/hiloHtml/22_05_26_buy_nobility/page.html
NOBLE_BUY_IOS_AUDIT
=
https://test.chathot.me/action/hiloHtml/lxt_h5/page.html
GUILD_DATA_URL
=
https://test.chathot.me/action/hiloHtml/22_10_18_app_data_coins/index.html
MGR_GUILD_DATA_URL
=
https://test.chathot.me/action/hiloHtml/22_10_18_app_data_coins/union.html
RANKING_PINK_DIAMOND_URL
=
https://test.chathot.me/action/activitiesPage/2022_10_17HiloLiveH5/index.html
GROUP_POWER_GRADE_URL
=
https://test.chathot.me/action/hiloHtml/2023Activity/2023_3_21FamilyLevel/index.html
GROUP_POWER_ACT_URL
=
SHEEP_H5_URL
=
https://gzds.vip/yangyang?game_id=hilo_sheep
ID_URL
=
https://h5.whoisamy.shop/action/hiloHtml/new_upgrade/index.html
[GROUPIM]
MSG_SORT_EXPIRE
=
21600
MSG_SORT_SNAP
=
300
MSG_PARALLEL_SIZE
=
10
[GRADE]
CHARM_SPEED_VIP
=
15
ACTITY_SPEED_VIP
=
15
WEALTH_SPEED_VIP
=
15
[LIKE]
I_LIKE_NUM
=
30
I_LIKE_NUM_VIP
=
300
I_LIKE_NUM_NOBLE
=
1000
[APPLEPAY]
PASSWORD
=
38702750a05c4cb09c9d6ca646835634
[REGISTER]
IMEI_TOTAL
=
3
IMEI_OAUTH
=
2
ACCOUNT_IP
=
100
ACCOUNT_IP_DURATION
=
21600
[BANNER]
GIFT_BANNER_LEVEL1
=
500
GIFT_BANNER_LEVEL2
=
2000
GIFT_BANNER_LEVEL3
=
5000
[DIAMOND]
DAILY_LOGIN_IMEI_LIMIT
=
2
DAILY_LOGIN_IP_LIMIT
=
5
PRIVATE_GIFT_RETURN
=
10
[LUCKY_WHEEL]
MINIMAL_PARTICIPANT
=
2
WAIT_TIMELONG
=
10
WINNER_DIAMOND_BANNER
=
10
[GROUP_CUSTOM_THEME]
PIC_LIMIT
=
5
DAY
=
10
[GIFT]
WALL_DIAMOND
=
10
[DAILY]
LOGIN_COMMON
=
5
LOGIN_VIP
=
300
[FRUIT_TYCOON]
POOL_RATIO
=
80
WATERMELON_RATIO
=
24
[RISK_CONTROL]
USER_QPS_LIMIT
=
60
[PAYER_MAX]
URL
=
https://pay-gate-uat.payermax.com/aggregate-pay-gate/api/gateway
KEY
=
d50d149a883b8bb6
MERCHANT_ID
=
SP11018326
BIZ_TYPE
=
CUSTOMIZE
VERSION
=
2.3
FRONT_CALLBACK_URL
=
https://www.hiloconn.com
SHOW_RESULT
=
1
EXPIRE_TIME
=
1800
LANGUAGE
=
en
[PAYPAL]
PAYPAL_CLIENT_ID
=
AQCXHyXFhNLNWoorcj3Du0J4WwBDy25DoQ7SZKNKRe4PNY0BLpeCzV_zm1HKwAvd7reWeOBCte-vMakM
PAYPAL_SECRET_ID
=
EDBTK99v6wXhGXhDqDTOksK2j8NPAfJKT-wRTqTrNGrUmn8xsjkrVcO_xSvMVR6CB2bN74rGl_AFm098
RETURN_URL
=
https://test.apiv1.faceline.live/v1/callback/paypal
\ No newline at end of file
local.ini
View file @
32a658c5
...
...
@@ -11,159 +11,10 @@ MYSQL_DB=hilo_code
[REDIS]
REDIS_HOST
=
47.244.34.27:6379
REDIS_PASSWORD
=
8QZ9JD1zLvPR3yHf
REDIS_CLUSTER_HOST
=
47.244.34.27:6379
REDIS_CLUSTER_PASSWORD
=
8QZ9JD1zLvPR3yHf
[JWT]
SECRET
=
hilo1632
ISSUER_API
=
hiloApi
ISSUER_Mgr
=
hiloMgr
EXPIRE
=
240h
\ No newline at end of file
[APP]
MASTER
=
false
BIZ_SECRET
=
biz
WEB_SECRET
=
webHilo1258
OPERATION_SECRET
=
operation1258236
SUPERUSER
=
2701,2831
OFFICIAL_STAFF
=
2701,2831
OFFICIAL_GROUP
=
@TGS#3NC2ATRHS,@TGS#33W3KNLHK
MINIMAL_VERSION_ANDROID
=
212
MINIMAL_VERSION_IOS
=
100
MODERATE
=
AWS
[OSS]
OSS_ACCESS_KEY_ID
=
LTAIxdazV2pCuV3T
OSS_ACCESS_KEY_SECRET
=
zuAnreAXQ6vlAKnvvmolFLfb1N5w5S
OSS_ROLE_ARN
=
acs:ram::1509841556585969:role/aliyunosstokengeneratorrole
OSS_END_POINT
=
http://oss-accelerate.aliyuncs.com
OSS_BUCKET
=
starvoice
OSS_CDN
=
https://oss.chathot.me/
OSS_EXPIRED_TIME
=
3600
OSS_STS_POINT
=
me-east-1
OSS_STS
=
sts-faceline-demo
OSS_STS_AES
=
484194d4d0f968a7
[AWS]
AWS_BUCKET
=
starchat
AWS_CDN
=
https://image.whoisamy.shop/
AWS_DIR
=
hilo/
CONFIDENCE
=
80
[RONGYUN]
RONG_CLOUD_APP_KEY
=
pvxdm17jpe9tr
RONG_CLOUD_APP_SECRET
=
rI4giiKWaBS4
RONG_CLOUD_URL
=
https://api-sg01.ronghub.com
[TENCENTYUN]
TENCENTYUN_APP_ID
=
1400548270
TENCENTYUN_KEY
=
321bd60f73096b059c7350f1cd97d51028850b34fa58c5c0d26bb4a19e783de8
TX_OVERSEA_APP_ID
=
40000066
TX_OVERSEA_KEY
=
3ab68ea5bddc8774d90b8c764ae71188914bd5fd06f30b28790c51e44ca7885c
[EMAS]
REGION_ID
=
cn-hangzhou
ACCESS_KEY_ID
=
LTAI4FhNPzxdzD4w6bHirL9Z
ACCESS_KEY_SECRET
=
OQvUJpXDrjGi3g1F2aHiAIFWIvLdbP
ANDROID_APP_KEY
=
30250713
ANDROID_APP_SECRET
=
cae7b9a9d3e54577d2c3b60bf6d23047
IOS_APP_KEY
=
30240346
IOS_APP_SECRET
=
57f33ab9ca6a957a8c659f2b0b6d1205
APNS
=
DEV
[AGORA]
APP_ID
=
fc3e087f701b4f788099e1924c3cc7b0
APP_CERTIFICATE
=
ff29c100a613433db82324e8411eabc8
CUSTOMER_KEY
=
6b132c0ff7164560a2bc53fda06ea85a
CUSTOMER_SECRET
=
eedad2cd16d24834990d5450ace9f1ce
CALLBACK_SECRET
=
n_ZizS_N8
[CHECKOUT]
AUTHORIZATION
=
sk_test_9b5e771c-5a3f-4a8d-a4da-31b19bd43d83
URL
=
https://api.sandbox.checkout.com/hosted-payments
H5
=
http://test.chathot.me/action/hiloHtml/22_05_30_recharge/topup.html
HILO_SECRET_KEY
=
sk_test_dfbaa3b6-135d-4376-9996-2089b7d8a086
[MATCH]
MATCH_FREE_TIME
=
60
MATCH_FREE_TIME_VIP
=
300
MATCH_ADD_TIME_FREE
=
90
MATCH_AGORA_TIME
=
30
MATCH_CYCLE
=
8
MATCH_USER_EXPIRES
=
480
MATCH_SUCCESS_WAIT_DURATION
=
10
MATCH_SUCCESS_SINGLE_WAIT_TIME_IN_SEC
=
12
MATCH_SUCCESS_DUAL_WAIT_TIME_IN_SEC
=
15
[ONLINE]
ONLINE_CYCLE
=
600
ONLINE_USER_EXPIRES
=
259200
[VIDEO]
VIDEO_DAILY_FREE_NUM
=
20
VIDEO_FREE_TIME
=
60
VIDEO_FREE_TIME_VIP
=
300
VIDEO_ADD_TIME_FREE
=
60
VIDEO_AGORA_TIME
=
30
VIDEO_MINUTE_NORMAL
=
1000
VIDEO_MINUTE_UNION
=
2000
[SESSION]
SESSION_DAILY_FREE_NUM
=
50
[BEAN]
DIAMOND_BEAN_RATE
=
90
[GEM]
DIAMOND_GEM_RATE
=
10
[H5]
USER_LEVEL
=
http://test.chathot.me/action/activityhtml/hiloUserLevel/index.html
GROUP_SUPPORT
=
http://test.chathot.me/action/activityhtml/21_12_06/page.html
LUCKY_WHEEL
=
https://h5.whoisamy.shop/action/activityhtml/21_12_30/page.html
NOBLE_BUY_IOS
=
https://h5.whoisamy.shop/action/hiloHtml/lxt_h5/page.html
NOBLE_BUY_IOS_AUDIT
=
https://h5.whoisamy.shop/action/hiloHtml/lxt_h5/page.html
GROUP_POWER_GRADE_URL
=
https://test.chathot.me/action/hiloHtml/2023Activity/2023_3_21FamilyLevel/index.html
GROUP_POWER_ACT_URL
=
https://www.baidu.com
SHEEP_H5_URL
=
https://gzds.vip/yangyang?game_id=hilo_sheep
ID_URL
=
https://h5.whoisamy.shop/action/hiloHtml/new_upgrade/index.html
[GROUPIM]
MSG_SORT_EXPIRE
=
43200
MSG_SORT_SNAP
=
300
[GRADE]
CHARM_SPEED_VIP
=
15
ACTITY_SPEED_VIP
=
15
WEALTH_SPEED_VIP
=
15
[LIKE]
I_LIKE_NUM
=
30
I_LIKE_NUM_VIP
=
100
I_LIKE_NUM_NOBLE
=
1000
[APPLEPAY]
PASSWORD
=
38702750a05c4cb09c9d6ca646835634
[REGISTER]
IMEI_TOTAL
=
3
IMEI_OAUTH
=
2
ACCOUNT_IP
=
100
ACCOUNT_IP_DURATION
=
21600
[BANNER]
GIFT_BANNER_LEVEL1
=
100
GIFT_BANNER_LEVEL2
=
2000
GIFT_BANNER_LEVEL3
=
5000
[DIAMOND]
DAILY_LOGIN_IMEI_LIMIT
=
200
DAILY_LOGIN_IP_LIMIT
=
5
PRIVATE_GIFT_RETURN
=
1440
NEW_USER_INVITE_AWARD
=
5000
[LUCKY_WHEEL]
MINIMAL_PARTICIPANT
=
2
WAIT_TIMELONG
=
10
WINNER_DIAMOND_BANNER
=
100
[GROUP_CUSTOM_THEME]
PIC_LIMIT
=
5
DAY
=
10
[GIFT]
WALL_DIAMOND
=
10
[DAILY]
LOGIN_COMMON
=
5
LOGIN_VIP
=
300
[DAILY]
LOGIN_COMMON
=
5
LOGIN_VIP
=
300
[FRUIT_TYCOON]
POOL_RATIO
=
20
WATERMELON_RATIO
=
70
[ACTIVITY]
COUNTRY_STAR_POOL_RATIO
=
20
COUNTRY_STAR_ORDINARY_RATIO
=
20
[PAYER_MAX]
URL
=
https://pay-gate-uat.payermax.com/aggregate-pay-gate/api/gateway
KEY
=
d50d149a883b8bb6
MERCHANT_ID
=
SP11018326
BIZ_TYPE
=
CUSTOMIZE
VERSION
=
2.3
FRONT_CALLBACK_URL
=
https://www.hiloconn.com
SHOW_RESULT
=
1
EXPIRE_TIME
=
1800
LANGUAGE
=
en
\ No newline at end of file
main.go
View file @
32a658c5
...
...
@@ -4,6 +4,7 @@ import (
"context"
"flag"
"fmt"
"gorm.io/gorm/schema"
"net"
"net/http"
"net/url"
...
...
@@ -20,6 +21,7 @@ import (
"gorm.io/gorm/logger"
"hilo-userCenter/common"
appConfig
"hilo-userCenter/common/config"
"hilo-userCenter/common/dingding"
"hilo-userCenter/common/mylogrus"
"hilo-userCenter/manager"
...
...
@@ -29,8 +31,6 @@ import (
const
(
port
=
50040
default_redis_address
=
"47.244.34.27:6379"
default_redis_password
=
"8QZ9JD1zLvPR3yHf"
redis_section
=
1
)
...
...
@@ -39,11 +39,13 @@ const (
monitorLength
=
3500
// 队列告警数量
kickChanSize
=
500
broadcastChanSize
=
3500
areacastChanSize
=
3500
)
var
(
kickChan
chan
KickChanMsg
broadcastChan
chan
BroadcastChanMsg
areacastChan
chan
AreaChanMsg
)
type
KickChanMsg
struct
{
...
...
@@ -57,14 +59,18 @@ type BroadcastChanMsg struct {
in
*
userCenter
.
BroadcastMessage
}
type
AreaChanMsg
struct
{
ProxyAddr
string
UserIds
[]
uint64
in
*
userCenter
.
AreaMessage
}
var
(
userManager
*
manager
.
UserManager
=
nil
termManager
*
manager
.
TerminalManager
=
nil
roomManager
*
manager
.
RoomManager
=
nil
)
var
logDir
=
"/var/log/hilo/"
type
server
struct
{
userCenter
.
UnimplementedUserServer
}
...
...
@@ -238,6 +244,56 @@ func (s *server) Broadcast(ctx context.Context, in *userCenter.BroadcastMessage)
return
&
userCenter
.
BroadcastMessageRsp
{
FailedUids
:
failed
},
nil
}
func
(
s
*
server
)
Areacast
(
ctx
context
.
Context
,
in
*
userCenter
.
AreaMessage
)
(
*
userCenter
.
AreaMessageRsp
,
error
)
{
var
failed
[]
uint64
terminals
:=
termManager
.
GetAll
()
if
terminals
!=
nil
{
var
uids
[]
uint64
for
uidStr
:=
range
*
terminals
{
if
uid
,
_
:=
strconv
.
ParseUint
(
uidStr
,
10
,
64
);
uid
>
0
{
uids
=
append
(
uids
,
uid
)
}
}
// 处理分区用户
areaUids
:=
userManager
.
GetAreaUsers
(
uids
,
int8
(
in
.
Area
))
if
len
(
areaUids
)
<=
0
{
return
&
userCenter
.
AreaMessageRsp
{
FailedUids
:
failed
},
nil
}
m
:=
make
(
map
[
string
][]
uint64
,
0
)
for
uid
:=
range
areaUids
{
ok
:=
false
addr
:=
userManager
.
GetUser
(
uid
)
if
addr
!=
nil
{
if
_
,
ok
:=
m
[
*
addr
];
!
ok
{
m
[
*
addr
]
=
make
([]
uint64
,
0
)
}
m
[
*
addr
]
=
append
(
m
[
*
addr
],
uid
)
ok
=
true
}
else
{
mylogrus
.
MyLog
.
Errorf
(
"Unknown user %d
\n
"
,
uid
)
}
if
!
ok
{
failed
=
append
(
failed
,
uid
)
}
}
for
addr
,
users
:=
range
m
{
const
sendBatchSize
=
5
for
i
:=
0
;
i
<
len
(
users
);
i
+=
sendBatchSize
{
end
:=
i
+
sendBatchSize
if
end
>
len
(
users
)
{
end
=
len
(
users
)
}
areacastChan
<-
AreaChanMsg
{
ProxyAddr
:
addr
,
UserIds
:
users
[
i
:
end
],
in
:
in
,
}
}
}
}
return
&
userCenter
.
AreaMessageRsp
{
FailedUids
:
failed
},
nil
}
func
(
s
*
server
)
Transmit
(
ctx
context
.
Context
,
in
*
userCenter
.
BizMessage
)
(
*
userCenter
.
BizMessageRsp
,
error
)
{
mylogrus
.
MyLog
.
Infof
(
"Transmiting msgType = %d, uid = %d, payLoad: %s
\n
"
,
in
.
MsgType
,
in
.
Uid
,
in
.
PayLoad
)
...
...
@@ -312,6 +368,22 @@ func realBroadcast(addr string, uids []uint64, msg *userCenter.BroadcastMessage)
}
}
func
realAreacast
(
addr
string
,
uids
[]
uint64
,
msg
*
userCenter
.
AreaMessage
)
{
for
_
,
uid
:=
range
uids
{
client
:=
manager
.
UserProxyMgr
.
MakeClient
(
addr
)
if
client
==
nil
{
mylogrus
.
MyLog
.
Errorf
(
"Failed in making client for %d, %s
\n
"
,
uid
,
addr
)
}
else
{
toRouterClient
:=
userCenter
.
NewRouterClient
(
client
)
status
,
err
:=
routeMessage
(
toRouterClient
,
uid
,
msg
.
MsgType
,
msg
.
PayLoad
)
if
err
!=
nil
{
mylogrus
.
MyLog
.
Errorf
(
"routeMessage uid = %d, msgType = %d, status = %d, %v"
,
uid
,
msg
.
MsgType
,
status
,
err
)
}
}
}
}
func
routeMessage
(
c
userCenter
.
RouterClient
,
uid
uint64
,
msgType
uint32
,
data
[]
byte
)
(
uint32
,
error
)
{
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
time
.
Second
*
3
)
defer
cancel
()
...
...
@@ -437,7 +509,7 @@ func selfCheck() {
}
}
type
HiloConfig
struct
{
type
HiloConfig
s
struct
{
Name
string
`gorm:"primary_key"`
Value
string
}
...
...
@@ -454,53 +526,15 @@ func main() {
go
registerToConsul
(
client
,
false
)
go
selfCheck
()
redisAddress
:=
default_redis_address
redisPassword
:=
default_redis_password
mysqHost
,
mysqlUsername
,
mysqlPassword
,
mysqlDb
:=
"47.244.34.27:3306"
,
"root"
,
"yX0jPAhO0I4s2zlA"
,
"hilo"
kv
:=
client
.
KV
()
if
kv
!=
nil
{
p
,
_
,
err
:=
kv
.
Get
(
"redis_address"
,
nil
)
if
err
==
nil
&&
p
!=
nil
{
redisAddress
=
string
(
p
.
Value
)
}
p
,
_
,
err
=
kv
.
Get
(
"redis_password"
,
nil
)
if
err
==
nil
&&
p
!=
nil
{
redisPassword
=
string
(
p
.
Value
)
}
p
,
_
,
err
=
kv
.
Get
(
"mysql_host"
,
nil
)
if
err
==
nil
&&
p
!=
nil
{
mysqHost
=
string
(
p
.
Value
)
}
p
,
_
,
err
=
kv
.
Get
(
"mysql_username"
,
nil
)
if
err
==
nil
&&
p
!=
nil
{
mysqlUsername
=
string
(
p
.
Value
)
}
p
,
_
,
err
=
kv
.
Get
(
"mysql_password"
,
nil
)
if
err
==
nil
&&
p
!=
nil
{
mysqlPassword
=
string
(
p
.
Value
)
}
p
,
_
,
err
=
kv
.
Get
(
"mysql_db"
,
nil
)
if
err
==
nil
&&
p
!=
nil
{
mysqlDb
=
string
(
p
.
Value
)
}
}
mylogrus
.
MyLog
.
Infof
(
"Db config mysqHost = %v , mysqlUsername = %v, mysqlPassword = %v ,mysqlDb = %v redisAddress :%v,redisPassword:%v"
,
mysqHost
,
mysqlUsername
,
mysqlPassword
,
mysqlDb
,
redisAddress
,
redisPassword
)
if
mysqHost
==
""
||
mysqlUsername
==
""
||
mysqlPassword
==
""
||
mysqlDb
==
""
{
mylogrus
.
MyLog
.
Fatalln
(
"Db config is missing."
)
}
// init redis
rdb
:=
redis
.
NewClient
(
&
redis
.
Options
{
Addr
:
redisAddress
,
Password
:
redisPassword
,
Addr
:
appConfig
.
GetConfigRedis
()
.
REDIS_HOST
,
Password
:
appConfig
.
GetConfigRedis
()
.
REDIS_PASSWORD
,
DB
:
redis_section
,
})
if
rdb
==
nil
{
mylogrus
.
MyLog
.
Fatalf
(
"failed to connect redis %s
\n
"
,
redisAddress
)
mylogrus
.
MyLog
.
Fatalf
(
"failed to connect redis %s
\n
"
,
appConfig
.
GetConfigRedis
()
.
REDIS_HOST
)
}
result
,
err
:=
rdb
.
Ping
(
context
.
Background
())
.
Result
()
if
err
!=
nil
{
mylogrus
.
MyLog
.
Fatal
(
err
)
...
...
@@ -512,9 +546,12 @@ func main() {
options
:=
"?charset=utf8mb4&parseTime=True&loc=Local&time_zone="
+
url
.
QueryEscape
(
"'+8:00'"
)
fmt
.
Println
(
"options = "
,
options
)
dsn
:=
mysqlUsername
+
":"
+
mysqlPassword
+
"@("
+
mysqHost
+
")/"
+
mysqlDb
dsn
:=
appConfig
.
GetConfigMysql
()
.
MYSQL_USERNAME
+
":"
+
appConfig
.
GetConfigMysql
()
.
MYSQL_PASSWORD
+
"@("
+
appConfig
.
GetConfigMysql
()
.
MYSQL_HOST
+
")/"
+
appConfig
.
GetConfigMysql
()
.
MYSQL_DB
db
,
err
:=
gorm
.
Open
(
mysql
.
Open
(
dsn
),
&
gorm
.
Config
{
Logger
:
logger
.
Default
.
LogMode
(
logger
.
Info
),
NamingStrategy
:
schema
.
NamingStrategy
{
SingularTable
:
true
,
},
})
if
err
!=
nil
{
mylogrus
.
MyLog
.
Fatal
(
"mysql connect error %v"
,
err
)
...
...
@@ -522,7 +559,7 @@ func main() {
mylogrus
.
MyLog
.
Infof
(
"mysql connect success"
)
}
var
jwtConfig
=
HiloConfig
{}
var
jwtConfig
=
HiloConfig
s
{}
db
.
First
(
&
jwtConfig
,
"name = 'jwt_secret'"
)
if
len
(
jwtConfig
.
Value
)
==
0
{
mylogrus
.
MyLog
.
Fatalln
(
"Empty jwt secret"
)
...
...
@@ -533,7 +570,15 @@ func main() {
userManager
=
&
manager
.
UserManager
{
Ctx
:
context
.
Background
(),
RedisClient
:
rdb
,
MysqlDB
:
db
,
}
go
func
()
{
for
{
// 同步区域
userManager
.
SyncArea
()
time
.
Sleep
(
time
.
Minute
*
15
)
}
}()
termManager
=
&
manager
.
TerminalManager
{
Ctx
:
context
.
Background
(),
RedisClient
:
rdb
,
...
...
@@ -543,8 +588,6 @@ func main() {
RedisClient
:
rdb
,
}
mylogrus
.
MyLog
.
Infof
(
"Connected to Redis %s
\n
"
,
redisAddress
)
go
func
()
{
ticker
:=
time
.
NewTicker
(
time
.
Second
*
30
)
defer
ticker
.
Stop
()
...
...
@@ -569,6 +612,7 @@ func main() {
// 初始化协程chan
kickChan
=
make
(
chan
KickChanMsg
,
kickChanSize
)
broadcastChan
=
make
(
chan
BroadcastChanMsg
,
broadcastChanSize
)
areacastChan
=
make
(
chan
AreaChanMsg
,
areacastChanSize
)
go
check
()
// 检查长度
for
i
:=
0
;
i
<
kickChanSize
;
i
++
{
go
func
(
n
int
)
{
...
...
@@ -580,6 +624,11 @@ func main() {
broadcast
(
n
)
}(
i
)
}
for
i
:=
0
;
i
<
areacastChanSize
;
i
++
{
go
func
(
n
int
)
{
areacast
(
n
)
}(
i
)
}
fmt
.
Println
(
"Go RPC listening on "
,
port
)
lis
,
err
:=
net
.
Listen
(
"tcp4"
,
":"
+
strconv
.
Itoa
(
port
))
...
...
@@ -622,6 +671,12 @@ func broadcast(n int) {
}
}
func
areacast
(
n
int
)
{
for
msg
:=
range
areacastChan
{
realAreacast
(
msg
.
ProxyAddr
,
msg
.
UserIds
,
msg
.
in
)
}
}
var
lastDingTime
time
.
Time
var
dingIntervalMin
float64
=
5
// 5min 告警间隔
...
...
@@ -632,11 +687,11 @@ func check() {
for
{
select
{
case
<-
tick
.
C
:
l
,
l2
:=
len
(
kickChan
),
len
(
broad
castChan
)
if
l
>=
monitorLength
||
l2
>=
monitorLength
{
l
,
l2
,
l3
:=
len
(
kickChan
),
len
(
broadcastChan
),
len
(
area
castChan
)
if
l
>=
monitorLength
||
l2
>=
monitorLength
||
l3
>=
monitorLength
{
if
time
.
Now
()
.
Sub
(
lastDingTime
)
.
Minutes
()
>
dingIntervalMin
{
go
func
()
{
if
sErr
:=
dingding
.
SendDingRobot
(
dingding
.
ROBOTWEBHOOK
,
fmt
.
Sprintf
(
"userCenter通知延迟,队列长度:kickChan:%d,broadcastChan:%d
"
,
l
,
l2
),
true
);
sErr
!=
nil
{
if
sErr
:=
dingding
.
SendDingRobot
(
dingding
.
ROBOTWEBHOOK
,
fmt
.
Sprintf
(
"userCenter通知延迟,队列长度:kickChan:%d,broadcastChan:%d
,areacastChan:%d"
,
l
,
l2
,
l3
),
true
);
sErr
!=
nil
{
mylogrus
.
MyLog
.
Errorf
(
"dingding msg fail:%v"
,
sErr
)
}
else
{
lastDingTime
=
time
.
Now
()
...
...
manager/userManager.go
View file @
32a658c5
...
...
@@ -3,8 +3,11 @@ package manager
import
(
"context"
"github.com/go-redis/redis/v8"
"gorm.io/gorm"
"hilo-userCenter/common/mylogrus"
"log"
"strconv"
"sync"
)
const
(
...
...
@@ -14,6 +17,7 @@ const (
type
UserManager
struct
{
Ctx
context
.
Context
RedisClient
*
redis
.
Client
MysqlDB
*
gorm
.
DB
}
func
(
m
*
UserManager
)
GetUser
(
uid
uint64
)
*
string
{
...
...
@@ -63,3 +67,71 @@ func (m *UserManager) GetAll() *map[string]string {
return
&
result
}
}
// 国家到area映射 country->area 1:阿语 2:非阿语
var
countryArea
sync
.
Map
type
ResCountry
struct
{
Name
string
Area
int8
}
// 定期同步国家到area映射
func
(
m
*
UserManager
)
SyncArea
()
{
var
rows
[]
ResCountry
if
err
:=
m
.
MysqlDB
.
Model
(
ResCountry
{})
.
Find
(
&
rows
)
.
Error
;
err
!=
nil
{
mylogrus
.
MyLog
.
Errorf
(
"SyncArea fail:%v"
,
err
)
return
}
for
_
,
v
:=
range
rows
{
countryArea
.
Store
(
v
.
Name
,
v
.
Area
)
}
}
// 获取地区
func
(
m
*
UserManager
)
GetArea
(
country
string
)
(
area
int8
)
{
area
=
1
// 默认阿语
if
data
,
ok
:=
countryArea
.
Load
(
country
);
ok
{
return
data
.
(
int8
)
}
return
area
}
type
UserTinyArea
struct
{
ID
uint64
Avatar
string
ExternalId
string
Sex
uint8
Code
string
Country
string
Area
int8
`gorm:"-"`
}
// 获取指定区域用户
func
(
m
*
UserManager
)
GetAreaUsers
(
userIds
[]
uint64
,
area
int8
)
map
[
uint64
]
UserTinyArea
{
res
:=
make
(
map
[
uint64
]
UserTinyArea
)
// 从db中读,暂时不缓存(几千个)
var
users
[]
UserTinyArea
if
err
:=
m
.
MysqlDB
.
Table
(
"user"
)
.
Select
(
"id,external_id,sex,code,country,avatar"
)
.
Where
(
"id IN (?)"
,
userIds
)
.
Find
(
&
users
)
.
Error
;
err
!=
nil
{
mylogrus
.
MyLog
.
Errorf
(
"GetUserArea fail:%v"
,
err
)
return
res
}
for
_
,
u
:=
range
users
{
a
:=
m
.
GetArea
(
u
.
Country
)
if
a
!=
area
{
continue
}
res
[
u
.
ID
]
=
UserTinyArea
{
ID
:
u
.
ID
,
ExternalId
:
u
.
ExternalId
,
Sex
:
u
.
Sex
,
Code
:
u
.
Code
,
Country
:
u
.
Country
,
Area
:
a
,
Avatar
:
u
.
Avatar
,
}
}
return
res
}
protocol/userCenter.proto
View file @
32a658c5
...
...
@@ -122,6 +122,16 @@ message GetLastRoomHeartbeatMessageResp {
int64
timestamp
=
1
;
}
message
AreaMessage
{
int32
area
=
1
;
uint32
msgType
=
2
;
bytes
payLoad
=
3
;
}
message
AreaMessageRsp
{
repeated
uint64
failedUids
=
1
;
}
service
Router
{
rpc
route
(
RouteMessage
)
returns
(
RouteMessageRsp
)
{}
rpc
kickUser
(
KickMessage
)
returns
(
KickMessageRsp
)
{}
...
...
@@ -132,6 +142,7 @@ service User {
rpc
logout
(
LogoutMessage
)
returns
(
LogoutMessageRsp
)
{}
rpc
multicast
(
MulticastMessage
)
returns
(
MulticastMessageRsp
)
{}
rpc
broadcast
(
BroadcastMessage
)
returns
(
BroadcastMessageRsp
)
{}
rpc
areacast
(
AreaMessage
)
returns
(
AreaMessageRsp
)
{}
rpc
transmit
(
BizMessage
)
returns
(
BizMessageRsp
)
{}
rpc
enterRoom
(
EnterRoomMessage
)
returns
(
EnterRoomMessageRsp
)
{}
rpc
leaveRoom
(
LeaveRoomMessage
)
returns
(
LeaveRoomMessageRsp
)
{}
...
...
release.ini
View file @
32a658c5
...
...
@@ -11,174 +11,10 @@ MYSQL_DB=hilo_code
[REDIS]
REDIS_HOST
=
r-eb3btxn8vfdsuwdbuf.redis.dubai.rds.aliyuncs.com:6379
REDIS_PASSWORD
=
REDIS_CLUSTER_HOST
=
r-eb3yt6k8zgxs62kjjs.redis.dubai.rds.aliyuncs.com:6379
REDIS_CLUSTER_PASSWORD
=
[JWT]
SECRET
=
hilo1504
ISSUER_API
=
hiloApi
ISSUER_Mgr
=
hiloMgr
EXPIRE
=
720h
\ No newline at end of file
[APP]
MASTER
=
true
BIZ_SECRET
=
biz
OPERATION_SECRET
=
operation1258236
WEB_SECRET
=
webHilo1258
SUPERUSER
=
28201,23951,133101,41,2020531,955271,1575531
OFFICIAL_STAFF
=
133101,435731,486461,41
OFFICIAL_GROUP
=
@TGS#33W3KNLHK,@TGS#3XA5RJ5HH,@TGS#3O6PKBTH6
MINIMAL_VERSION_ANDROID
=
22600
MINIMAL_VERSION_IOS
=
22600
ROOM_MODE
=
AVChatRoom
MODERATE
=
TENCENT
[OSS]
OSS_ACCESS_KEY_ID
=
LTAIxdazV2pCuV3T
OSS_ACCESS_KEY_SECRET
=
zuAnreAXQ6vlAKnvvmolFLfb1N5w5S
OSS_ROLE_ARN
=
acs:ram::1509841556585969:role/aliyunosstokengeneratorrole
OSS_END_POINT
=
https://oss-accelerate.aliyuncs.com
OSS_BUCKET
=
starvoice
OSS_CDN
=
https://oss.chathot.me/
OSS_EXPIRED_TIME
=
3600
OSS_STS_POINT
=
me-east-1
OSS_STS
=
sts-faceline-demo
OSS_STS_AES
=
484194d4d0f968a7
[AWS]
AWS_BUCKET
=
starchat
AWS_CDN
=
https://image.whoisamy.shop/
AWS_DIR
=
hilo/
CONFIDENCE
=
80
[RONGYUN]
RONG_CLOUD_APP_KEY
=
uwd1c0sxu5t41
RONG_CLOUD_APP_SECRET
=
vo9djozyBl9bZ
RONG_CLOUD_URL
=
https://api-sg01.ronghub.com
[TENCENTYUN]
TENCENTYUN_APP_ID
=
1400487464
TENCENTYUN_KEY
=
cb4c1f2e3398a88e0e9468b403f671e60d66a564df86f7db925c6ab4f18b66e5
TX_OVERSEA_APP_ID
=
40000066
TX_OVERSEA_KEY
=
3ab68ea5bddc8774d90b8c764ae71188914bd5fd06f30b28790c51e44ca7885c
[EMAS]
REGION_ID
=
cn-hangzhou
ACCESS_KEY_ID
=
LTAIdQZv5H1kNZp5
ACCESS_KEY_SECRET
=
UnwY0ClDkqBMLwPx3OJJiLYyk9xYLO
ANDROID_APP_KEY
=
30774987
ANDROID_APP_SECRET
=
297a0f231f1286a2de9aab097cc8ff5c
IOS_APP_KEY
=
30790728
IOS_APP_SECRET
=
4fd69ca084c67d4b5a8d15452f0af26a
APNS
=
PRODUCT
[AGORA]
APP_ID
=
6291d069123642d9929a49c734c50719
APP_CERTIFICATE
=
d5de40350aa54e60bcdce90c71e9598a
CUSTOMER_KEY
=
6b132c0ff7164560a2bc53fda06ea85a
CUSTOMER_SECRET
=
eedad2cd16d24834990d5450ace9f1ce
[CHECKOUT]
AUTHORIZATION
=
sk_fca6e213-b7df-4bd7-99f4-7c0a9f7c778c
URL
=
https://api.checkout.com/hosted-payments
H5
=
https://h5.whoisamy.shop/action/hiloHtml/22_05_30_recharge/topup.html
HILO_SECRET_KEY
=
sk_26806bf4-e6e3-45e2-a093-c72c5b53eaf5
[MATCH]
MATCH_FREE_TIME
=
60
MATCH_FREE_TIME_VIP
=
60
MATCH_ADD_TIME_FREE
=
90
MATCH_AGORA_TIME
=
30
MATCH_CYCLE
=
8
MATCH_USER_EXPIRES
=
480
MATCH_SUCCESS_WAIT_DURATION
=
10
MATCH_SUCCESS_SINGLE_WAIT_TIME_IN_SEC
=
12
MATCH_SUCCESS_DUAL_WAIT_TIME_IN_SEC
=
15
[ONLINE]
ONLINE_CYCLE
=
600
ONLINE_USER_EXPIRES
=
259200
[VIDEO]
VIDEO_DAILY_FREE_NUM
=
20
VIDEO_FREE_TIME
=
60
VIDEO_FREE_TIME_VIP
=
300
VIDEO_ADD_TIME_FREE
=
60
VIDEO_AGORA_TIME
=
30
VIDEO_MINUTE_NORMAL
=
60
VIDEO_MINUTE_UNION
=
60
[SESSION]
SESSION_DAILY_FREE_NUM
=
50
GUILD_USER_HELLO_DAY
=
30
[BEAN]
DIAMOND_BEAN_RATE
=
90
[GEM]
DIAMOND_GEM_RATE
=
10
[H5]
USER_LEVEL
=
https://h5.whoisamy.shop/action/hiloHtml/hiloUserLevel/index.html
GROUP_SUPPORT
=
https://h5.whoisamy.shop/action/activityhtml/21_12_06/page.html
LUCKY_WHEEL
=
https://h5.whoisamy.shop/action/activityhtml/21_12_30/page.html
WEEKLY_STAR
=
https://h5.whoisamy.shop/action/hiloHtml/lxt_h5/page.html
WEEKLY_CP
=
https://h5.whoisamy.shop/action/hiloHtml/Valentines_22_1_18/page.html
COUNTRY_STAR
=
https://h5.whoisamy.shop/action/hiloHtml/22_08_18_nation_star/page.html
NOBLE_BUY_IOS
=
https://h5.whoisamy.shop/action/hiloHtml/22_05_26_buy_nobility/page.html
NOBLE_BUY_IOS_AUDIT
=
https://h5.whoisamy.shop/action/hiloHtml/lxt_h5/page.html
GUILD_DATA_URL
=
https://h5.whoisamy.shop/action/hiloHtml/22_10_18_app_data_coins/index.html
MGR_GUILD_DATA_URL
=
https://h5.whoisamy.shop/action/hiloHtml/22_10_18_app_data_coins/union.html
RANKING_PINK_DIAMOND_URL
=
https://h5.whoisamy.shop/action/activitiesPage/2022_10_17HiloLiveH5/index.html
GROUP_POWER_GRADE_URL
=
https://h5.whoisamy.shop/action/hiloHtml/2023Activity/2023_3_21FamilyLevel/index.html
ID_URL
=
https://h5.whoisamy.shop/action/hiloHtml/new_upgrade/index.html
GROUP_POWER_ACT_URL
=
https://h5.whoisamy.shop/action/hiloHtml/2023Activity/2023_4_21FamilyMonth/index.html
SHEEP_H5_URL
=
https://h5.whoisamy.shop/action/slotRelease/sheep0322v1/index.html?game_id=hilo_sheep
[GROUPIM]
MSG_SORT_EXPIRE
=
1209600
MSG_SORT_SNAP
=
300
MSG_PARALLEL_SIZE
=
10
[GRADE]
CHARM_SPEED_VIP
=
15
ACTITY_SPEED_VIP
=
15
WEALTH_SPEED_VIP
=
15
[LIKE]
I_LIKE_NUM
=
500
I_LIKE_NUM_VIP
=
1000
I_LIKE_NUM_NOBLE
=
5000
[APPLEPAY]
PASSWORD
=
38702750a05c4cb09c9d6ca646835634
[REGISTER]
IMEI_TOTAL
=
5
IMEI_OAUTH
=
2
ACCOUNT_IP
=
100
ACCOUNT_IP_DURATION
=
21600
[BANNER]
GIFT_BANNER_LEVEL1
=
3000
GIFT_BANNER_LEVEL2
=
5000
GIFT_BANNER_LEVEL3
=
10000
[DIAMOND]
DAILY_LOGIN_IMEI_LIMIT
=
5
DAILY_LOGIN_IP_LIMIT
=
30
PRIVATE_GIFT_RETURN
=
1440
NEW_USER_INVITE_AWARD
=
5000
[LUCKY_WHEEL]
MINIMAL_PARTICIPANT
=
2
WAIT_TIMELONG
=
10
WINNER_DIAMOND_BANNER
=
200
[GROUP_CUSTOM_THEME]
PIC_LIMIT
=
50
DAY
=
10
[GIFT]
WALL_DIAMOND
=
2000
[DAILY]
LOGIN_COMMON
=
10
LOGIN_VIP
=
1000
[FRUIT_TYCOON]
BIG_WINNER_THRESDHOLD
=
30000
BIG_WINNER_LOW
=
10000
BIG_WINNER_HIGH
=
20000
POOL_RATIO
=
5
WATERMELON_RATIO
=
24
[ACTIVITY]
COUNTRY_STAR_POOL_RATIO
=
20
COUNTRY_STAR_ORDINARY_RATIO
=
20
[RISK_CONTROL]
USER_QPS_LIMIT
=
128
USER_URL_QPS_LIMIT
=
64
[PAYER_MAX]
URL
=
https://pay-gate.payermax.com/aggregate-pay-gate/api/gateway
KEY
=
503a970695756efa
MERCHANT_ID
=
SP11018326
BIZ_TYPE
=
CUSTOMIZE
VERSION
=
2.3
FRONT_CALLBACK_URL
=
https://www.hiloconn.com
SHOW_RESULT
=
1
EXPIRE_TIME
=
1800
LANGUAGE
=
en
[PAYPAL]
PAYPAL_CLIENT_ID
=
AXn-z2U6D2uKW0eJBoH3Hg0MzH6i8mLackAP9bcub2W_YmfMC-YBuPD3sTQgwJSecmAVtHIS9IsqBiIy
PAYPAL_SECRET_ID
=
EBNCFnSEwbteb8TDVtCMcOUcQBimG7hABmSe0bgC05HriWmje7cKFV2F4xI9pZnt1hDetKLnYxfmWYSY
RETURN_URL
=
https://apiv1.faceline.live/v1/callback/paypal
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment