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 32 kB

11 years ago
11 years ago
11 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
8 years ago
11 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
8 years ago
11 years ago
11 years ago
11 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
8 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
11 years ago
11 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
8 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
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
8 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
8 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
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
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
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
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091
  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. "crypto/rand"
  7. "encoding/base64"
  8. "fmt"
  9. "io"
  10. "net/mail"
  11. "net/url"
  12. "os"
  13. "os/exec"
  14. "path"
  15. "path/filepath"
  16. "runtime"
  17. "strconv"
  18. "strings"
  19. "time"
  20. "code.gitea.io/git"
  21. "code.gitea.io/gitea/modules/log"
  22. "code.gitea.io/gitea/modules/user"
  23. "github.com/Unknwon/com"
  24. _ "github.com/go-macaron/cache/memcache" // memcache plugin for cache
  25. _ "github.com/go-macaron/cache/redis"
  26. "github.com/go-macaron/session"
  27. _ "github.com/go-macaron/session/redis" // redis plugin for store session
  28. _ "github.com/kardianos/minwinsvc" // import minwinsvc for windows services
  29. "gopkg.in/ini.v1"
  30. "strk.kbt.io/projects/go/libravatar"
  31. )
  32. // Scheme describes protocol types
  33. type Scheme string
  34. // enumerates all the scheme types
  35. const (
  36. HTTP Scheme = "http"
  37. HTTPS Scheme = "https"
  38. FCGI Scheme = "fcgi"
  39. UnixSocket Scheme = "unix"
  40. )
  41. // LandingPage describes the default page
  42. type LandingPage string
  43. // enumerates all the landing page types
  44. const (
  45. LandingPageHome LandingPage = "/"
  46. LandingPageExplore LandingPage = "/explore"
  47. )
  48. // settings
  49. var (
  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. ListenHost string `ini:"SSH_LISTEN_HOST"`
  78. ListenPort int `ini:"SSH_LISTEN_PORT"`
  79. RootPath string `ini:"SSH_ROOT_PATH"`
  80. KeyTestPath string `ini:"SSH_KEY_TEST_PATH"`
  81. KeygenPath string `ini:"SSH_KEYGEN_PATH"`
  82. MinimumKeySizeCheck bool `ini:"-"`
  83. MinimumKeySizes map[string]int `ini:"-"`
  84. }{
  85. Disabled: false,
  86. StartBuiltinServer: false,
  87. Domain: "localhost",
  88. Port: 22,
  89. KeygenPath: "ssh-keygen",
  90. }
  91. LFS struct {
  92. StartServer bool `ini:"LFS_START_SERVER"`
  93. ContentPath string `ini:"LFS_CONTENT_PATH"`
  94. JWTSecretBase64 string `ini:"LFS_JWT_SECRET"`
  95. JWTSecretBytes []byte `ini:"-"`
  96. }
  97. // Security settings
  98. InstallLock bool
  99. SecretKey string
  100. LogInRememberDays int
  101. CookieUserName string
  102. CookieRememberName string
  103. ReverseProxyAuthUser string
  104. MinPasswordLength int
  105. // Database settings
  106. UseSQLite3 bool
  107. UseMySQL bool
  108. UseMSSQL bool
  109. UsePostgreSQL bool
  110. UseTiDB bool
  111. // Webhook settings
  112. Webhook = struct {
  113. QueueLength int
  114. DeliverTimeout int
  115. SkipTLSVerify bool
  116. Types []string
  117. PagingNum int
  118. }{
  119. QueueLength: 1000,
  120. DeliverTimeout: 5,
  121. SkipTLSVerify: false,
  122. PagingNum: 10,
  123. }
  124. // Repository settings
  125. Repository = struct {
  126. AnsiCharset string
  127. ForcePrivate bool
  128. MaxCreationLimit int
  129. MirrorQueueLength int
  130. PullRequestQueueLength int
  131. PreferredLicenses []string
  132. DisableHTTPGit bool
  133. // Repository editor settings
  134. Editor struct {
  135. LineWrapExtensions []string
  136. PreviewableFileModes []string
  137. } `ini:"-"`
  138. // Repository upload settings
  139. Upload struct {
  140. Enabled bool
  141. TempPath string
  142. AllowedTypes []string `delim:"|"`
  143. FileMaxSize int64
  144. MaxFiles int
  145. } `ini:"-"`
  146. }{
  147. AnsiCharset: "",
  148. ForcePrivate: false,
  149. MaxCreationLimit: -1,
  150. MirrorQueueLength: 1000,
  151. PullRequestQueueLength: 1000,
  152. PreferredLicenses: []string{"Apache License 2.0,MIT License"},
  153. DisableHTTPGit: false,
  154. // Repository editor settings
  155. Editor: struct {
  156. LineWrapExtensions []string
  157. PreviewableFileModes []string
  158. }{
  159. LineWrapExtensions: strings.Split(".txt,.md,.markdown,.mdown,.mkd,", ","),
  160. PreviewableFileModes: []string{"markdown"},
  161. },
  162. // Repository upload settings
  163. Upload: struct {
  164. Enabled bool
  165. TempPath string
  166. AllowedTypes []string `delim:"|"`
  167. FileMaxSize int64
  168. MaxFiles int
  169. }{
  170. Enabled: true,
  171. TempPath: "data/tmp/uploads",
  172. AllowedTypes: []string{},
  173. FileMaxSize: 3,
  174. MaxFiles: 5,
  175. },
  176. }
  177. RepoRootPath string
  178. ScriptType = "bash"
  179. // UI settings
  180. UI = struct {
  181. ExplorePagingNum int
  182. IssuePagingNum int
  183. FeedMaxCommitNum int
  184. ThemeColorMetaTag string
  185. MaxDisplayFileSize int64
  186. ShowUserEmail bool
  187. Admin struct {
  188. UserPagingNum int
  189. RepoPagingNum int
  190. NoticePagingNum int
  191. OrgPagingNum int
  192. } `ini:"ui.admin"`
  193. User struct {
  194. RepoPagingNum int
  195. } `ini:"ui.user"`
  196. }{
  197. ExplorePagingNum: 20,
  198. IssuePagingNum: 10,
  199. FeedMaxCommitNum: 5,
  200. ThemeColorMetaTag: `#6cc644`,
  201. MaxDisplayFileSize: 8388608,
  202. Admin: struct {
  203. UserPagingNum int
  204. RepoPagingNum int
  205. NoticePagingNum int
  206. OrgPagingNum int
  207. }{
  208. UserPagingNum: 50,
  209. RepoPagingNum: 50,
  210. NoticePagingNum: 25,
  211. OrgPagingNum: 50,
  212. },
  213. User: struct {
  214. RepoPagingNum int
  215. }{
  216. RepoPagingNum: 15,
  217. },
  218. }
  219. // Markdown sttings
  220. Markdown = struct {
  221. EnableHardLineBreak bool
  222. CustomURLSchemes []string `ini:"CUSTOM_URL_SCHEMES"`
  223. FileExtensions []string
  224. }{
  225. EnableHardLineBreak: false,
  226. FileExtensions: strings.Split(".md,.markdown,.mdown,.mkd", ","),
  227. }
  228. // Picture settings
  229. AvatarUploadPath string
  230. GravatarSource string
  231. DisableGravatar bool
  232. EnableFederatedAvatar bool
  233. LibravatarService *libravatar.Libravatar
  234. // Log settings
  235. LogRootPath string
  236. LogModes []string
  237. LogConfigs []string
  238. // Attachment settings
  239. AttachmentPath string
  240. AttachmentAllowedTypes string
  241. AttachmentMaxSize int64
  242. AttachmentMaxFiles int
  243. AttachmentEnabled bool
  244. // Time settings
  245. TimeFormat string
  246. // Cache settings
  247. CacheAdapter string
  248. CacheInterval int
  249. CacheConn string
  250. // Session settings
  251. SessionConfig session.Options
  252. CSRFCookieName = "_csrf"
  253. // Cron tasks
  254. Cron = struct {
  255. UpdateMirror struct {
  256. Enabled bool
  257. RunAtStart bool
  258. Schedule string
  259. } `ini:"cron.update_mirrors"`
  260. RepoHealthCheck struct {
  261. Enabled bool
  262. RunAtStart bool
  263. Schedule string
  264. Timeout time.Duration
  265. Args []string `delim:" "`
  266. } `ini:"cron.repo_health_check"`
  267. CheckRepoStats struct {
  268. Enabled bool
  269. RunAtStart bool
  270. Schedule string
  271. } `ini:"cron.check_repo_stats"`
  272. }{
  273. UpdateMirror: struct {
  274. Enabled bool
  275. RunAtStart bool
  276. Schedule string
  277. }{
  278. Schedule: "@every 10m",
  279. },
  280. RepoHealthCheck: struct {
  281. Enabled bool
  282. RunAtStart bool
  283. Schedule string
  284. Timeout time.Duration
  285. Args []string `delim:" "`
  286. }{
  287. Schedule: "@every 24h",
  288. Timeout: 60 * time.Second,
  289. Args: []string{},
  290. },
  291. CheckRepoStats: struct {
  292. Enabled bool
  293. RunAtStart bool
  294. Schedule string
  295. }{
  296. RunAtStart: true,
  297. Schedule: "@every 24h",
  298. },
  299. }
  300. // Git settings
  301. Git = struct {
  302. DisableDiffHighlight bool
  303. MaxGitDiffLines int
  304. MaxGitDiffLineCharacters int
  305. MaxGitDiffFiles int
  306. GCArgs []string `delim:" "`
  307. Timeout struct {
  308. Migrate int
  309. Mirror int
  310. Clone int
  311. Pull int
  312. GC int `ini:"GC"`
  313. } `ini:"git.timeout"`
  314. }{
  315. DisableDiffHighlight: false,
  316. MaxGitDiffLines: 1000,
  317. MaxGitDiffLineCharacters: 500,
  318. MaxGitDiffFiles: 100,
  319. GCArgs: []string{},
  320. Timeout: struct {
  321. Migrate int
  322. Mirror int
  323. Clone int
  324. Pull int
  325. GC int `ini:"GC"`
  326. }{
  327. Migrate: 600,
  328. Mirror: 300,
  329. Clone: 300,
  330. Pull: 300,
  331. GC: 60,
  332. },
  333. }
  334. // Mirror settings
  335. Mirror = struct {
  336. DefaultInterval int
  337. }{
  338. DefaultInterval: 8,
  339. }
  340. // API settings
  341. API = struct {
  342. MaxResponseItems int
  343. }{
  344. MaxResponseItems: 50,
  345. }
  346. // I18n settings
  347. Langs []string
  348. Names []string
  349. dateLangs map[string]string
  350. // Highlight settings are loaded in modules/template/hightlight.go
  351. // Other settings
  352. ShowFooterBranding bool
  353. ShowFooterVersion bool
  354. ShowFooterTemplateLoadTime bool
  355. // Global setting objects
  356. Cfg *ini.File
  357. CustomPath string // Custom directory path
  358. CustomConf string
  359. CustomPID string
  360. ProdMode bool
  361. RunUser string
  362. IsWindows bool
  363. HasRobotsTxt bool
  364. )
  365. // DateLang transforms standard language locale name to corresponding value in datetime plugin.
  366. func DateLang(lang string) string {
  367. name, ok := dateLangs[lang]
  368. if ok {
  369. return name
  370. }
  371. return "en"
  372. }
  373. // execPath returns the executable path.
  374. func execPath() (string, error) {
  375. file, err := exec.LookPath(os.Args[0])
  376. if err != nil {
  377. return "", err
  378. }
  379. return filepath.Abs(file)
  380. }
  381. func init() {
  382. IsWindows = runtime.GOOS == "windows"
  383. log.NewLogger(0, "console", `{"level": 0}`)
  384. var err error
  385. if AppPath, err = execPath(); err != nil {
  386. log.Fatal(4, "fail to get app path: %v\n", err)
  387. }
  388. // Note: we don't use path.Dir here because it does not handle case
  389. // which path starts with two "/" in Windows: "//psf/Home/..."
  390. AppPath = strings.Replace(AppPath, "\\", "/", -1)
  391. }
  392. // WorkDir returns absolute path of work directory.
  393. func WorkDir() (string, error) {
  394. wd := os.Getenv("GITEA_WORK_DIR")
  395. if len(wd) > 0 {
  396. return wd, nil
  397. }
  398. // Use GOGS_WORK_DIR if available, for backward compatibility
  399. // TODO: drop in 1.1.0 ?
  400. wd = os.Getenv("GOGS_WORK_DIR")
  401. if len(wd) > 0 {
  402. log.Warn(`Usage of GOGS_WORK_DIR is deprecated and will be *removed* in a future release,
  403. please consider changing to GITEA_WORK_DIR`)
  404. return wd, nil
  405. }
  406. i := strings.LastIndex(AppPath, "/")
  407. if i == -1 {
  408. return AppPath, nil
  409. }
  410. return AppPath[:i], nil
  411. }
  412. func forcePathSeparator(path string) {
  413. if strings.Contains(path, "\\") {
  414. log.Fatal(4, "Do not use '\\' or '\\\\' in paths, instead, please use '/' in all places")
  415. }
  416. }
  417. // IsRunUserMatchCurrentUser returns false if configured run user does not match
  418. // actual user that runs the app. The first return value is the actual user name.
  419. // This check is ignored under Windows since SSH remote login is not the main
  420. // method to login on Windows.
  421. func IsRunUserMatchCurrentUser(runUser string) (string, bool) {
  422. if IsWindows {
  423. return "", true
  424. }
  425. currentUser := user.CurrentUsername()
  426. return currentUser, runUser == currentUser
  427. }
  428. func createPIDFile(pidPath string) {
  429. currentPid := os.Getpid()
  430. if err := os.MkdirAll(filepath.Dir(pidPath), os.ModePerm); err != nil {
  431. log.Fatal(4, "Can't create PID folder on %s", err)
  432. }
  433. file, err := os.Create(pidPath)
  434. if err != nil {
  435. log.Fatal(4, "Can't create PID file: %v", err)
  436. }
  437. defer file.Close()
  438. if _, err := file.WriteString(strconv.FormatInt(int64(currentPid), 10)); err != nil {
  439. log.Fatal(4, "Can'write PID information on %s", err)
  440. }
  441. }
  442. // NewContext initializes configuration context.
  443. // NOTE: do not print any log except error.
  444. func NewContext() {
  445. workDir, err := WorkDir()
  446. if err != nil {
  447. log.Fatal(4, "Fail to get work directory: %v", err)
  448. }
  449. Cfg = ini.Empty()
  450. if err != nil {
  451. log.Fatal(4, "Fail to parse 'app.ini': %v", err)
  452. }
  453. CustomPath = os.Getenv("GITEA_CUSTOM")
  454. if len(CustomPath) == 0 {
  455. // For backward compatibility
  456. // TODO: drop in 1.1.0 ?
  457. CustomPath = os.Getenv("GOGS_CUSTOM")
  458. if len(CustomPath) == 0 {
  459. CustomPath = workDir + "/custom"
  460. } else {
  461. log.Warn(`Usage of GOGS_CUSTOM is deprecated and will be *removed* in a future release,
  462. please consider changing to GITEA_CUSTOM`)
  463. }
  464. }
  465. if len(CustomPID) > 0 {
  466. createPIDFile(CustomPID)
  467. }
  468. if len(CustomConf) == 0 {
  469. CustomConf = CustomPath + "/conf/app.ini"
  470. }
  471. if com.IsFile(CustomConf) {
  472. if err = Cfg.Append(CustomConf); err != nil {
  473. log.Fatal(4, "Fail to load custom conf '%s': %v", CustomConf, err)
  474. }
  475. } else {
  476. log.Warn("Custom config '%s' not found, ignore this if you're running first time", CustomConf)
  477. }
  478. Cfg.NameMapper = ini.AllCapsUnderscore
  479. homeDir, err := com.HomeDir()
  480. if err != nil {
  481. log.Fatal(4, "Fail to get home directory: %v", err)
  482. }
  483. homeDir = strings.Replace(homeDir, "\\", "/", -1)
  484. LogRootPath = Cfg.Section("log").Key("ROOT_PATH").MustString(path.Join(workDir, "log"))
  485. forcePathSeparator(LogRootPath)
  486. sec := Cfg.Section("server")
  487. AppName = Cfg.Section("").Key("APP_NAME").MustString("Gitea: Git with a cup of tea")
  488. AppURL = sec.Key("ROOT_URL").MustString("http://localhost:3000/")
  489. if AppURL[len(AppURL)-1] != '/' {
  490. AppURL += "/"
  491. }
  492. // Check if has app suburl.
  493. url, err := url.Parse(AppURL)
  494. if err != nil {
  495. log.Fatal(4, "Invalid ROOT_URL '%s': %s", AppURL, err)
  496. }
  497. // Suburl should start with '/' and end without '/', such as '/{subpath}'.
  498. // This value is empty if site does not have sub-url.
  499. AppSubURL = strings.TrimSuffix(url.Path, "/")
  500. AppSubURLDepth = strings.Count(AppSubURL, "/")
  501. Protocol = HTTP
  502. if sec.Key("PROTOCOL").String() == "https" {
  503. Protocol = HTTPS
  504. CertFile = sec.Key("CERT_FILE").String()
  505. KeyFile = sec.Key("KEY_FILE").String()
  506. } else if sec.Key("PROTOCOL").String() == "fcgi" {
  507. Protocol = FCGI
  508. } else if sec.Key("PROTOCOL").String() == "unix" {
  509. Protocol = UnixSocket
  510. UnixSocketPermissionRaw := sec.Key("UNIX_SOCKET_PERMISSION").MustString("666")
  511. UnixSocketPermissionParsed, err := strconv.ParseUint(UnixSocketPermissionRaw, 8, 32)
  512. if err != nil || UnixSocketPermissionParsed > 0777 {
  513. log.Fatal(4, "Fail to parse unixSocketPermission: %s", UnixSocketPermissionRaw)
  514. }
  515. UnixSocketPermission = uint32(UnixSocketPermissionParsed)
  516. }
  517. Domain = sec.Key("DOMAIN").MustString("localhost")
  518. HTTPAddr = sec.Key("HTTP_ADDR").MustString("0.0.0.0")
  519. HTTPPort = sec.Key("HTTP_PORT").MustString("3000")
  520. LocalURL = sec.Key("LOCAL_ROOT_URL").MustString(string(Protocol) + "://localhost:" + HTTPPort + "/")
  521. OfflineMode = sec.Key("OFFLINE_MODE").MustBool()
  522. DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool()
  523. StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(workDir)
  524. AppDataPath = sec.Key("APP_DATA_PATH").MustString("data")
  525. EnableGzip = sec.Key("ENABLE_GZIP").MustBool()
  526. switch sec.Key("LANDING_PAGE").MustString("home") {
  527. case "explore":
  528. LandingPageURL = LandingPageExplore
  529. default:
  530. LandingPageURL = LandingPageHome
  531. }
  532. SSH.RootPath = path.Join(homeDir, ".ssh")
  533. SSH.KeyTestPath = os.TempDir()
  534. if err = Cfg.Section("server").MapTo(&SSH); err != nil {
  535. log.Fatal(4, "Fail to map SSH settings: %v", err)
  536. }
  537. SSH.KeygenPath = sec.Key("SSH_KEYGEN_PATH").MustString("ssh-keygen")
  538. SSH.Port = sec.Key("SSH_PORT").MustInt(22)
  539. SSH.ListenPort = sec.Key("SSH_LISTEN_PORT").MustInt(SSH.Port)
  540. // When disable SSH, start builtin server value is ignored.
  541. if SSH.Disabled {
  542. SSH.StartBuiltinServer = false
  543. }
  544. if !SSH.Disabled && !SSH.StartBuiltinServer {
  545. if err := os.MkdirAll(SSH.RootPath, 0700); err != nil {
  546. log.Fatal(4, "Fail to create '%s': %v", SSH.RootPath, err)
  547. } else if err = os.MkdirAll(SSH.KeyTestPath, 0644); err != nil {
  548. log.Fatal(4, "Fail to create '%s': %v", SSH.KeyTestPath, err)
  549. }
  550. }
  551. SSH.MinimumKeySizeCheck = sec.Key("MINIMUM_KEY_SIZE_CHECK").MustBool()
  552. SSH.MinimumKeySizes = map[string]int{}
  553. minimumKeySizes := Cfg.Section("ssh.minimum_key_sizes").Keys()
  554. for _, key := range minimumKeySizes {
  555. if key.MustInt() != -1 {
  556. SSH.MinimumKeySizes[strings.ToLower(key.Name())] = key.MustInt()
  557. }
  558. }
  559. if err = Cfg.Section("server").MapTo(&LFS); err != nil {
  560. log.Fatal(4, "Fail to map LFS settings: %v", err)
  561. }
  562. if LFS.StartServer {
  563. if err := os.MkdirAll(LFS.ContentPath, 0700); err != nil {
  564. log.Fatal(4, "Fail to create '%s': %v", LFS.ContentPath, err)
  565. }
  566. LFS.JWTSecretBytes = make([]byte, 32)
  567. n, err := base64.RawURLEncoding.Decode(LFS.JWTSecretBytes, []byte(LFS.JWTSecretBase64))
  568. if err != nil || n != 32 {
  569. //Generate new secret and save to config
  570. _, err := io.ReadFull(rand.Reader, LFS.JWTSecretBytes)
  571. if err != nil {
  572. log.Fatal(4, "Error reading random bytes: %s", err)
  573. }
  574. LFS.JWTSecretBase64 = base64.RawURLEncoding.EncodeToString(LFS.JWTSecretBytes)
  575. // Save secret
  576. cfg := ini.Empty()
  577. if com.IsFile(CustomConf) {
  578. // Keeps custom settings if there is already something.
  579. if err := cfg.Append(CustomConf); err != nil {
  580. log.Error(4, "Fail to load custom conf '%s': %v", CustomConf, err)
  581. }
  582. }
  583. cfg.Section("server").Key("LFS_JWT_SECRET").SetValue(LFS.JWTSecretBase64)
  584. if err := os.MkdirAll(filepath.Dir(CustomConf), os.ModePerm); err != nil {
  585. log.Fatal(4, "Fail to create '%s': %v", CustomConf, err)
  586. }
  587. if err := cfg.SaveTo(CustomConf); err != nil {
  588. log.Fatal(4, "Error saving generated JWT Secret to custom config: %v", err)
  589. return
  590. }
  591. }
  592. //Disable LFS client hooks if installed for the current OS user
  593. //Needs at least git v2.1.2
  594. binVersion, err := git.BinVersion()
  595. if err != nil {
  596. log.Fatal(4, "Error retrieving git version: %s", err)
  597. }
  598. splitVersion := strings.SplitN(binVersion, ".", 3)
  599. majorVersion, err := strconv.ParseUint(splitVersion[0], 10, 64)
  600. if err != nil {
  601. log.Fatal(4, "Error parsing git major version: %s", err)
  602. }
  603. minorVersion, err := strconv.ParseUint(splitVersion[1], 10, 64)
  604. if err != nil {
  605. log.Fatal(4, "Error parsing git minor version: %s", err)
  606. }
  607. revisionVersion, err := strconv.ParseUint(splitVersion[2], 10, 64)
  608. if err != nil {
  609. log.Fatal(4, "Error parsing git revision version: %s", err)
  610. }
  611. if !((majorVersion > 2) || (majorVersion == 2 && minorVersion > 1) ||
  612. (majorVersion == 2 && minorVersion == 1 && revisionVersion >= 2)) {
  613. LFS.StartServer = false
  614. log.Error(4, "LFS server support needs at least Git v2.1.2")
  615. } else {
  616. git.GlobalCommandArgs = append(git.GlobalCommandArgs, "-c", "filter.lfs.required=",
  617. "-c", "filter.lfs.smudge=", "-c", "filter.lfs.clean=")
  618. }
  619. }
  620. sec = Cfg.Section("security")
  621. InstallLock = sec.Key("INSTALL_LOCK").MustBool(false)
  622. SecretKey = sec.Key("SECRET_KEY").MustString("!#@FDEWREWR&*(")
  623. LogInRememberDays = sec.Key("LOGIN_REMEMBER_DAYS").MustInt(7)
  624. CookieUserName = sec.Key("COOKIE_USERNAME").MustString("gitea_awesome")
  625. CookieRememberName = sec.Key("COOKIE_REMEMBER_NAME").MustString("gitea_incredible")
  626. ReverseProxyAuthUser = sec.Key("REVERSE_PROXY_AUTHENTICATION_USER").MustString("X-WEBAUTH-USER")
  627. MinPasswordLength = sec.Key("MIN_PASSWORD_LENGTH").MustInt(6)
  628. sec = Cfg.Section("attachment")
  629. AttachmentPath = sec.Key("PATH").MustString(path.Join(AppDataPath, "attachments"))
  630. if !filepath.IsAbs(AttachmentPath) {
  631. AttachmentPath = path.Join(workDir, AttachmentPath)
  632. }
  633. AttachmentAllowedTypes = strings.Replace(sec.Key("ALLOWED_TYPES").MustString("image/jpeg,image/png,application/zip,application/gzip"), "|", ",", -1)
  634. AttachmentMaxSize = sec.Key("MAX_SIZE").MustInt64(4)
  635. AttachmentMaxFiles = sec.Key("MAX_FILES").MustInt(5)
  636. AttachmentEnabled = sec.Key("ENABLE").MustBool(true)
  637. TimeFormat = map[string]string{
  638. "ANSIC": time.ANSIC,
  639. "UnixDate": time.UnixDate,
  640. "RubyDate": time.RubyDate,
  641. "RFC822": time.RFC822,
  642. "RFC822Z": time.RFC822Z,
  643. "RFC850": time.RFC850,
  644. "RFC1123": time.RFC1123,
  645. "RFC1123Z": time.RFC1123Z,
  646. "RFC3339": time.RFC3339,
  647. "RFC3339Nano": time.RFC3339Nano,
  648. "Kitchen": time.Kitchen,
  649. "Stamp": time.Stamp,
  650. "StampMilli": time.StampMilli,
  651. "StampMicro": time.StampMicro,
  652. "StampNano": time.StampNano,
  653. }[Cfg.Section("time").Key("FORMAT").MustString("RFC1123")]
  654. RunUser = Cfg.Section("").Key("RUN_USER").MustString(user.CurrentUsername())
  655. // Does not check run user when the install lock is off.
  656. if InstallLock {
  657. currentUser, match := IsRunUserMatchCurrentUser(RunUser)
  658. if !match {
  659. log.Fatal(4, "Expect user '%s' but current user is: %s", RunUser, currentUser)
  660. }
  661. }
  662. // Determine and create root git repository path.
  663. sec = Cfg.Section("repository")
  664. Repository.DisableHTTPGit = sec.Key("DISABLE_HTTP_GIT").MustBool()
  665. RepoRootPath = sec.Key("ROOT").MustString(path.Join(homeDir, "gitea-repositories"))
  666. forcePathSeparator(RepoRootPath)
  667. if !filepath.IsAbs(RepoRootPath) {
  668. RepoRootPath = path.Join(workDir, RepoRootPath)
  669. } else {
  670. RepoRootPath = path.Clean(RepoRootPath)
  671. }
  672. ScriptType = sec.Key("SCRIPT_TYPE").MustString("bash")
  673. if err = Cfg.Section("repository").MapTo(&Repository); err != nil {
  674. log.Fatal(4, "Fail to map Repository settings: %v", err)
  675. } else if err = Cfg.Section("repository.editor").MapTo(&Repository.Editor); err != nil {
  676. log.Fatal(4, "Fail to map Repository.Editor settings: %v", err)
  677. } else if err = Cfg.Section("repository.upload").MapTo(&Repository.Upload); err != nil {
  678. log.Fatal(4, "Fail to map Repository.Upload settings: %v", err)
  679. }
  680. if !filepath.IsAbs(Repository.Upload.TempPath) {
  681. Repository.Upload.TempPath = path.Join(workDir, Repository.Upload.TempPath)
  682. }
  683. sec = Cfg.Section("picture")
  684. AvatarUploadPath = sec.Key("AVATAR_UPLOAD_PATH").MustString(path.Join(AppDataPath, "avatars"))
  685. forcePathSeparator(AvatarUploadPath)
  686. if !filepath.IsAbs(AvatarUploadPath) {
  687. AvatarUploadPath = path.Join(workDir, AvatarUploadPath)
  688. }
  689. switch source := sec.Key("GRAVATAR_SOURCE").MustString("gravatar"); source {
  690. case "duoshuo":
  691. GravatarSource = "http://gravatar.duoshuo.com/avatar/"
  692. case "gravatar":
  693. GravatarSource = "https://secure.gravatar.com/avatar/"
  694. case "libravatar":
  695. GravatarSource = "https://seccdn.libravatar.org/avatar/"
  696. default:
  697. GravatarSource = source
  698. }
  699. DisableGravatar = sec.Key("DISABLE_GRAVATAR").MustBool()
  700. EnableFederatedAvatar = sec.Key("ENABLE_FEDERATED_AVATAR").MustBool()
  701. if OfflineMode {
  702. DisableGravatar = true
  703. EnableFederatedAvatar = false
  704. }
  705. if DisableGravatar {
  706. EnableFederatedAvatar = false
  707. }
  708. if EnableFederatedAvatar {
  709. LibravatarService = libravatar.New()
  710. parts := strings.Split(GravatarSource, "/")
  711. if len(parts) >= 3 {
  712. if parts[0] == "https:" {
  713. LibravatarService.SetUseHTTPS(true)
  714. LibravatarService.SetSecureFallbackHost(parts[2])
  715. } else {
  716. LibravatarService.SetUseHTTPS(false)
  717. LibravatarService.SetFallbackHost(parts[2])
  718. }
  719. }
  720. }
  721. if err = Cfg.Section("ui").MapTo(&UI); err != nil {
  722. log.Fatal(4, "Fail to map UI settings: %v", err)
  723. } else if err = Cfg.Section("markdown").MapTo(&Markdown); err != nil {
  724. log.Fatal(4, "Fail to map Markdown settings: %v", err)
  725. } else if err = Cfg.Section("cron").MapTo(&Cron); err != nil {
  726. log.Fatal(4, "Fail to map Cron settings: %v", err)
  727. } else if err = Cfg.Section("git").MapTo(&Git); err != nil {
  728. log.Fatal(4, "Fail to map Git settings: %v", err)
  729. } else if err = Cfg.Section("mirror").MapTo(&Mirror); err != nil {
  730. log.Fatal(4, "Fail to map Mirror settings: %v", err)
  731. } else if err = Cfg.Section("api").MapTo(&API); err != nil {
  732. log.Fatal(4, "Fail to map API settings: %v", err)
  733. }
  734. if Mirror.DefaultInterval <= 0 {
  735. Mirror.DefaultInterval = 24
  736. }
  737. Langs = Cfg.Section("i18n").Key("LANGS").Strings(",")
  738. if len(Langs) == 0 {
  739. Langs = defaultLangs
  740. }
  741. Names = Cfg.Section("i18n").Key("NAMES").Strings(",")
  742. if len(Names) == 0 {
  743. Names = defaultLangNames
  744. }
  745. dateLangs = Cfg.Section("i18n.datelang").KeysHash()
  746. ShowFooterBranding = Cfg.Section("other").Key("SHOW_FOOTER_BRANDING").MustBool(false)
  747. ShowFooterVersion = Cfg.Section("other").Key("SHOW_FOOTER_VERSION").MustBool(true)
  748. ShowFooterTemplateLoadTime = Cfg.Section("other").Key("SHOW_FOOTER_TEMPLATE_LOAD_TIME").MustBool(true)
  749. UI.ShowUserEmail = Cfg.Section("ui").Key("SHOW_USER_EMAIL").MustBool(true)
  750. HasRobotsTxt = com.IsFile(path.Join(CustomPath, "robots.txt"))
  751. }
  752. // Service settings
  753. var Service struct {
  754. ActiveCodeLives int
  755. ResetPwdCodeLives int
  756. RegisterEmailConfirm bool
  757. DisableRegistration bool
  758. ShowRegistrationButton bool
  759. RequireSignInView bool
  760. EnableNotifyMail bool
  761. EnableReverseProxyAuth bool
  762. EnableReverseProxyAutoRegister bool
  763. EnableCaptcha bool
  764. DefaultKeepEmailPrivate bool
  765. NoReplyAddress string
  766. }
  767. func newService() {
  768. sec := Cfg.Section("service")
  769. Service.ActiveCodeLives = sec.Key("ACTIVE_CODE_LIVE_MINUTES").MustInt(180)
  770. Service.ResetPwdCodeLives = sec.Key("RESET_PASSWD_CODE_LIVE_MINUTES").MustInt(180)
  771. Service.DisableRegistration = sec.Key("DISABLE_REGISTRATION").MustBool()
  772. Service.ShowRegistrationButton = sec.Key("SHOW_REGISTRATION_BUTTON").MustBool(!Service.DisableRegistration)
  773. Service.RequireSignInView = sec.Key("REQUIRE_SIGNIN_VIEW").MustBool()
  774. Service.EnableReverseProxyAuth = sec.Key("ENABLE_REVERSE_PROXY_AUTHENTICATION").MustBool()
  775. Service.EnableReverseProxyAutoRegister = sec.Key("ENABLE_REVERSE_PROXY_AUTO_REGISTRATION").MustBool()
  776. Service.EnableCaptcha = sec.Key("ENABLE_CAPTCHA").MustBool()
  777. Service.DefaultKeepEmailPrivate = sec.Key("DEFAULT_KEEP_EMAIL_PRIVATE").MustBool()
  778. Service.NoReplyAddress = sec.Key("NO_REPLY_ADDRESS").MustString("noreply.example.org")
  779. }
  780. var logLevels = map[string]string{
  781. "Trace": "0",
  782. "Debug": "1",
  783. "Info": "2",
  784. "Warn": "3",
  785. "Error": "4",
  786. "Critical": "5",
  787. }
  788. func newLogService() {
  789. log.Info("Gitea v%s", AppVer)
  790. LogModes = strings.Split(Cfg.Section("log").Key("MODE").MustString("console"), ",")
  791. LogConfigs = make([]string, len(LogModes))
  792. for i, mode := range LogModes {
  793. mode = strings.TrimSpace(mode)
  794. sec, err := Cfg.GetSection("log." + mode)
  795. if err != nil {
  796. sec, _ = Cfg.NewSection("log." + mode)
  797. }
  798. validLevels := []string{"Trace", "Debug", "Info", "Warn", "Error", "Critical"}
  799. // Log level.
  800. levelName := Cfg.Section("log."+mode).Key("LEVEL").In(
  801. Cfg.Section("log").Key("LEVEL").In("Trace", validLevels),
  802. validLevels)
  803. level, ok := logLevels[levelName]
  804. if !ok {
  805. log.Fatal(4, "Unknown log level: %s", levelName)
  806. }
  807. // Generate log configuration.
  808. switch mode {
  809. case "console":
  810. LogConfigs[i] = fmt.Sprintf(`{"level":%s}`, level)
  811. case "file":
  812. logPath := sec.Key("FILE_NAME").MustString(path.Join(LogRootPath, "gogs.log"))
  813. if err = os.MkdirAll(path.Dir(logPath), os.ModePerm); err != nil {
  814. panic(err.Error())
  815. }
  816. LogConfigs[i] = fmt.Sprintf(
  817. `{"level":%s,"filename":"%s","rotate":%v,"maxlines":%d,"maxsize":%d,"daily":%v,"maxdays":%d}`, level,
  818. logPath,
  819. sec.Key("LOG_ROTATE").MustBool(true),
  820. sec.Key("MAX_LINES").MustInt(1000000),
  821. 1<<uint(sec.Key("MAX_SIZE_SHIFT").MustInt(28)),
  822. sec.Key("DAILY_ROTATE").MustBool(true),
  823. sec.Key("MAX_DAYS").MustInt(7))
  824. case "conn":
  825. LogConfigs[i] = fmt.Sprintf(`{"level":%s,"reconnectOnMsg":%v,"reconnect":%v,"net":"%s","addr":"%s"}`, level,
  826. sec.Key("RECONNECT_ON_MSG").MustBool(),
  827. sec.Key("RECONNECT").MustBool(),
  828. sec.Key("PROTOCOL").In("tcp", []string{"tcp", "unix", "udp"}),
  829. sec.Key("ADDR").MustString(":7020"))
  830. case "smtp":
  831. LogConfigs[i] = fmt.Sprintf(`{"level":%s,"username":"%s","password":"%s","host":"%s","sendTos":["%s"],"subject":"%s"}`, level,
  832. sec.Key("USER").MustString("example@example.com"),
  833. sec.Key("PASSWD").MustString("******"),
  834. sec.Key("HOST").MustString("127.0.0.1:25"),
  835. strings.Replace(sec.Key("RECEIVERS").MustString("example@example.com"), ",", "\",\"", -1),
  836. sec.Key("SUBJECT").MustString("Diagnostic message from serve"))
  837. case "database":
  838. LogConfigs[i] = fmt.Sprintf(`{"level":%s,"driver":"%s","conn":"%s"}`, level,
  839. sec.Key("DRIVER").String(),
  840. sec.Key("CONN").String())
  841. }
  842. log.NewLogger(Cfg.Section("log").Key("BUFFER_LEN").MustInt64(10000), mode, LogConfigs[i])
  843. log.Info("Log Mode: %s(%s)", strings.Title(mode), levelName)
  844. }
  845. }
  846. func newCacheService() {
  847. CacheAdapter = Cfg.Section("cache").Key("ADAPTER").In("memory", []string{"memory", "redis", "memcache"})
  848. switch CacheAdapter {
  849. case "memory":
  850. CacheInterval = Cfg.Section("cache").Key("INTERVAL").MustInt(60)
  851. case "redis", "memcache":
  852. CacheConn = strings.Trim(Cfg.Section("cache").Key("HOST").String(), "\" ")
  853. default:
  854. log.Fatal(4, "Unknown cache adapter: %s", CacheAdapter)
  855. }
  856. log.Info("Cache Service Enabled")
  857. }
  858. func newSessionService() {
  859. SessionConfig.Provider = Cfg.Section("session").Key("PROVIDER").In("memory",
  860. []string{"memory", "file", "redis", "mysql"})
  861. SessionConfig.ProviderConfig = strings.Trim(Cfg.Section("session").Key("PROVIDER_CONFIG").String(), "\" ")
  862. SessionConfig.CookieName = Cfg.Section("session").Key("COOKIE_NAME").MustString("i_like_gitea")
  863. SessionConfig.CookiePath = AppSubURL
  864. SessionConfig.Secure = Cfg.Section("session").Key("COOKIE_SECURE").MustBool(false)
  865. SessionConfig.Gclifetime = Cfg.Section("session").Key("GC_INTERVAL_TIME").MustInt64(86400)
  866. SessionConfig.Maxlifetime = Cfg.Section("session").Key("SESSION_LIFE_TIME").MustInt64(86400)
  867. log.Info("Session Service Enabled")
  868. }
  869. // Mailer represents mail service.
  870. type Mailer struct {
  871. // Mailer
  872. QueueLength int
  873. Name string
  874. From string
  875. FromEmail string
  876. EnableHTMLAlternative bool
  877. // SMTP sender
  878. Host string
  879. User, Passwd string
  880. DisableHelo bool
  881. HeloHostname string
  882. SkipVerify bool
  883. UseCertificate bool
  884. CertFile, KeyFile string
  885. // Sendmail sender
  886. UseSendmail bool
  887. SendmailPath string
  888. }
  889. var (
  890. // MailService the global mailer
  891. MailService *Mailer
  892. )
  893. func newMailService() {
  894. sec := Cfg.Section("mailer")
  895. // Check mailer setting.
  896. if !sec.Key("ENABLED").MustBool() {
  897. return
  898. }
  899. MailService = &Mailer{
  900. QueueLength: sec.Key("SEND_BUFFER_LEN").MustInt(100),
  901. Name: sec.Key("NAME").MustString(AppName),
  902. EnableHTMLAlternative: sec.Key("ENABLE_HTML_ALTERNATIVE").MustBool(),
  903. Host: sec.Key("HOST").String(),
  904. User: sec.Key("USER").String(),
  905. Passwd: sec.Key("PASSWD").String(),
  906. DisableHelo: sec.Key("DISABLE_HELO").MustBool(),
  907. HeloHostname: sec.Key("HELO_HOSTNAME").String(),
  908. SkipVerify: sec.Key("SKIP_VERIFY").MustBool(),
  909. UseCertificate: sec.Key("USE_CERTIFICATE").MustBool(),
  910. CertFile: sec.Key("CERT_FILE").String(),
  911. KeyFile: sec.Key("KEY_FILE").String(),
  912. UseSendmail: sec.Key("USE_SENDMAIL").MustBool(),
  913. SendmailPath: sec.Key("SENDMAIL_PATH").MustString("sendmail"),
  914. }
  915. MailService.From = sec.Key("FROM").MustString(MailService.User)
  916. parsed, err := mail.ParseAddress(MailService.From)
  917. if err != nil {
  918. log.Fatal(4, "Invalid mailer.FROM (%s): %v", MailService.From, err)
  919. }
  920. MailService.FromEmail = parsed.Address
  921. log.Info("Mail Service Enabled")
  922. }
  923. func newRegisterMailService() {
  924. if !Cfg.Section("service").Key("REGISTER_EMAIL_CONFIRM").MustBool() {
  925. return
  926. } else if MailService == nil {
  927. log.Warn("Register Mail Service: Mail Service is not enabled")
  928. return
  929. }
  930. Service.RegisterEmailConfirm = true
  931. log.Info("Register Mail Service Enabled")
  932. }
  933. func newNotifyMailService() {
  934. if !Cfg.Section("service").Key("ENABLE_NOTIFY_MAIL").MustBool() {
  935. return
  936. } else if MailService == nil {
  937. log.Warn("Notify Mail Service: Mail Service is not enabled")
  938. return
  939. }
  940. Service.EnableNotifyMail = true
  941. log.Info("Notify Mail Service Enabled")
  942. }
  943. func newWebhookService() {
  944. sec := Cfg.Section("webhook")
  945. Webhook.QueueLength = sec.Key("QUEUE_LENGTH").MustInt(1000)
  946. Webhook.DeliverTimeout = sec.Key("DELIVER_TIMEOUT").MustInt(5)
  947. Webhook.SkipTLSVerify = sec.Key("SKIP_TLS_VERIFY").MustBool()
  948. Webhook.Types = []string{"gogs", "slack"}
  949. Webhook.PagingNum = sec.Key("PAGING_NUM").MustInt(10)
  950. }
  951. // NewServices initializes the services
  952. func NewServices() {
  953. newService()
  954. newLogService()
  955. newCacheService()
  956. newSessionService()
  957. newMailService()
  958. newRegisterMailService()
  959. newNotifyMailService()
  960. newWebhookService()
  961. }