Skip to content

Commit

Permalink
conf: overhaul server settings (#5928)
Browse files Browse the repository at this point in the history
* conf: rename package

* Requires Go 1.12

* Fix lint

* Fix lint

* Overhaul

* db: fix tests

* Save my work

* Fix tests

* Server.UnixSocketPermission

* Server.LocalRootURL

* SSH settings

* Server.OfflineMode

* Save my work

* App.Version

* Remove [server] STATIC_ROOT_PATH

* Server.LandingURL
  • Loading branch information
unknwon committed Feb 22, 2020
1 parent 5b14cc6 commit 648d9e2
Show file tree
Hide file tree
Showing 102 changed files with 1,463 additions and 1,328 deletions.
1 change: 0 additions & 1 deletion .travis.yml
@@ -1,7 +1,6 @@
os: linux
language: go
go:
- 1.11.x
- 1.12.x
- 1.13.x
go_import_path: gogs.io/gogs
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -17,6 +17,9 @@ All notable changes to Gogs are documented in this file.
- All assets are now embedded into binary and served from memory by default. Set `[server] LOAD_ASSETS_FROM_DISK = true` to load them from disk. [#5920](https://github.com/gogs/gogs/pull/5920)
- Application and Go versions are removed from page footer and only show in the admin dashboard.
- Build tag for running as Windows Service has been changed from `miniwinsvc` to `minwinsvc`.
- Configuration option `APP_NAME` is deprecated and will end support in 0.13.0, please start using `BRAND_NAME`.
- Configuration option `[server] ROOT_URL` is deprecated and will end support in 0.13.0, please start using `[server] EXTERNAL_URL`.
- Configuration option `[server] LANDING_PAGE` is deprecated and will end support in 0.13.0, please start using `[server] LANDING_URL`.

### Fixed

Expand All @@ -33,6 +36,7 @@ All notable changes to Gogs are documented in this file.
### Removed

- Configuration option `[other] SHOW_FOOTER_VERSION`
- Configuration option `[server] STATIC_ROOT_PATH`

---

Expand Down
10 changes: 5 additions & 5 deletions Makefile
@@ -1,5 +1,5 @@
LDFLAGS += -X "gogs.io/gogs/internal/setting.BuildTime=$(shell date -u '+%Y-%m-%d %I:%M:%S %Z')"
LDFLAGS += -X "gogs.io/gogs/internal/setting.BuildCommit=$(shell git rev-parse HEAD)"
LDFLAGS += -X "gogs.io/gogs/internal/conf.BuildTime=$(shell date -u '+%Y-%m-%d %I:%M:%S %Z')"
LDFLAGS += -X "gogs.io/gogs/internal/conf.BuildCommit=$(shell git rev-parse HEAD)"

CONF_FILES := $(shell find conf | sed 's/ /\\ /g')
TEMPLATES_FILES := $(shell find templates | sed 's/ /\\ /g')
Expand Down Expand Up @@ -81,11 +81,11 @@ test:
go test -cover -race ./...

fixme:
grep -rnw "FIXME" cmd routers models pkg
grep -rnw "FIXME" internal

todo:
grep -rnw "TODO" cmd routers models pkg
grep -rnw "TODO" internal

# Legacy code should be remove by the time of release
legacy:
grep -rnw "LEGACY" cmd routes models pkg
grep -rnw "\(LEGACY\|DEPRECATED\)" internal
123 changes: 66 additions & 57 deletions conf/app.ini
Expand Up @@ -2,75 +2,91 @@
# !!! PLEASE MAKE CHANGES ON CORRESPONDING CUSTOM CONFIG FILE !!!
# !!! IF YOU ARE PACKAGING PROVIDER, PLEASE MAKE OWN COPY OF IT !!!

; App name that shows on every page title
APP_NAME = Gogs
; The name of the system user that runs Gogs
; The brand name of the application.
BRAND_NAME = Gogs
; The system user who should be running the applications. It has no effect on Windows,
; otherwise, it should match the value of $USER environment variable.
RUN_USER = git
; Either "dev", "prod" or "test"
; The running mode of the application, can be either "dev", "prod" or "test".
RUN_MODE = dev

[server]
PROTOCOL = http
; The public-facing URL for the application.
EXTERNAL_URL = %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/
; The public-facing domain name for the application.
DOMAIN = localhost
ROOT_URL = %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/
; The protocol that is used to serve direct traffic to the application.
; Currently supports "http", "https", "fcgi" and "unix".
PROTOCOL = http
; The address to be listened by the application.
HTTP_ADDR = 0.0.0.0
; The port number to be listened by the application.
HTTP_PORT = 3000
; Permission for unix socket
; Generate steps:
; $ ./gogs cert -ca=true -duration=8760h0m0s -host=myhost.example.com
;
; Or from a .pfx file exported from the Windows certificate store (do
; not forget to export the private key):
; $ openssl pkcs12 -in cert.pfx -out cert.pem -nokeys
; $ openssl pkcs12 -in cert.pfx -out key.pem -nocerts -nodes
CERT_FILE = custom/https/cert.pem
KEY_FILE = custom/https/key.pem
; The minimum allowed TLS version, currently supports "TLS10", "TLS11", "TLS12", and "TLS13".
TLS_MIN_VERSION = TLS12
; File permission when serve traffic via Unix domain socket.
UNIX_SOCKET_PERMISSION = 666
; Local (DMZ) URL for Gogs workers (such as SSH update) accessing web service.
; Local (DMZ) URL for workers (e.g. SSH update) accessing web service.
; In most cases you do not need to change the default value.
; Alter it only if your SSH server node is not the same as HTTP node.
LOCAL_ROOT_URL = %(PROTOCOL)s://%(HTTP_ADDR)s:%(HTTP_PORT)s/
; Disable SSH feature when not available

; Whether to disable SSH access to the application entirely.
DISABLE_SSH = false
; Whether use builtin SSH server or not.
START_SSH_SERVER = false
; Domain name to be exposed in SSH clone URL
; The domain name to be exposed in SSH clone URL.
SSH_DOMAIN = %(DOMAIN)s
; Port number to be exposed in SSH clone URL
; The port number to be exposed in SSH clone URL.
SSH_PORT = 22
; Network interface builtin SSH server listens on
; The path of SSH root directory, default is "$HOME/.ssh".
SSH_ROOT_PATH =
; The path to ssh-keygen, default is "ssh-keygen" and let shell find out which one to call.
SSH_KEYGEN_PATH = ssh-keygen
; The directory to create temporary files when test a public key using ssh-keygen,
; default is the system temporary directory.
SSH_KEY_TEST_PATH =
; Whether to start a builtin SSH server.
START_SSH_SERVER = false
; The network interface for builtin SSH server to listen on.
SSH_LISTEN_HOST = 0.0.0.0
; Port number builtin SSH server listens on
; The port number for builtin SSH server to listen on.
SSH_LISTEN_PORT = %(SSH_PORT)s
; Root path of SSH directory, default is '~/.ssh', but you have to use '/home/git/.ssh'.
SSH_ROOT_PATH =
; Indicate whether to rewrite authorized_keys at start, ignored when use builtin SSH server
REWRITE_AUTHORIZED_KEYS_AT_START = false
; Choose the ciphers to support for SSH connections
; The list of accepted ciphers for connections to builtin SSH server.
SSH_SERVER_CIPHERS = aes128-ctr, aes192-ctr, aes256-ctr, aes128-gcm@openssh.com, arcfour256, arcfour128
; Directory to create temporary files when test publick key using ssh-keygen,
; default is system temporary directory.
SSH_KEY_TEST_PATH =
; Path to ssh-keygen, default is 'ssh-keygen' and let shell find out which one to call.
SSH_KEYGEN_PATH = ssh-keygen
; Indicate whether to check minimum key size with corresponding type
; Whether to check minimum public key size with corresponding type.
MINIMUM_KEY_SIZE_CHECK = false
; Disable CDN even in "prod" mode
; Whether to rewrite "~/.ssh/authorized_keys" file at start, ignored when use builtin SSH server.
REWRITE_AUTHORIZED_KEYS_AT_START = false

; Whether to disable using CDN for static files regardless.
OFFLINE_MODE = false
DISABLE_ROUTER_LOG = false
; Generate steps:
; $ ./gogs cert -ca=true -duration=8760h0m0s -host=myhost.example.com
;
; Or from a .pfx file exported from the Windows certificate store (do
; not forget to export the private key):
; $ openssl pkcs12 -in cert.pfx -out cert.pem -nokeys
; $ openssl pkcs12 -in cert.pfx -out key.pem -nocerts -nodes
CERT_FILE = custom/https/cert.pem
KEY_FILE = custom/https/key.pem
; Allowed TLS version values: SSL30, TLS10, TLS11, TLS12
TLS_MIN_VERSION = TLS10
; Whether to disable logging in router.
DISABLE_ROUTER_LOG = true
; Whether to enable application level GZIP compression.
ENABLE_GZIP = false

; Enable to load assets (i.e. "conf", "templates", "public") from disk instead of embedded bindata.
LOAD_ASSETS_FROM_DISK = false
; The directory that contains "templates" and "public". By default, it is the working directory.
STATIC_ROOT_PATH =
; Default path for App data
; The path for storing application specific data.
APP_DATA_PATH = data
; Application level GZIP support
ENABLE_GZIP = false
; Landing page for non-logged users, can be "home" or "explore"
LANDING_PAGE = home
; Whether to enable to load assets (i.e. "conf", "templates", "public") from disk instead of embedded bindata.
LOAD_ASSETS_FROM_DISK = false

; The landing page URL for anonymous users, can be a link to a external site.
LANDING_URL = /

; Define allowed algorithms and their minimum key length (use -1 to disable a type).
[ssh.minimum_key_sizes]
ED25519 = 256
ECDSA = 256
RSA = 2048
DSA = 1024

[repository]
; Root path for storing repositories's data, default is "~/gogs-repositories"
Expand Down Expand Up @@ -156,13 +172,6 @@ ANGLED_QUOTES = true
; Value for Access-Control-Allow-Origin header, default is not to present
ACCESS_CONTROL_ALLOW_ORIGIN =

; Define allowed algorithms and their minimum key length (use -1 to disable a type)
[ssh.minimum_key_sizes]
ED25519 = 256
ECDSA = 256
RSA = 2048
DSA = 1024

[database]
; Either "mysql", "postgres" or "sqlite3", you can connect to TiDB with MySQL protocol
DB_TYPE = mysql
Expand Down Expand Up @@ -228,7 +237,7 @@ ENABLED = false
; Buffer length of channel, keep it as it is if you don't know what it is.
SEND_BUFFER_LEN = 100
; Prefix prepended to the subject line
SUBJECT_PREFIX = `[%(APP_NAME)s] `
SUBJECT_PREFIX = `[%(BRAND_NAME)s] `
; Mail server
; Gmail: smtp.gmail.com:587
; QQ: smtp.qq.com:465
Expand Down Expand Up @@ -364,7 +373,7 @@ URL =
; Webhook URL
URL =
; Username displayed in webhook
USERNAME = %(APP_NAME)s
USERNAME = %(BRAND_NAME)s

[log.xorm]
; Enable file rotation
Expand Down
2 changes: 1 addition & 1 deletion conf/locale/locale_en-US.ini
Expand Up @@ -121,6 +121,7 @@ run_user_not_match = Run user isn't the current user: %s -> %s
smtp_host_missing_port = SMTP Host port missing from address.
invalid_smtp_from = SMTP From field is invalid: %v
save_config_failed = Failed to save configuration: %v
init_failed = Failed to initialize application: %v
invalid_admin_setting = Admin account setting is invalid: %v
install_success = Welcome! We're glad that you chose Gogs, have fun and take care.
invalid_log_root_path = Log root path is invalid: %v
Expand Down Expand Up @@ -1168,7 +1169,6 @@ config.offline_mode = Offline Mode
config.disable_router_log = Disable Router Log
config.run_user = Run User
config.run_mode = Run Mode
config.static_file_root_path = Static File Root Path
config.log_file_root_path = Log File Root Path
config.reverse_auth_user = Reverse Authentication User

Expand Down
2 changes: 1 addition & 1 deletion docs/local_development.md
Expand Up @@ -23,7 +23,7 @@ Gogs is built and runs as a single binary and meant to be cross platform. Theref
Gogs has the following dependencies:

- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) (v1.8.3 or higher)
- [Go](https://golang.org/doc/install) (v1.11 or higher)
- [Go](https://golang.org/doc/install) (v1.12 or higher)
- [Less.js](http://lesscss.org/usage/#command-line-usage-installing)
- [GNU Make](https://www.gnu.org/software/make/)
- Database upon your choice (pick one, we choose PostgreSQL in this document):
Expand Down
3 changes: 2 additions & 1 deletion go.mod
@@ -1,6 +1,6 @@
module gogs.io/gogs

go 1.13
go 1.12

require (
github.com/bgentry/speakeasy v0.1.0 // indirect
Expand Down Expand Up @@ -39,6 +39,7 @@ require (
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
github.com/niklasfasching/go-org v0.1.6
github.com/olekukonko/tablewriter v0.0.1 // indirect
github.com/pkg/errors v0.8.1
github.com/pquerna/otp v1.2.0
github.com/prometheus/client_golang v1.2.1
github.com/russross/blackfriday v1.5.2
Expand Down
1 change: 1 addition & 0 deletions go.sum
Expand Up @@ -194,6 +194,7 @@ github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJ
github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo=
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down
10 changes: 4 additions & 6 deletions gogs.go
@@ -1,4 +1,4 @@
// +build go1.11
// +build go1.12

// Copyright 2014 The Gogs Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
Expand All @@ -14,20 +14,18 @@ import (
log "unknwon.dev/clog/v2"

"gogs.io/gogs/internal/cmd"
"gogs.io/gogs/internal/setting"
"gogs.io/gogs/internal/conf"
)

const Version = "0.12.0+dev"

func init() {
setting.AppVersion = Version
conf.App.Version = "0.12.0+dev"
}

func main() {
app := cli.NewApp()
app.Name = "Gogs"
app.Usage = "A painless self-hosted Git service"
app.Version = Version
app.Version = conf.App.Version
app.Commands = []cli.Command{
cmd.Web,
cmd.Serv,
Expand Down
16 changes: 8 additions & 8 deletions internal/assets/conf/conf_gen.go

Large diffs are not rendered by default.

0 comments on commit 648d9e2

Please sign in to comment.