static.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // Copyright 2020 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package conf
  5. import (
  6. "net/url"
  7. "os"
  8. )
  9. // ℹ️ README: This file contains static values that should only be set at initialization time.
  10. // HasMinWinSvc is whether the application is built with Windows Service support.
  11. var HasMinWinSvc bool
  12. // Build information should only be set by -ldflags.
  13. var (
  14. BuildTime string
  15. BuildCommit string
  16. )
  17. // CustomConf returns the absolute path of custom configuration file that is used.
  18. var CustomConf string
  19. // ⚠️ WARNING: After changing the following section, do not forget to update template of
  20. // "/admin/config" page as well.
  21. var (
  22. // Application settings
  23. App struct {
  24. // ⚠️ WARNING: Should only be set by gogs.go.
  25. Version string `ini:"-"`
  26. BrandName string
  27. RunUser string
  28. RunMode string
  29. // Deprecated: Use BrandName instead, will be removed in 0.13.
  30. AppName string
  31. }
  32. // Server settings
  33. Server struct {
  34. ExternalURL string `ini:"EXTERNAL_URL"`
  35. Domain string
  36. Protocol string
  37. HTTPAddr string `ini:"HTTP_ADDR"`
  38. HTTPPort string `ini:"HTTP_PORT"`
  39. CertFile string
  40. KeyFile string
  41. TLSMinVersion string `ini:"TLS_MIN_VERSION"`
  42. UnixSocketPermission string
  43. LocalRootURL string `ini:"LOCAL_ROOT_URL"`
  44. OfflineMode bool
  45. DisableRouterLog bool
  46. EnableGzip bool
  47. AppDataPath string
  48. LoadAssetsFromDisk bool
  49. LandingURL string `ini:"LANDING_URL"`
  50. // Derived from other static values
  51. URL *url.URL `ini:"-"` // Parsed URL object of ExternalURL.
  52. Subpath string `ini:"-"` // Subpath found the ExternalURL. Should be empty when not found.
  53. SubpathDepth int `ini:"-"` // The number of slashes found in the Subpath.
  54. UnixSocketMode os.FileMode `ini:"-"` // Parsed file mode of UnixSocketPermission.
  55. // Deprecated: Use ExternalURL instead, will be removed in 0.13.
  56. RootURL string `ini:"ROOT_URL"`
  57. // Deprecated: Use LandingURL instead, will be removed in 0.13.
  58. LangdingPage string `ini:"LANDING_PAGE"`
  59. }
  60. // SSH settings
  61. SSH struct {
  62. Disabled bool `ini:"DISABLE_SSH"`
  63. Domain string `ini:"SSH_DOMAIN"`
  64. Port int `ini:"SSH_PORT"`
  65. RootPath string `ini:"SSH_ROOT_PATH"`
  66. KeygenPath string `ini:"SSH_KEYGEN_PATH"`
  67. KeyTestPath string `ini:"SSH_KEY_TEST_PATH"`
  68. MinimumKeySizeCheck bool
  69. MinimumKeySizes map[string]int `ini:"-"` // Load from [ssh.minimum_key_sizes]
  70. RewriteAuthorizedKeysAtStart bool
  71. StartBuiltinServer bool `ini:"START_SSH_SERVER"`
  72. ListenHost string `ini:"SSH_LISTEN_HOST"`
  73. ListenPort int `ini:"SSH_LISTEN_PORT"`
  74. ServerCiphers []string `ini:"SSH_SERVER_CIPHERS"`
  75. }
  76. )
  77. // transferDeprecated transfers deprecated values to the new ones when set.
  78. func transferDeprecated() {
  79. if App.AppName != "" {
  80. App.BrandName = App.AppName
  81. App.AppName = ""
  82. }
  83. if Server.RootURL != "" {
  84. Server.ExternalURL = Server.RootURL
  85. Server.RootURL = ""
  86. }
  87. if Server.LangdingPage == "explore" {
  88. Server.LandingURL = "/explore"
  89. Server.LangdingPage = ""
  90. }
  91. }