yamlconfig.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. package service
  2. import "fmt"
  3. /*
  4. #服务器都对内监听处理(处理服务器之间的连接)
  5. #loglevel
  6. # Debug 1
  7. # Info 2
  8. # Warning 3
  9. # Error 4
  10. # Fatal 5
  11. # 服务器类型节点Type:[1 gate] [2 game] [3 db] [4 auth] [5 social chat mail] [10 map]
  12. #服务器都对内监听处理(处理服务器之间的连接)
  13. node:
  14. addr: 0.0.0.0:8101
  15. type: 1
  16. id: 1
  17. zone: 1
  18. logfile: 。/log
  19. config: ./config/csv
  20. loglevel: 1
  21. etcdaddr: 192.168.56.102:2379
  22. concern: game
  23. #服务器对外开放端口
  24. acceptor:
  25. addr: 0.0.0.0:21001
  26. #处理redis连接使用
  27. db:
  28. redisaddr: 0.0.0.0:6379
  29. */
  30. //yaml 数据转换为 Go 结构体的在线服务
  31. //https://zhwt.github.io/yaml-to-go/
  32. type ServerNode struct {
  33. Server []ConfigServerNode
  34. }
  35. type ConfigServerNode struct {
  36. //服务器都对内监听处理(处理服务器之间的连接)
  37. Node configServerNode `yaml:"node"`
  38. //服务器对外开放端口(一般gate使用)
  39. Acceptor configServerAcceptor `yaml:"acceptor"`
  40. //redis连接使用
  41. Redis configServerDB `yaml:"db"`
  42. //elastic
  43. Elastic configElastic `yaml:"elastic"`
  44. //SDK
  45. SDKConfig configSDK `yaml:"sdkhttp"`
  46. ServerStartTime uint64
  47. }
  48. type configServerNode struct {
  49. NodeName string `yaml:"nodename"`
  50. Addr string `yaml:"addr"`
  51. //是否是websocket模式
  52. ISWS bool `yaml:"ws"`
  53. Type int `yaml:"type"`
  54. Id int `yaml:"id"`
  55. Zone int `yaml:"zone"`
  56. Logfile string `yaml:"logfile"`
  57. UniLogFile string `yaml:"unilogfile"`
  58. RecordFile string `yaml:"recordfile"`
  59. //日志文件等级
  60. LogLevel int `yaml:"loglevel"`
  61. //单个日志大小M
  62. LogMaxSize int `yaml:"logmaxsize"`
  63. EtcdAddr string `yaml:"etcdaddr"`
  64. //局部跨服etcd注册(跨服远航)
  65. CrossEtcdAddr string `yaml:"crossetcdaddr"`
  66. //所有服务器跨服etcd注册
  67. GCrossEtcdAddr string `yaml:"gcrossetcdaddr"`
  68. //配置文件路径
  69. Config string `yaml:"config"`
  70. //需要连接的服务器类型节点
  71. Concern []string `yaml:"concern,flow"`
  72. //创建角色后注册到serverlist列表
  73. ServerList string `yaml:"serverlist"`
  74. //php后台gm地址
  75. PhpServerAddr string `yaml:"phpserveraddr"`
  76. //是否开启服务器的断线重连
  77. Reconnect int `yaml:"reconnect"`
  78. //账号验证模式1:PC模式,不做任何处理 2:激活码模式 3:第三方平台验证模式SDK
  79. AuthMode int `yaml:"authmode"`
  80. //1:机器人模式 2:无法注册 3:关闭付费功能
  81. RobotMode int `yaml:"robotmode"`
  82. HttpAddr string `yaml:"httpaddr"` //gmweb服务器http监听端口
  83. //gm白名单
  84. WhiteListGM []string `yaml:"whitelist,flow"`
  85. }
  86. type configServerAcceptor struct {
  87. Addr string `yaml:"addr"`
  88. }
  89. type configServerConnector struct {
  90. Concern string `yaml:"concern"`
  91. }
  92. type configServerDB struct {
  93. RedisAddr []string `yaml:"redisaddr,flow"`
  94. Password string `yaml:"password"`
  95. DBIndex int `yaml:"dbindex"`
  96. MysqlAddr string `yaml:"mysqladdr"`
  97. RedisCluster int `yaml:"cluster"`
  98. }
  99. type configElastic struct {
  100. Url string `yaml:"url"`
  101. Index string `yaml:"index"`
  102. }
  103. type configSDK struct {
  104. QuickHttpAddr string `yaml:"quickhttpaddr"`
  105. QuickHttpAuth string `yaml:"quickhttpauth"`
  106. QuickProductCode string `yaml:"quickproductcode"`
  107. QuickProductKey string `yaml:"quickproductkey"`
  108. QuickCallbackKey string `yaml:"quickcallbackkey"`
  109. QuickMd5key string `yaml:"quickmd5key"`
  110. UniHttpAddr string `yaml:"unihttpaddr"`
  111. UniSecretKey string `yaml:"unisecretkey"`
  112. UniWebTokenAddr string `yaml:"uniwebtokenaddr"`
  113. UniWebSalt string `yaml:"uniwebsalt"`
  114. UniWebPid string `yaml:"uniwebpid"`
  115. NbHttpAddr string `yaml:"nbhttpaddr"`
  116. NbHttpAuth string `yaml:"nbhttpauth"`
  117. NbGameKey string `yaml:"nbgamekey"`
  118. YouYiHttpAddr string `yaml:"youyihttpaddr"`
  119. YouYiPayKey string `yaml:"youyipaykey"`
  120. YouYiGameId string `yaml:"youyigameid"`
  121. YouYiGameIdList []string `yaml:"youyigameidlist"`
  122. YouYiGameIdIOS string `yaml:"youyigameidios"`
  123. YouYiGameIdListIOS []string `yaml:"youyigameidlistios"`
  124. // 支付路由,配置在1服的配置文件中
  125. PayPostRouter []string `yaml:"paypostrouter"`
  126. }
  127. func (this *ConfigServerNode) Error() string {
  128. return fmt.Sprintf("%+v", *this)
  129. }