able to disable SSH for #883
This commit is contained in:
parent
3f2e99962c
commit
2a2596fe61
11 changed files with 24 additions and 13 deletions
|
@ -7,7 +7,7 @@ Gogs(Go Git Service) is a painless self-hosted Git Service written in Go.
|
||||||
|
|
||||||
![Demo](http://gogs.qiniudn.com/gogs_demo.gif)
|
![Demo](http://gogs.qiniudn.com/gogs_demo.gif)
|
||||||
|
|
||||||
##### Current version: 0.5.12 Beta
|
##### Current version: 0.5.13 Beta
|
||||||
|
|
||||||
### NOTICES
|
### NOTICES
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ Gogs(Go Git Service) 是一个基于 Go 语言的自助 Git 服务。
|
||||||
|
|
||||||
![Demo](http://gogs.qiniudn.com/gogs_demo.gif)
|
![Demo](http://gogs.qiniudn.com/gogs_demo.gif)
|
||||||
|
|
||||||
##### 当前版本:0.5.12 Beta
|
##### 当前版本:0.5.13 Beta
|
||||||
|
|
||||||
## 开发目的
|
## 开发目的
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,12 @@ var CmdServ = cli.Command{
|
||||||
func setup(logPath string) {
|
func setup(logPath string) {
|
||||||
setting.NewConfigContext()
|
setting.NewConfigContext()
|
||||||
log.NewGitLogger(filepath.Join(setting.LogRootPath, logPath))
|
log.NewGitLogger(filepath.Join(setting.LogRootPath, logPath))
|
||||||
|
|
||||||
|
if setting.DisableSSH {
|
||||||
|
println("Gogs: SSH has been disabled")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
models.LoadModelsConfig()
|
models.LoadModelsConfig()
|
||||||
|
|
||||||
if models.UseSQLite3 {
|
if models.UseSQLite3 {
|
||||||
|
|
|
@ -18,6 +18,8 @@ DOMAIN = localhost
|
||||||
ROOT_URL = %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/
|
ROOT_URL = %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/
|
||||||
HTTP_ADDR =
|
HTTP_ADDR =
|
||||||
HTTP_PORT = 3000
|
HTTP_PORT = 3000
|
||||||
|
; Disable SSH feature when not available
|
||||||
|
DISABLE_SSH = false
|
||||||
SSH_PORT = 22
|
SSH_PORT = 22
|
||||||
; Disable CDN even in "prod" mode
|
; Disable CDN even in "prod" mode
|
||||||
OFFLINE_MODE = false
|
OFFLINE_MODE = false
|
||||||
|
|
2
gogs.go
2
gogs.go
|
@ -17,7 +17,7 @@ import (
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APP_VER = "0.5.12.0206 Beta"
|
const APP_VER = "0.5.13.0207 Beta"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
|
@ -119,8 +119,6 @@ func (a Action) GetIssueInfos() []string {
|
||||||
|
|
||||||
func updateIssuesCommit(userId, repoId int64, repoUserName, repoName string, commits []*base.PushCommit) error {
|
func updateIssuesCommit(userId, repoId int64, repoUserName, repoName string, commits []*base.PushCommit) error {
|
||||||
for _, c := range commits {
|
for _, c := range commits {
|
||||||
// FIXME: should not be a reference when it comes with action.
|
|
||||||
// e.g. fixes #1 will not have duplicated reference message.
|
|
||||||
for _, ref := range IssueReferenceKeywordsPat.FindAllString(c.Message, -1) {
|
for _, ref := range IssueReferenceKeywordsPat.FindAllString(c.Message, -1) {
|
||||||
ref := ref[strings.IndexByte(ref, byte(' '))+1:]
|
ref := ref[strings.IndexByte(ref, byte(' '))+1:]
|
||||||
ref = strings.TrimRightFunc(ref, func(c rune) bool {
|
ref = strings.TrimRightFunc(ref, func(c rune) bool {
|
||||||
|
|
|
@ -247,8 +247,8 @@ func (repo *Repository) CloneLink() (cl CloneLink, err error) {
|
||||||
if err = repo.GetOwner(); err != nil {
|
if err = repo.GetOwner(); err != nil {
|
||||||
return cl, err
|
return cl, err
|
||||||
}
|
}
|
||||||
if setting.SshPort != 22 {
|
if setting.SSHPort != 22 {
|
||||||
cl.SSH = fmt.Sprintf("ssh://%s@%s:%d/%s/%s.git", setting.RunUser, setting.Domain, setting.SshPort, repo.Owner.LowerName, repo.LowerName)
|
cl.SSH = fmt.Sprintf("ssh://%s@%s:%d/%s/%s.git", setting.RunUser, setting.Domain, setting.SSHPort, repo.Owner.LowerName, repo.LowerName)
|
||||||
} else {
|
} else {
|
||||||
cl.SSH = fmt.Sprintf("%s@%s:%s/%s.git", setting.RunUser, setting.Domain, repo.Owner.LowerName, repo.LowerName)
|
cl.SSH = fmt.Sprintf("%s@%s:%s/%s.git", setting.RunUser, setting.Domain, repo.Owner.LowerName, repo.LowerName)
|
||||||
}
|
}
|
||||||
|
|
|
@ -386,6 +386,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler {
|
||||||
ctx.Data["IsRepositoryOwner"] = ctx.Repo.IsOwner
|
ctx.Data["IsRepositoryOwner"] = ctx.Repo.IsOwner
|
||||||
ctx.Data["IsRepositoryTrueOwner"] = ctx.Repo.IsTrueOwner
|
ctx.Data["IsRepositoryTrueOwner"] = ctx.Repo.IsTrueOwner
|
||||||
|
|
||||||
|
ctx.Data["DisableSSH"] = setting.DisableSSH
|
||||||
ctx.Repo.CloneLink, err = repo.CloneLink()
|
ctx.Repo.CloneLink, err = repo.CloneLink()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Handle(500, "CloneLink", err)
|
ctx.Handle(500, "CloneLink", err)
|
||||||
|
|
|
@ -50,7 +50,8 @@ var (
|
||||||
Protocol Scheme
|
Protocol Scheme
|
||||||
Domain string
|
Domain string
|
||||||
HttpAddr, HttpPort string
|
HttpAddr, HttpPort string
|
||||||
SshPort int
|
DisableSSH bool
|
||||||
|
SSHPort int
|
||||||
OfflineMode bool
|
OfflineMode bool
|
||||||
DisableRouterLog bool
|
DisableRouterLog bool
|
||||||
CertFile, KeyFile string
|
CertFile, KeyFile string
|
||||||
|
@ -209,7 +210,8 @@ func NewConfigContext() {
|
||||||
Domain = sec.Key("DOMAIN").MustString("localhost")
|
Domain = sec.Key("DOMAIN").MustString("localhost")
|
||||||
HttpAddr = sec.Key("HTTP_ADDR").MustString("0.0.0.0")
|
HttpAddr = sec.Key("HTTP_ADDR").MustString("0.0.0.0")
|
||||||
HttpPort = sec.Key("HTTP_PORT").MustString("3000")
|
HttpPort = sec.Key("HTTP_PORT").MustString("3000")
|
||||||
SshPort = sec.Key("SSH_PORT").MustInt(22)
|
DisableSSH = sec.Key("DISABLE_SSH").MustBool()
|
||||||
|
SSHPort = sec.Key("SSH_PORT").MustInt(22)
|
||||||
OfflineMode = sec.Key("OFFLINE_MODE").MustBool()
|
OfflineMode = sec.Key("OFFLINE_MODE").MustBool()
|
||||||
DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool()
|
DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool()
|
||||||
StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(workDir)
|
StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(workDir)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.5.12.0206 Beta
|
0.5.13.0207 Beta
|
|
@ -18,9 +18,11 @@
|
||||||
</a>
|
</a>
|
||||||
<div id="repo-header-download-drop" class="drop-down">
|
<div id="repo-header-download-drop" class="drop-down">
|
||||||
<div id="repo-clone" class="clear">
|
<div id="repo-clone" class="clear">
|
||||||
<button class="btn btn-blue left left btn-left-radius" id="repo-clone-ssh" data-link="{{$.CloneLink.SSH}}">SSH</button>
|
{{if not $.DisableSSH}}
|
||||||
<button class="btn btn-gray left" id="repo-clone-https" data-link="{{$.CloneLink.HTTPS}}">HTTPS</button>
|
<button class="btn btn-blue left btn-left-radius" id="repo-clone-ssh" data-link="{{$.CloneLink.SSH}}">SSH</button>
|
||||||
<input id="repo-clone-url" class="ipt ipt-disabled left" value="{{$.CloneLink.SSH}}" readonly />
|
{{end}}
|
||||||
|
<button class="btn {{if $.DisableSSH}}btn-blue{{else}}btn-gray{{end}} left" id="repo-clone-https" data-link="{{$.CloneLink.HTTPS}}">HTTPS</button>
|
||||||
|
<input id="repo-clone-url" class="ipt ipt-disabled left" value="{{if $.DisableSSH}}{{$.CloneLink.HTTPS}}{{else}}{{$.CloneLink.SSH}}{{end}}" readonly />
|
||||||
<button id="repo-clone-copy" class="btn btn-black left btn-right-radius" data-copy-val="val" data-copy-from="#repo-clone-url" original-title="{{$.i18n.Tr "repo.click_to_copy"}}" data-original-title="{{$.i18n.Tr "repo.click_to_copy"}}" data-after-title="{{$.i18n.Tr "repo.copied"}}">{{$.i18n.Tr "repo.copy_link"}}</button>
|
<button id="repo-clone-copy" class="btn btn-black left btn-right-radius" data-copy-val="val" data-copy-from="#repo-clone-url" original-title="{{$.i18n.Tr "repo.click_to_copy"}}" data-original-title="{{$.i18n.Tr "repo.click_to_copy"}}" data-after-title="{{$.i18n.Tr "repo.copied"}}">{{$.i18n.Tr "repo.copy_link"}}</button>
|
||||||
<p class="text-center" id="repo-clone-help">{{$.i18n.Tr "repo.clone_helper" "http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository" | Str2html}}</p>
|
<p class="text-center" id="repo-clone-help">{{$.i18n.Tr "repo.clone_helper" "http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository" | Str2html}}</p>
|
||||||
<hr/>
|
<hr/>
|
||||||
|
|
Loading…
Reference in a new issue