config.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package adslib
  2. import (
  3. "github.com/BurntSushi/toml"
  4. "sync"
  5. )
  6. type SvrConf struct {
  7. HostIos string `toml:"Host_Ios"`
  8. HostAndroid string `toml:"Host_Android"`
  9. Host string `toml:"Host"`
  10. HostScript string `toml:"Host_script"`
  11. HostMiao string `toml:"Host_miao"`
  12. IPReqSource []string `toml:"ip_req_source"`
  13. BlackReqSource []string `toml:"black_req_source"`
  14. DpTest string `toml:"dp_test"`
  15. FreqControlNum int `toml:"freq_control_num"`
  16. FlowPercent map[string]map[string]FlogControlItem `toml:"flow_percent"`
  17. FlowPercent1 map[string]map[string]FlogControlItem `toml:"flow_percent_1"`
  18. AdsActions map[string][]string `toml:"Ads_Actions"`
  19. AdsDuration map[string]int `toml:"Ads_Duration"`
  20. ActionWeight ActionWeight `toml:"action_weight"`
  21. CombinationActions map[string][]CombinationActionsConf `toml:"combination_actions"`
  22. SecretKey string `toml:"secret_key"`
  23. Ip2RegionFile string `toml:"ip2region_file"`
  24. LogPath string `toml:"log_path"`
  25. }
  26. type FlogControlItem struct {
  27. Percent int `toml:"percent"`
  28. Duration int `toml:"duration"`
  29. }
  30. type ActionWeight struct {
  31. VIEW int `toml:"VIEW"`
  32. VIDEOTIMER int `toml:"VIDEO_TIMER"`
  33. CLICK int `toml:"CLICK"`
  34. CLOSE int `toml:"CLOSE"`
  35. VIDEOFINISH int `toml:"VIDEO_FINISH"`
  36. }
  37. type CombinationActionsConf struct {
  38. PercentBegin int `toml:"percent_begin"`
  39. PercentEnd int `toml:"percent_end"`
  40. GroupValue []string `toml:"group_value"`
  41. LastAction string `toml:"last_action"`
  42. }
  43. var svrConf SvrConf
  44. var once sync.Once
  45. func GetConf() *SvrConf {
  46. once.Do(func() {
  47. _, err := toml.DecodeFile("./conf/config.toml", &svrConf)
  48. if err != nil {
  49. panic(err)
  50. }
  51. })
  52. return &svrConf
  53. }