diff options
author | ᴜɴᴋɴᴡᴏɴ <u@gogs.io> | 2020-02-22 09:05:26 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-22 09:05:26 +0800 |
commit | 648d9e253c1924b832248f26fee42b2fb64dc3bc (patch) | |
tree | 51649fad974cd7284a47d30e412c90e7ab72cd2c /internal/conf/utils.go | |
parent | 5b14cc6f0b7b661beb2640a94bd15660cdb48587 (diff) |
conf: overhaul server settings (#5928)
* 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
Diffstat (limited to 'internal/conf/utils.go')
-rw-r--r-- | internal/conf/utils.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/internal/conf/utils.go b/internal/conf/utils.go new file mode 100644 index 00000000..ad716018 --- /dev/null +++ b/internal/conf/utils.go @@ -0,0 +1,27 @@ +// Copyright 2020 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package conf + +import ( + "strings" + + "github.com/pkg/errors" + + "gogs.io/gogs/internal/process" +) + +// openSSHVersion returns string representation of OpenSSH version via command "ssh -V". +func openSSHVersion() (string, error) { + // NOTE: Somehow the version is printed to stderr. + _, stderr, err := process.Exec("conf.openSSHVersion", "ssh", "-V") + if err != nil { + return "", errors.Wrap(err, stderr) + } + + // Trim unused information, see https://github.com/gogs/gogs/issues/4507#issuecomment-305150441. + v := strings.TrimRight(strings.Fields(stderr)[0], ",1234567890") + v = strings.TrimSuffix(strings.TrimPrefix(v, "OpenSSH_"), "p") + return v, nil +} |