You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

setting.go 26 kB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
10 years ago
10 years ago
11 years ago
9 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
9 years ago
11 years ago
9 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
11 years ago
9 years ago
11 years ago
11 years ago
9 years ago
10 years ago
10 years ago
10 years ago
11 years ago
11 years ago
10 years ago
11 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
11 years ago
11 years ago
10 years ago
10 years ago
11 years ago
Squashed commit of the following: commit 0afcb843d7ffd596991c4885cab768273a6eb42c Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 17:13:29 2016 -0600 Removed Upload stats as the upload table is just a temporary table commit 7ecd73ff5535612d79d471409173ee7f1fcfa157 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:42:41 2016 -0600 Fix for CodeMirror mode commit c29b9ab531e2e7af0fb5db24dc17e51027dd1174 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:03:33 2016 -0600 Made tabbing in editor use spaces commit 23af384c53206a8a40e11e45bf49d7a149c4adcd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:56:46 2016 -0600 Fix for data-url commit cfb8a97591cb6fc0a92e49563b7b764c524db0e9 Merge: 7fc8a89 991ce42 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:42:53 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit 7fc8a89cb495478225b02d613e647f99a1489634 Merge: fd3d86c c03d040 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:40:00 2016 -0600 Merge branch 'feature-create-and-edit-repo-file' of github.com:richmahn/gogs into feature-create-and-edit-repo-file commit fd3d86ca6bbc02cfda566a504ffd6b03db4f75ef Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:39:44 2016 -0600 Code cleanup commit c03d0401c1049eeeccc32ab1f9c3303c130be5ee Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 29 15:38:23 2016 -0600 Code cleanup commit 98e1206ccf9f9a4503c020e3a7830cf9f861dfae Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:36:01 2016 -0600 Code cleanup and fixes commit c2895dc742f25f8412879c9fa15e18f27f42f194 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:24:04 2016 -0600 Fixes per Unknwon's requests commit 6aa7e46b21ad4c96e562daa2eac26a8fb408f8ef Merge: 889e9fa ad7ea88 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 17:13:43 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go modules/setting/setting.go commit 889e9faf1bd8559a4979c8f46005d488c1a234d4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:09:18 2016 -0600 Fix in gogs.js commit 47603edf223f147b114be65f3bd27bc1e88827a5 Merge: bb57912 cf85e9e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:07:36 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit bb5791255867a71c11a77b639db050ad09c597a4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:02:18 2016 -0600 Update for using CodeMirror mode addon commit d10d128c51039be19e2af9c66c63db66a9f2ec6d Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 16:12:57 2016 -0600 Update for Edit commit 34a34982025144e3225e389f7849eb6273c1d576 Merge: fa1b752 1c7dcdd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 11:52:02 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go commit fa1b752be29cd455c5184ddac2ffe80b3489763e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 15 18:35:42 2016 -0600 Feature for editing, creating, uploading and deleting files
8 years ago
10 years ago
10 years ago
Add support for federated avatars (#3320) * Add support for federated avatars Fixes #3105 Removes avatar fetching duplication code Adds an "Enable Federated Avatar" checkbox in user settings (defaults to unchecked) Moves avatar settings all in the same form, making local and remote avatars mutually exclusive Renames UploadAvatarForm to AvatarForm as it's not anymore only for uploading * Run gofmt on all modified files * Move Avatar form in its own page * Add go-libravatar dependency to vendor/ dir Hopefully helps with accepting the contribution. See also #3214 * Revert "Add go-libravatar dependency to vendor/ dir" This reverts commit a8cb93ae640bbb90f7d25012fc257bda9fae9b82. * Make federated avatar setting a global configuration Removes the per-user setting * Move avatar handling back to base tool, disable federated avatar in offline mode * Format, handle error * Properly set fallback host * Use unsupported github.com mirror for importing go-libravatar * Remove comment showing life exists outside of github.com ... pity, but contribution would not be accepted otherwise * Use Combo for Get and Post methods over /avatar * FEDERATED_AVATAR -> ENABLE_FEDERATED_AVATAR * Fix persistance of federated avatar lookup checkbox at install time * Federated Avatars -> Enable Federated Avatars * Use len(string) == 0 instead of string == "" * Move import line where it belong See https://github.com/Unknwon/go-code-convention/blob/master/en-US/import_packages.md Pity the import url is still the unofficial one, but oh well... * Save a line (and waste much more expensive time) * Remove redundant parens * Remove an empty line * Remove empty lines * Reorder lines to make diff smaller * Remove another newline Unknwon review got me start a fight against newlines * Move DISABLE_GRAVATAR and ENABLE_FEDERATED_AVATAR after OFFLINE_MODE On re-reading the diff I figured what Unknwon meant here: https://github.com/gogits/gogs/pull/3320/files#r73741106 * Remove newlines that weren't there before my intervention
8 years ago
Add support for federated avatars (#3320) * Add support for federated avatars Fixes #3105 Removes avatar fetching duplication code Adds an "Enable Federated Avatar" checkbox in user settings (defaults to unchecked) Moves avatar settings all in the same form, making local and remote avatars mutually exclusive Renames UploadAvatarForm to AvatarForm as it's not anymore only for uploading * Run gofmt on all modified files * Move Avatar form in its own page * Add go-libravatar dependency to vendor/ dir Hopefully helps with accepting the contribution. See also #3214 * Revert "Add go-libravatar dependency to vendor/ dir" This reverts commit a8cb93ae640bbb90f7d25012fc257bda9fae9b82. * Make federated avatar setting a global configuration Removes the per-user setting * Move avatar handling back to base tool, disable federated avatar in offline mode * Format, handle error * Properly set fallback host * Use unsupported github.com mirror for importing go-libravatar * Remove comment showing life exists outside of github.com ... pity, but contribution would not be accepted otherwise * Use Combo for Get and Post methods over /avatar * FEDERATED_AVATAR -> ENABLE_FEDERATED_AVATAR * Fix persistance of federated avatar lookup checkbox at install time * Federated Avatars -> Enable Federated Avatars * Use len(string) == 0 instead of string == "" * Move import line where it belong See https://github.com/Unknwon/go-code-convention/blob/master/en-US/import_packages.md Pity the import url is still the unofficial one, but oh well... * Save a line (and waste much more expensive time) * Remove redundant parens * Remove an empty line * Remove empty lines * Reorder lines to make diff smaller * Remove another newline Unknwon review got me start a fight against newlines * Move DISABLE_GRAVATAR and ENABLE_FEDERATED_AVATAR after OFFLINE_MODE On re-reading the diff I figured what Unknwon meant here: https://github.com/gogits/gogs/pull/3320/files#r73741106 * Remove newlines that weren't there before my intervention
8 years ago
Add support for federated avatars (#3320) * Add support for federated avatars Fixes #3105 Removes avatar fetching duplication code Adds an "Enable Federated Avatar" checkbox in user settings (defaults to unchecked) Moves avatar settings all in the same form, making local and remote avatars mutually exclusive Renames UploadAvatarForm to AvatarForm as it's not anymore only for uploading * Run gofmt on all modified files * Move Avatar form in its own page * Add go-libravatar dependency to vendor/ dir Hopefully helps with accepting the contribution. See also #3214 * Revert "Add go-libravatar dependency to vendor/ dir" This reverts commit a8cb93ae640bbb90f7d25012fc257bda9fae9b82. * Make federated avatar setting a global configuration Removes the per-user setting * Move avatar handling back to base tool, disable federated avatar in offline mode * Format, handle error * Properly set fallback host * Use unsupported github.com mirror for importing go-libravatar * Remove comment showing life exists outside of github.com ... pity, but contribution would not be accepted otherwise * Use Combo for Get and Post methods over /avatar * FEDERATED_AVATAR -> ENABLE_FEDERATED_AVATAR * Fix persistance of federated avatar lookup checkbox at install time * Federated Avatars -> Enable Federated Avatars * Use len(string) == 0 instead of string == "" * Move import line where it belong See https://github.com/Unknwon/go-code-convention/blob/master/en-US/import_packages.md Pity the import url is still the unofficial one, but oh well... * Save a line (and waste much more expensive time) * Remove redundant parens * Remove an empty line * Remove empty lines * Reorder lines to make diff smaller * Remove another newline Unknwon review got me start a fight against newlines * Move DISABLE_GRAVATAR and ENABLE_FEDERATED_AVATAR after OFFLINE_MODE On re-reading the diff I figured what Unknwon meant here: https://github.com/gogits/gogs/pull/3320/files#r73741106 * Remove newlines that weren't there before my intervention
8 years ago
Add support for federated avatars (#3320) * Add support for federated avatars Fixes #3105 Removes avatar fetching duplication code Adds an "Enable Federated Avatar" checkbox in user settings (defaults to unchecked) Moves avatar settings all in the same form, making local and remote avatars mutually exclusive Renames UploadAvatarForm to AvatarForm as it's not anymore only for uploading * Run gofmt on all modified files * Move Avatar form in its own page * Add go-libravatar dependency to vendor/ dir Hopefully helps with accepting the contribution. See also #3214 * Revert "Add go-libravatar dependency to vendor/ dir" This reverts commit a8cb93ae640bbb90f7d25012fc257bda9fae9b82. * Make federated avatar setting a global configuration Removes the per-user setting * Move avatar handling back to base tool, disable federated avatar in offline mode * Format, handle error * Properly set fallback host * Use unsupported github.com mirror for importing go-libravatar * Remove comment showing life exists outside of github.com ... pity, but contribution would not be accepted otherwise * Use Combo for Get and Post methods over /avatar * FEDERATED_AVATAR -> ENABLE_FEDERATED_AVATAR * Fix persistance of federated avatar lookup checkbox at install time * Federated Avatars -> Enable Federated Avatars * Use len(string) == 0 instead of string == "" * Move import line where it belong See https://github.com/Unknwon/go-code-convention/blob/master/en-US/import_packages.md Pity the import url is still the unofficial one, but oh well... * Save a line (and waste much more expensive time) * Remove redundant parens * Remove an empty line * Remove empty lines * Reorder lines to make diff smaller * Remove another newline Unknwon review got me start a fight against newlines * Move DISABLE_GRAVATAR and ENABLE_FEDERATED_AVATAR after OFFLINE_MODE On re-reading the diff I figured what Unknwon meant here: https://github.com/gogits/gogs/pull/3320/files#r73741106 * Remove newlines that weren't there before my intervention
8 years ago
10 years ago
11 years ago
11 years ago
10 years ago
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
11 years ago
10 years ago
11 years ago
11 years ago
10 years ago
11 years ago
11 years ago
10 years ago
10 years ago
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
11 years ago
10 years ago
11 years ago
11 years ago
10 years ago
11 years ago
10 years ago
11 years ago
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833
  1. // Copyright 2014 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 setting
  5. import (
  6. "fmt"
  7. "net/mail"
  8. "net/url"
  9. "os"
  10. "os/exec"
  11. "path"
  12. "path/filepath"
  13. "runtime"
  14. "strconv"
  15. "strings"
  16. "time"
  17. "github.com/Unknwon/com"
  18. _ "github.com/go-macaron/cache/memcache" // memcache plugin for cache
  19. _ "github.com/go-macaron/cache/redis"
  20. "github.com/go-macaron/session"
  21. _ "github.com/go-macaron/session/redis" // redis plugin for store session
  22. _ "github.com/kardianos/minwinsvc" // import minwinsvc for windows services
  23. "gopkg.in/ini.v1"
  24. "strk.kbt.io/projects/go/libravatar"
  25. "code.gitea.io/gitea/modules/bindata"
  26. "code.gitea.io/gitea/modules/log"
  27. "code.gitea.io/gitea/modules/user"
  28. )
  29. // Scheme describes protocol types
  30. type Scheme string
  31. // enumerates all the scheme types
  32. const (
  33. HTTP Scheme = "http"
  34. HTTPS Scheme = "https"
  35. FCGI Scheme = "fcgi"
  36. UnixSocket Scheme = "unix"
  37. )
  38. // LandingPage describes the default page
  39. type LandingPage string
  40. // enumerates all the landing page types
  41. const (
  42. LandingPageHome LandingPage = "/"
  43. LandingPageExplore LandingPage = "/explore"
  44. )
  45. // settings
  46. var (
  47. // BuildTime information should only be set by -ldflags.
  48. BuildTime string
  49. BuildGitHash string
  50. // AppVer settings
  51. AppVer string
  52. AppName string
  53. AppURL string
  54. AppSubURL string
  55. AppSubURLDepth int // Number of slashes
  56. AppPath string
  57. AppDataPath string
  58. // Server settings
  59. Protocol Scheme
  60. Domain string
  61. HTTPAddr string
  62. HTTPPort string
  63. LocalURL string
  64. OfflineMode bool
  65. DisableRouterLog bool
  66. CertFile string
  67. KeyFile string
  68. StaticRootPath string
  69. EnableGzip bool
  70. LandingPageURL LandingPage
  71. UnixSocketPermission uint32
  72. SSH struct {
  73. Disabled bool `ini:"DISABLE_SSH"`
  74. StartBuiltinServer bool `ini:"START_SSH_SERVER"`
  75. Domain string `ini:"SSH_DOMAIN"`
  76. Port int `ini:"SSH_PORT"`
  77. ListenPort int `ini:"SSH_LISTEN_PORT"`
  78. RootPath string `ini:"SSH_ROOT_PATH"`
  79. KeyTestPath string `ini:"SSH_KEY_TEST_PATH"`
  80. KeygenPath string `ini:"SSH_KEYGEN_PATH"`
  81. MinimumKeySizeCheck bool `ini:"-"`
  82. MinimumKeySizes map[string]int `ini:"-"`
  83. }
  84. // Security settings
  85. InstallLock bool
  86. SecretKey string
  87. LogInRememberDays int
  88. CookieUserName string
  89. CookieRememberName string
  90. ReverseProxyAuthUser string
  91. // Database settings
  92. UseSQLite3 bool
  93. UseMySQL bool
  94. UsePostgreSQL bool
  95. UseTiDB bool
  96. // Webhook settings
  97. Webhook struct {
  98. QueueLength int
  99. DeliverTimeout int
  100. SkipTLSVerify bool
  101. Types []string
  102. PagingNum int
  103. }
  104. // Repository settings
  105. Repository struct {
  106. AnsiCharset string
  107. ForcePrivate bool
  108. MaxCreationLimit int
  109. MirrorQueueLength int
  110. PullRequestQueueLength int
  111. PreferredLicenses []string
  112. DisableHTTPGit bool
  113. // Repository editor settings
  114. Editor struct {
  115. LineWrapExtensions []string
  116. PreviewableFileModes []string
  117. } `ini:"-"`
  118. // Repository upload settings
  119. Upload struct {
  120. Enabled bool
  121. TempPath string
  122. AllowedTypes []string `delim:"|"`
  123. FileMaxSize int64
  124. MaxFiles int
  125. } `ini:"-"`
  126. }
  127. RepoRootPath string
  128. ScriptType string
  129. // UI settings
  130. UI struct {
  131. ExplorePagingNum int
  132. IssuePagingNum int
  133. FeedMaxCommitNum int
  134. ThemeColorMetaTag string
  135. MaxDisplayFileSize int64
  136. Admin struct {
  137. UserPagingNum int
  138. RepoPagingNum int
  139. NoticePagingNum int
  140. OrgPagingNum int
  141. } `ini:"ui.admin"`
  142. User struct {
  143. RepoPagingNum int
  144. } `ini:"ui.user"`
  145. }
  146. // Markdown sttings
  147. Markdown struct {
  148. EnableHardLineBreak bool
  149. CustomURLSchemes []string `ini:"CUSTOM_URL_SCHEMES"`
  150. FileExtensions []string
  151. }
  152. // Picture settings
  153. AvatarUploadPath string
  154. GravatarSource string
  155. DisableGravatar bool
  156. EnableFederatedAvatar bool
  157. LibravatarService *libravatar.Libravatar
  158. // Log settings
  159. LogRootPath string
  160. LogModes []string
  161. LogConfigs []string
  162. // Attachment settings
  163. AttachmentPath string
  164. AttachmentAllowedTypes string
  165. AttachmentMaxSize int64
  166. AttachmentMaxFiles int
  167. AttachmentEnabled bool
  168. // Time settings
  169. TimeFormat string
  170. // Cache settings
  171. CacheAdapter string
  172. CacheInterval int
  173. CacheConn string
  174. // Session settings
  175. SessionConfig session.Options
  176. CSRFCookieName = "_csrf"
  177. // Cron tasks
  178. Cron struct {
  179. UpdateMirror struct {
  180. Enabled bool
  181. RunAtStart bool
  182. Schedule string
  183. } `ini:"cron.update_mirrors"`
  184. RepoHealthCheck struct {
  185. Enabled bool
  186. RunAtStart bool
  187. Schedule string
  188. Timeout time.Duration
  189. Args []string `delim:" "`
  190. } `ini:"cron.repo_health_check"`
  191. CheckRepoStats struct {
  192. Enabled bool
  193. RunAtStart bool
  194. Schedule string
  195. } `ini:"cron.check_repo_stats"`
  196. }
  197. // Git settings
  198. Git struct {
  199. DisableDiffHighlight bool
  200. MaxGitDiffLines int
  201. MaxGitDiffLineCharacters int
  202. MaxGitDiffFiles int
  203. GCArgs []string `delim:" "`
  204. Timeout struct {
  205. Migrate int
  206. Mirror int
  207. Clone int
  208. Pull int
  209. GC int `ini:"GC"`
  210. } `ini:"git.timeout"`
  211. }
  212. // Mirror settings
  213. Mirror struct {
  214. DefaultInterval int
  215. }
  216. // API settings
  217. API struct {
  218. MaxResponseItems int
  219. }
  220. // I18n settings
  221. Langs []string
  222. Names []string
  223. dateLangs map[string]string
  224. // Highlight settings are loaded in modules/template/hightlight.go
  225. // Other settings
  226. ShowFooterBranding bool
  227. ShowFooterVersion bool
  228. ShowFooterTemplateLoadTime bool
  229. // Global setting objects
  230. Cfg *ini.File
  231. CustomPath string // Custom directory path
  232. CustomConf string
  233. ProdMode bool
  234. RunUser string
  235. IsWindows bool
  236. HasRobotsTxt bool
  237. )
  238. // DateLang transforms standard language locale name to corresponding value in datetime plugin.
  239. func DateLang(lang string) string {
  240. name, ok := dateLangs[lang]
  241. if ok {
  242. return name
  243. }
  244. return "en"
  245. }
  246. // execPath returns the executable path.
  247. func execPath() (string, error) {
  248. file, err := exec.LookPath(os.Args[0])
  249. if err != nil {
  250. return "", err
  251. }
  252. return filepath.Abs(file)
  253. }
  254. func init() {
  255. IsWindows = runtime.GOOS == "windows"
  256. log.NewLogger(0, "console", `{"level": 0}`)
  257. var err error
  258. if AppPath, err = execPath(); err != nil {
  259. log.Fatal(4, "fail to get app path: %v\n", err)
  260. }
  261. // Note: we don't use path.Dir here because it does not handle case
  262. // which path starts with two "/" in Windows: "//psf/Home/..."
  263. AppPath = strings.Replace(AppPath, "\\", "/", -1)
  264. }
  265. // WorkDir returns absolute path of work directory.
  266. func WorkDir() (string, error) {
  267. wd := os.Getenv("GITEA_WORK_DIR")
  268. if len(wd) > 0 {
  269. return wd, nil
  270. }
  271. // Use GOGS_WORK_DIR if available, for backward compatibility
  272. // TODO: drop in 1.1.0 ?
  273. wd = os.Getenv("GOGS_WORK_DIR")
  274. if len(wd) > 0 {
  275. log.Warn(`Usage of GOGS_WORK_DIR is deprecated and will be *removed* in a future release,
  276. please consider changing to GITEA_WORK_DIR`)
  277. return wd, nil
  278. }
  279. i := strings.LastIndex(AppPath, "/")
  280. if i == -1 {
  281. return AppPath, nil
  282. }
  283. return AppPath[:i], nil
  284. }
  285. func forcePathSeparator(path string) {
  286. if strings.Contains(path, "\\") {
  287. log.Fatal(4, "Do not use '\\' or '\\\\' in paths, instead, please use '/' in all places")
  288. }
  289. }
  290. // IsRunUserMatchCurrentUser returns false if configured run user does not match
  291. // actual user that runs the app. The first return value is the actual user name.
  292. // This check is ignored under Windows since SSH remote login is not the main
  293. // method to login on Windows.
  294. func IsRunUserMatchCurrentUser(runUser string) (string, bool) {
  295. if IsWindows {
  296. return "", true
  297. }
  298. currentUser := user.CurrentUsername()
  299. return currentUser, runUser == currentUser
  300. }
  301. // NewContext initializes configuration context.
  302. // NOTE: do not print any log except error.
  303. func NewContext() {
  304. workDir, err := WorkDir()
  305. if err != nil {
  306. log.Fatal(4, "Fail to get work directory: %v", err)
  307. }
  308. Cfg, err = ini.Load(bindata.MustAsset("conf/app.ini"))
  309. if err != nil {
  310. log.Fatal(4, "Fail to parse 'conf/app.ini': %v", err)
  311. }
  312. CustomPath = os.Getenv("GITEA_CUSTOM")
  313. if len(CustomPath) == 0 {
  314. // For backward compatibility
  315. // TODO: drop in 1.1.0 ?
  316. CustomPath = os.Getenv("GOGS_CUSTOM")
  317. if len(CustomPath) == 0 {
  318. CustomPath = workDir + "/custom"
  319. } else {
  320. log.Warn(`Usage of GOGS_CUSTOM is deprecated and will be *removed* in a future release,
  321. please consider changing to GITEA_CUSTOM`)
  322. }
  323. }
  324. if len(CustomConf) == 0 {
  325. CustomConf = CustomPath + "/conf/app.ini"
  326. }
  327. if com.IsFile(CustomConf) {
  328. if err = Cfg.Append(CustomConf); err != nil {
  329. log.Fatal(4, "Fail to load custom conf '%s': %v", CustomConf, err)
  330. }
  331. } else {
  332. log.Warn("Custom config '%s' not found, ignore this if you're running first time", CustomConf)
  333. }
  334. Cfg.NameMapper = ini.AllCapsUnderscore
  335. homeDir, err := com.HomeDir()
  336. if err != nil {
  337. log.Fatal(4, "Fail to get home directory: %v", err)
  338. }
  339. homeDir = strings.Replace(homeDir, "\\", "/", -1)
  340. LogRootPath = Cfg.Section("log").Key("ROOT_PATH").MustString(path.Join(workDir, "log"))
  341. forcePathSeparator(LogRootPath)
  342. sec := Cfg.Section("server")
  343. AppName = Cfg.Section("").Key("APP_NAME").MustString("Gogs: Go Git Service")
  344. AppURL = sec.Key("ROOT_URL").MustString("http://localhost:3000/")
  345. if AppURL[len(AppURL)-1] != '/' {
  346. AppURL += "/"
  347. }
  348. // Check if has app suburl.
  349. url, err := url.Parse(AppURL)
  350. if err != nil {
  351. log.Fatal(4, "Invalid ROOT_URL '%s': %s", AppURL, err)
  352. }
  353. // Suburl should start with '/' and end without '/', such as '/{subpath}'.
  354. // This value is empty if site does not have sub-url.
  355. AppSubURL = strings.TrimSuffix(url.Path, "/")
  356. AppSubURLDepth = strings.Count(AppSubURL, "/")
  357. Protocol = HTTP
  358. if sec.Key("PROTOCOL").String() == "https" {
  359. Protocol = HTTPS
  360. CertFile = sec.Key("CERT_FILE").String()
  361. KeyFile = sec.Key("KEY_FILE").String()
  362. } else if sec.Key("PROTOCOL").String() == "fcgi" {
  363. Protocol = FCGI
  364. } else if sec.Key("PROTOCOL").String() == "unix" {
  365. Protocol = UnixSocket
  366. UnixSocketPermissionRaw := sec.Key("UNIX_SOCKET_PERMISSION").MustString("666")
  367. UnixSocketPermissionParsed, err := strconv.ParseUint(UnixSocketPermissionRaw, 8, 32)
  368. if err != nil || UnixSocketPermissionParsed > 0777 {
  369. log.Fatal(4, "Fail to parse unixSocketPermission: %s", UnixSocketPermissionRaw)
  370. }
  371. UnixSocketPermission = uint32(UnixSocketPermissionParsed)
  372. }
  373. Domain = sec.Key("DOMAIN").MustString("localhost")
  374. HTTPAddr = sec.Key("HTTP_ADDR").MustString("0.0.0.0")
  375. HTTPPort = sec.Key("HTTP_PORT").MustString("3000")
  376. LocalURL = sec.Key("LOCAL_ROOT_URL").MustString(string(Protocol) + "://localhost:" + HTTPPort + "/")
  377. OfflineMode = sec.Key("OFFLINE_MODE").MustBool()
  378. DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool()
  379. StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(workDir)
  380. AppDataPath = sec.Key("APP_DATA_PATH").MustString("data")
  381. EnableGzip = sec.Key("ENABLE_GZIP").MustBool()
  382. switch sec.Key("LANDING_PAGE").MustString("home") {
  383. case "explore":
  384. LandingPageURL = LandingPageExplore
  385. default:
  386. LandingPageURL = LandingPageHome
  387. }
  388. SSH.RootPath = path.Join(homeDir, ".ssh")
  389. SSH.KeyTestPath = os.TempDir()
  390. if err = Cfg.Section("server").MapTo(&SSH); err != nil {
  391. log.Fatal(4, "Fail to map SSH settings: %v", err)
  392. }
  393. // When disable SSH, start builtin server value is ignored.
  394. if SSH.Disabled {
  395. SSH.StartBuiltinServer = false
  396. }
  397. if !SSH.Disabled && !SSH.StartBuiltinServer {
  398. if err := os.MkdirAll(SSH.RootPath, 0700); err != nil {
  399. log.Fatal(4, "Fail to create '%s': %v", SSH.RootPath, err)
  400. } else if err = os.MkdirAll(SSH.KeyTestPath, 0644); err != nil {
  401. log.Fatal(4, "Fail to create '%s': %v", SSH.KeyTestPath, err)
  402. }
  403. }
  404. SSH.MinimumKeySizeCheck = sec.Key("MINIMUM_KEY_SIZE_CHECK").MustBool()
  405. SSH.MinimumKeySizes = map[string]int{}
  406. minimumKeySizes := Cfg.Section("ssh.minimum_key_sizes").Keys()
  407. for _, key := range minimumKeySizes {
  408. if key.MustInt() != -1 {
  409. SSH.MinimumKeySizes[strings.ToLower(key.Name())] = key.MustInt()
  410. }
  411. }
  412. sec = Cfg.Section("security")
  413. InstallLock = sec.Key("INSTALL_LOCK").MustBool()
  414. SecretKey = sec.Key("SECRET_KEY").String()
  415. LogInRememberDays = sec.Key("LOGIN_REMEMBER_DAYS").MustInt()
  416. CookieUserName = sec.Key("COOKIE_USERNAME").String()
  417. CookieRememberName = sec.Key("COOKIE_REMEMBER_NAME").String()
  418. ReverseProxyAuthUser = sec.Key("REVERSE_PROXY_AUTHENTICATION_USER").MustString("X-WEBAUTH-USER")
  419. sec = Cfg.Section("attachment")
  420. AttachmentPath = sec.Key("PATH").MustString(path.Join(AppDataPath, "attachments"))
  421. if !filepath.IsAbs(AttachmentPath) {
  422. AttachmentPath = path.Join(workDir, AttachmentPath)
  423. }
  424. AttachmentAllowedTypes = strings.Replace(sec.Key("ALLOWED_TYPES").MustString("image/jpeg,image/png"), "|", ",", -1)
  425. AttachmentMaxSize = sec.Key("MAX_SIZE").MustInt64(4)
  426. AttachmentMaxFiles = sec.Key("MAX_FILES").MustInt(5)
  427. AttachmentEnabled = sec.Key("ENABLE").MustBool(true)
  428. TimeFormat = map[string]string{
  429. "ANSIC": time.ANSIC,
  430. "UnixDate": time.UnixDate,
  431. "RubyDate": time.RubyDate,
  432. "RFC822": time.RFC822,
  433. "RFC822Z": time.RFC822Z,
  434. "RFC850": time.RFC850,
  435. "RFC1123": time.RFC1123,
  436. "RFC1123Z": time.RFC1123Z,
  437. "RFC3339": time.RFC3339,
  438. "RFC3339Nano": time.RFC3339Nano,
  439. "Kitchen": time.Kitchen,
  440. "Stamp": time.Stamp,
  441. "StampMilli": time.StampMilli,
  442. "StampMicro": time.StampMicro,
  443. "StampNano": time.StampNano,
  444. }[Cfg.Section("time").Key("FORMAT").MustString("RFC1123")]
  445. RunUser = Cfg.Section("").Key("RUN_USER").String()
  446. // Does not check run user when the install lock is off.
  447. if InstallLock {
  448. currentUser, match := IsRunUserMatchCurrentUser(RunUser)
  449. if !match {
  450. log.Fatal(4, "Expect user '%s' but current user is: %s", RunUser, currentUser)
  451. }
  452. }
  453. // Determine and create root git repository path.
  454. sec = Cfg.Section("repository")
  455. Repository.DisableHTTPGit = sec.Key("DISABLE_HTTP_GIT").MustBool()
  456. RepoRootPath = sec.Key("ROOT").MustString(path.Join(homeDir, "gitea-repositories"))
  457. forcePathSeparator(RepoRootPath)
  458. if !filepath.IsAbs(RepoRootPath) {
  459. RepoRootPath = path.Join(workDir, RepoRootPath)
  460. } else {
  461. RepoRootPath = path.Clean(RepoRootPath)
  462. }
  463. ScriptType = sec.Key("SCRIPT_TYPE").MustString("bash")
  464. if err = Cfg.Section("repository").MapTo(&Repository); err != nil {
  465. log.Fatal(4, "Fail to map Repository settings: %v", err)
  466. } else if err = Cfg.Section("repository.editor").MapTo(&Repository.Editor); err != nil {
  467. log.Fatal(4, "Fail to map Repository.Editor settings: %v", err)
  468. } else if err = Cfg.Section("repository.upload").MapTo(&Repository.Upload); err != nil {
  469. log.Fatal(4, "Fail to map Repository.Upload settings: %v", err)
  470. }
  471. if !filepath.IsAbs(Repository.Upload.TempPath) {
  472. Repository.Upload.TempPath = path.Join(workDir, Repository.Upload.TempPath)
  473. }
  474. sec = Cfg.Section("picture")
  475. AvatarUploadPath = sec.Key("AVATAR_UPLOAD_PATH").MustString(path.Join(AppDataPath, "avatars"))
  476. forcePathSeparator(AvatarUploadPath)
  477. if !filepath.IsAbs(AvatarUploadPath) {
  478. AvatarUploadPath = path.Join(workDir, AvatarUploadPath)
  479. }
  480. switch source := sec.Key("GRAVATAR_SOURCE").MustString("gravatar"); source {
  481. case "duoshuo":
  482. GravatarSource = "http://gravatar.duoshuo.com/avatar/"
  483. case "gravatar":
  484. GravatarSource = "https://secure.gravatar.com/avatar/"
  485. default:
  486. GravatarSource = source
  487. }
  488. DisableGravatar = sec.Key("DISABLE_GRAVATAR").MustBool()
  489. EnableFederatedAvatar = sec.Key("ENABLE_FEDERATED_AVATAR").MustBool()
  490. if OfflineMode {
  491. DisableGravatar = true
  492. EnableFederatedAvatar = false
  493. }
  494. if DisableGravatar {
  495. EnableFederatedAvatar = false
  496. }
  497. if EnableFederatedAvatar {
  498. LibravatarService = libravatar.New()
  499. parts := strings.Split(GravatarSource, "/")
  500. if len(parts) >= 3 {
  501. if parts[0] == "https:" {
  502. LibravatarService.SetUseHTTPS(true)
  503. LibravatarService.SetSecureFallbackHost(parts[2])
  504. } else {
  505. LibravatarService.SetUseHTTPS(false)
  506. LibravatarService.SetFallbackHost(parts[2])
  507. }
  508. }
  509. }
  510. if err = Cfg.Section("ui").MapTo(&UI); err != nil {
  511. log.Fatal(4, "Fail to map UI settings: %v", err)
  512. } else if err = Cfg.Section("markdown").MapTo(&Markdown); err != nil {
  513. log.Fatal(4, "Fail to map Markdown settings: %v", err)
  514. } else if err = Cfg.Section("cron").MapTo(&Cron); err != nil {
  515. log.Fatal(4, "Fail to map Cron settings: %v", err)
  516. } else if err = Cfg.Section("git").MapTo(&Git); err != nil {
  517. log.Fatal(4, "Fail to map Git settings: %v", err)
  518. } else if err = Cfg.Section("mirror").MapTo(&Mirror); err != nil {
  519. log.Fatal(4, "Fail to map Mirror settings: %v", err)
  520. } else if err = Cfg.Section("api").MapTo(&API); err != nil {
  521. log.Fatal(4, "Fail to map API settings: %v", err)
  522. }
  523. if Mirror.DefaultInterval <= 0 {
  524. Mirror.DefaultInterval = 24
  525. }
  526. Langs = Cfg.Section("i18n").Key("LANGS").Strings(",")
  527. Names = Cfg.Section("i18n").Key("NAMES").Strings(",")
  528. dateLangs = Cfg.Section("i18n.datelang").KeysHash()
  529. ShowFooterBranding = Cfg.Section("other").Key("SHOW_FOOTER_BRANDING").MustBool()
  530. ShowFooterVersion = Cfg.Section("other").Key("SHOW_FOOTER_VERSION").MustBool()
  531. ShowFooterTemplateLoadTime = Cfg.Section("other").Key("SHOW_FOOTER_TEMPLATE_LOAD_TIME").MustBool()
  532. HasRobotsTxt = com.IsFile(path.Join(CustomPath, "robots.txt"))
  533. }
  534. // Service settings
  535. var Service struct {
  536. ActiveCodeLives int
  537. ResetPwdCodeLives int
  538. RegisterEmailConfirm bool
  539. DisableRegistration bool
  540. ShowRegistrationButton bool
  541. RequireSignInView bool
  542. EnableNotifyMail bool
  543. EnableReverseProxyAuth bool
  544. EnableReverseProxyAutoRegister bool
  545. EnableCaptcha bool
  546. }
  547. func newService() {
  548. sec := Cfg.Section("service")
  549. Service.ActiveCodeLives = sec.Key("ACTIVE_CODE_LIVE_MINUTES").MustInt(180)
  550. Service.ResetPwdCodeLives = sec.Key("RESET_PASSWD_CODE_LIVE_MINUTES").MustInt(180)
  551. Service.DisableRegistration = sec.Key("DISABLE_REGISTRATION").MustBool()
  552. Service.ShowRegistrationButton = sec.Key("SHOW_REGISTRATION_BUTTON").MustBool(!Service.DisableRegistration)
  553. Service.RequireSignInView = sec.Key("REQUIRE_SIGNIN_VIEW").MustBool()
  554. Service.EnableReverseProxyAuth = sec.Key("ENABLE_REVERSE_PROXY_AUTHENTICATION").MustBool()
  555. Service.EnableReverseProxyAutoRegister = sec.Key("ENABLE_REVERSE_PROXY_AUTO_REGISTRATION").MustBool()
  556. Service.EnableCaptcha = sec.Key("ENABLE_CAPTCHA").MustBool()
  557. }
  558. var logLevels = map[string]string{
  559. "Trace": "0",
  560. "Debug": "1",
  561. "Info": "2",
  562. "Warn": "3",
  563. "Error": "4",
  564. "Critical": "5",
  565. }
  566. func newLogService() {
  567. log.Info("%s %s", AppName, AppVer)
  568. if len(BuildTime) > 0 {
  569. log.Info("Build Time: %s", BuildTime)
  570. log.Info("Build Git Hash: %s", BuildGitHash)
  571. }
  572. // Get and check log mode.
  573. LogModes = strings.Split(Cfg.Section("log").Key("MODE").MustString("console"), ",")
  574. LogConfigs = make([]string, len(LogModes))
  575. for i, mode := range LogModes {
  576. mode = strings.TrimSpace(mode)
  577. sec, err := Cfg.GetSection("log." + mode)
  578. if err != nil {
  579. log.Fatal(4, "Unknown log mode: %s", mode)
  580. }
  581. validLevels := []string{"Trace", "Debug", "Info", "Warn", "Error", "Critical"}
  582. // Log level.
  583. levelName := Cfg.Section("log."+mode).Key("LEVEL").In(
  584. Cfg.Section("log").Key("LEVEL").In("Trace", validLevels),
  585. validLevels)
  586. level, ok := logLevels[levelName]
  587. if !ok {
  588. log.Fatal(4, "Unknown log level: %s", levelName)
  589. }
  590. // Generate log configuration.
  591. switch mode {
  592. case "console":
  593. LogConfigs[i] = fmt.Sprintf(`{"level":%s}`, level)
  594. case "file":
  595. logPath := sec.Key("FILE_NAME").MustString(path.Join(LogRootPath, "gogs.log"))
  596. if err = os.MkdirAll(path.Dir(logPath), os.ModePerm); err != nil {
  597. panic(err.Error())
  598. }
  599. LogConfigs[i] = fmt.Sprintf(
  600. `{"level":%s,"filename":"%s","rotate":%v,"maxlines":%d,"maxsize":%d,"daily":%v,"maxdays":%d}`, level,
  601. logPath,
  602. sec.Key("LOG_ROTATE").MustBool(true),
  603. sec.Key("MAX_LINES").MustInt(1000000),
  604. 1<<uint(sec.Key("MAX_SIZE_SHIFT").MustInt(28)),
  605. sec.Key("DAILY_ROTATE").MustBool(true),
  606. sec.Key("MAX_DAYS").MustInt(7))
  607. case "conn":
  608. LogConfigs[i] = fmt.Sprintf(`{"level":%s,"reconnectOnMsg":%v,"reconnect":%v,"net":"%s","addr":"%s"}`, level,
  609. sec.Key("RECONNECT_ON_MSG").MustBool(),
  610. sec.Key("RECONNECT").MustBool(),
  611. sec.Key("PROTOCOL").In("tcp", []string{"tcp", "unix", "udp"}),
  612. sec.Key("ADDR").MustString(":7020"))
  613. case "smtp":
  614. LogConfigs[i] = fmt.Sprintf(`{"level":%s,"username":"%s","password":"%s","host":"%s","sendTos":"%s","subject":"%s"}`, level,
  615. sec.Key("USER").MustString("example@example.com"),
  616. sec.Key("PASSWD").MustString("******"),
  617. sec.Key("HOST").MustString("127.0.0.1:25"),
  618. sec.Key("RECEIVERS").MustString("[]"),
  619. sec.Key("SUBJECT").MustString("Diagnostic message from serve"))
  620. case "database":
  621. LogConfigs[i] = fmt.Sprintf(`{"level":%s,"driver":"%s","conn":"%s"}`, level,
  622. sec.Key("DRIVER").String(),
  623. sec.Key("CONN").String())
  624. }
  625. log.NewLogger(Cfg.Section("log").Key("BUFFER_LEN").MustInt64(10000), mode, LogConfigs[i])
  626. log.Info("Log Mode: %s(%s)", strings.Title(mode), levelName)
  627. }
  628. }
  629. func newCacheService() {
  630. CacheAdapter = Cfg.Section("cache").Key("ADAPTER").In("memory", []string{"memory", "redis", "memcache"})
  631. switch CacheAdapter {
  632. case "memory":
  633. CacheInterval = Cfg.Section("cache").Key("INTERVAL").MustInt(60)
  634. case "redis", "memcache":
  635. CacheConn = strings.Trim(Cfg.Section("cache").Key("HOST").String(), "\" ")
  636. default:
  637. log.Fatal(4, "Unknown cache adapter: %s", CacheAdapter)
  638. }
  639. log.Info("Cache Service Enabled")
  640. }
  641. func newSessionService() {
  642. SessionConfig.Provider = Cfg.Section("session").Key("PROVIDER").In("memory",
  643. []string{"memory", "file", "redis", "mysql"})
  644. SessionConfig.ProviderConfig = strings.Trim(Cfg.Section("session").Key("PROVIDER_CONFIG").String(), "\" ")
  645. SessionConfig.CookieName = Cfg.Section("session").Key("COOKIE_NAME").MustString("i_like_gogits")
  646. SessionConfig.CookiePath = AppSubURL
  647. SessionConfig.Secure = Cfg.Section("session").Key("COOKIE_SECURE").MustBool()
  648. SessionConfig.Gclifetime = Cfg.Section("session").Key("GC_INTERVAL_TIME").MustInt64(86400)
  649. SessionConfig.Maxlifetime = Cfg.Section("session").Key("SESSION_LIFE_TIME").MustInt64(86400)
  650. log.Info("Session Service Enabled")
  651. }
  652. // Mailer represents mail service.
  653. type Mailer struct {
  654. QueueLength int
  655. Name string
  656. Host string
  657. From string
  658. FromEmail string
  659. User, Passwd string
  660. DisableHelo bool
  661. HeloHostname string
  662. SkipVerify bool
  663. UseCertificate bool
  664. CertFile, KeyFile string
  665. EnableHTMLAlternative bool
  666. }
  667. var (
  668. // MailService the global mailer
  669. MailService *Mailer
  670. )
  671. func newMailService() {
  672. sec := Cfg.Section("mailer")
  673. // Check mailer setting.
  674. if !sec.Key("ENABLED").MustBool() {
  675. return
  676. }
  677. MailService = &Mailer{
  678. QueueLength: sec.Key("SEND_BUFFER_LEN").MustInt(100),
  679. Name: sec.Key("NAME").MustString(AppName),
  680. Host: sec.Key("HOST").String(),
  681. User: sec.Key("USER").String(),
  682. Passwd: sec.Key("PASSWD").String(),
  683. DisableHelo: sec.Key("DISABLE_HELO").MustBool(),
  684. HeloHostname: sec.Key("HELO_HOSTNAME").String(),
  685. SkipVerify: sec.Key("SKIP_VERIFY").MustBool(),
  686. UseCertificate: sec.Key("USE_CERTIFICATE").MustBool(),
  687. CertFile: sec.Key("CERT_FILE").String(),
  688. KeyFile: sec.Key("KEY_FILE").String(),
  689. EnableHTMLAlternative: sec.Key("ENABLE_HTML_ALTERNATIVE").MustBool(),
  690. }
  691. MailService.From = sec.Key("FROM").MustString(MailService.User)
  692. parsed, err := mail.ParseAddress(MailService.From)
  693. if err != nil {
  694. log.Fatal(4, "Invalid mailer.FROM (%s): %v", MailService.From, err)
  695. }
  696. MailService.FromEmail = parsed.Address
  697. log.Info("Mail Service Enabled")
  698. }
  699. func newRegisterMailService() {
  700. if !Cfg.Section("service").Key("REGISTER_EMAIL_CONFIRM").MustBool() {
  701. return
  702. } else if MailService == nil {
  703. log.Warn("Register Mail Service: Mail Service is not enabled")
  704. return
  705. }
  706. Service.RegisterEmailConfirm = true
  707. log.Info("Register Mail Service Enabled")
  708. }
  709. func newNotifyMailService() {
  710. if !Cfg.Section("service").Key("ENABLE_NOTIFY_MAIL").MustBool() {
  711. return
  712. } else if MailService == nil {
  713. log.Warn("Notify Mail Service: Mail Service is not enabled")
  714. return
  715. }
  716. Service.EnableNotifyMail = true
  717. log.Info("Notify Mail Service Enabled")
  718. }
  719. func newWebhookService() {
  720. sec := Cfg.Section("webhook")
  721. Webhook.QueueLength = sec.Key("QUEUE_LENGTH").MustInt(1000)
  722. Webhook.DeliverTimeout = sec.Key("DELIVER_TIMEOUT").MustInt(5)
  723. Webhook.SkipTLSVerify = sec.Key("SKIP_TLS_VERIFY").MustBool()
  724. Webhook.Types = []string{"gogs", "slack"}
  725. Webhook.PagingNum = sec.Key("PAGING_NUM").MustInt(10)
  726. }
  727. // NewServices initializes the services
  728. func NewServices() {
  729. newService()
  730. newLogService()
  731. newCacheService()
  732. newSessionService()
  733. newMailService()
  734. newRegisterMailService()
  735. newNotifyMailService()
  736. newWebhookService()
  737. }