summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authormscherer <mscherer@users.noreply.github.com>2021-12-06 05:46:11 +0100
committerGitHub <noreply@github.com>2021-12-05 23:46:11 -0500
commitf49d160447899270fbca6370cb7ab2742dce85dc (patch)
treec0d4aba602a7ab922c77eba312540bac075ee2e8 /modules
parent9d6208965c0590e307b8b198557690257da83351 (diff)
downloadgitea-f49d160447899270fbca6370cb7ab2742dce85dc.tar.gz
gitea-f49d160447899270fbca6370cb7ab2742dce85dc.zip
Replace "unix" by "http+unix" for PROTOCOL (#17771)
Diffstat (limited to 'modules')
-rw-r--r--modules/private/internal.go2
-rw-r--r--modules/setting/setting.go37
2 files changed, 19 insertions, 20 deletions
diff --git a/modules/private/internal.go b/modules/private/internal.go
index 0a39ca7b8e..a77a990627 100644
--- a/modules/private/internal.go
+++ b/modules/private/internal.go
@@ -46,7 +46,7 @@ func newInternalRequest(ctx context.Context, url, method string) *httplib.Reques
InsecureSkipVerify: true,
ServerName: setting.Domain,
})
- if setting.Protocol == setting.UnixSocket {
+ if setting.Protocol == setting.HTTPUnix {
req.SetTransport(&http.Transport{
DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) {
var d net.Dialer
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index d219dbaafd..8b67a45175 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -39,11 +39,11 @@ type Scheme string
// enumerates all the scheme types
const (
- HTTP Scheme = "http"
- HTTPS Scheme = "https"
- FCGI Scheme = "fcgi"
- FCGIUnix Scheme = "fcgi+unix"
- UnixSocket Scheme = "unix"
+ HTTP Scheme = "http"
+ HTTPS Scheme = "https"
+ FCGI Scheme = "fcgi"
+ FCGIUnix Scheme = "fcgi+unix"
+ HTTPUnix Scheme = "http+unix"
)
// LandingPage describes the default page
@@ -607,7 +607,8 @@ func loadFromConf(allowEmpty bool) {
HTTPPort = sec.Key("HTTP_PORT").MustString("3000")
Protocol = HTTP
- switch sec.Key("PROTOCOL").String() {
+ protocolCfg := sec.Key("PROTOCOL").String()
+ switch protocolCfg {
case "https":
Protocol = HTTPS
CertFile = sec.Key("CERT_FILE").String()
@@ -620,24 +621,22 @@ func loadFromConf(allowEmpty bool) {
}
case "fcgi":
Protocol = FCGI
- case "fcgi+unix":
- Protocol = FCGIUnix
- UnixSocketPermissionRaw := sec.Key("UNIX_SOCKET_PERMISSION").MustString("666")
- UnixSocketPermissionParsed, err := strconv.ParseUint(UnixSocketPermissionRaw, 8, 32)
- if err != nil || UnixSocketPermissionParsed > 0777 {
- log.Fatal("Failed to parse unixSocketPermission: %s", UnixSocketPermissionRaw)
+ case "fcgi+unix", "unix", "http+unix":
+ switch protocolCfg {
+ case "fcgi+unix":
+ Protocol = FCGIUnix
+ case "unix":
+ log.Warn("unix PROTOCOL value is deprecated, please use http+unix")
+ fallthrough
+ case "http+unix":
+ Protocol = HTTPUnix
}
- UnixSocketPermission = uint32(UnixSocketPermissionParsed)
- if !filepath.IsAbs(HTTPAddr) {
- HTTPAddr = filepath.Join(AppWorkPath, HTTPAddr)
- }
- case "unix":
- Protocol = UnixSocket
UnixSocketPermissionRaw := sec.Key("UNIX_SOCKET_PERMISSION").MustString("666")
UnixSocketPermissionParsed, err := strconv.ParseUint(UnixSocketPermissionRaw, 8, 32)
if err != nil || UnixSocketPermissionParsed > 0777 {
log.Fatal("Failed to parse unixSocketPermission: %s", UnixSocketPermissionRaw)
}
+
UnixSocketPermission = uint32(UnixSocketPermissionParsed)
if !filepath.IsAbs(HTTPAddr) {
HTTPAddr = filepath.Join(AppWorkPath, HTTPAddr)
@@ -692,7 +691,7 @@ func loadFromConf(allowEmpty bool) {
var defaultLocalURL string
switch Protocol {
- case UnixSocket:
+ case HTTPUnix:
defaultLocalURL = "http://unix/"
case FCGI:
defaultLocalURL = AppURL