static.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. var (
  20. // Application settings
  21. App struct {
  22. // ⚠️ WARNING: Should only be set by gogs.go.
  23. Version string `ini:"-"`
  24. BrandName string
  25. RunUser string
  26. RunMode string
  27. // Deprecated: Use BrandName instead, will be removed in 0.13.
  28. AppName string
  29. }
  30. // Server settings
  31. Server struct {
  32. ExternalURL string `ini:"EXTERNAL_URL"`
  33. Domain string
  34. Protocol string
  35. HTTPAddr string `ini:"HTTP_ADDR"`
  36. HTTPPort string `ini:"HTTP_PORT"`
  37. CertFile string
  38. KeyFile string
  39. TLSMinVersion string `ini:"TLS_MIN_VERSION"`
  40. UnixSocketPermission string
  41. LocalRootURL string `ini:"LOCAL_ROOT_URL"`
  42. OfflineMode bool
  43. DisableRouterLog bool
  44. EnableGzip bool
  45. AppDataPath string
  46. LoadAssetsFromDisk bool
  47. LandingURL string `ini:"LANDING_URL"`
  48. // Derived from other static values
  49. URL *url.URL `ini:"-"` // Parsed URL object of ExternalURL.
  50. Subpath string `ini:"-"` // Subpath found the ExternalURL. Should be empty when not found.
  51. SubpathDepth int `ini:"-"` // The number of slashes found in the Subpath.
  52. UnixSocketMode os.FileMode `ini:"-"` // Parsed file mode of UnixSocketPermission.
  53. // Deprecated: Use ExternalURL instead, will be removed in 0.13.
  54. RootURL string `ini:"ROOT_URL"`
  55. // Deprecated: Use LandingURL instead, will be removed in 0.13.
  56. LangdingPage string `ini:"LANDING_PAGE"`
  57. }
  58. // SSH settings
  59. SSH struct {
  60. Disabled bool `ini:"DISABLE_SSH"`
  61. Domain string `ini:"SSH_DOMAIN"`
  62. Port int `ini:"SSH_PORT"`
  63. RootPath string `ini:"SSH_ROOT_PATH"`
  64. KeygenPath string `ini:"SSH_KEYGEN_PATH"`
  65. KeyTestPath string `ini:"SSH_KEY_TEST_PATH"`
  66. StartBuiltinServer bool `ini:"START_SSH_SERVER"`
  67. ListenHost string `ini:"SSH_LISTEN_HOST"`
  68. ListenPort int `ini:"SSH_LISTEN_PORT"`
  69. ServerCiphers []string `ini:"SSH_SERVER_CIPHERS"`
  70. MinimumKeySizeCheck bool `ini:"MINIMUM_KEY_SIZE_CHECK"`
  71. MinimumKeySizes map[string]int `ini:"-"` // Load from [ssh.minimum_key_sizes]
  72. RewriteAuthorizedKeysAtStart bool `ini:"REWRITE_AUTHORIZED_KEYS_AT_START"`
  73. }
  74. )
  75. // transferDeprecated transfers deprecated values to the new ones when set.
  76. func transferDeprecated() {
  77. if App.AppName != "" {
  78. App.BrandName = App.AppName
  79. App.AppName = ""
  80. }
  81. if Server.RootURL != "" {
  82. Server.ExternalURL = Server.RootURL
  83. Server.RootURL = ""
  84. }
  85. if Server.LangdingPage == "explore" {
  86. Server.LandingURL = "/explore"
  87. Server.LangdingPage = ""
  88. }
  89. }