From 6a0fec77eaacbce05486fea76b67db3f5f880e88 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sat, 18 Apr 2015 05:21:07 -0500 Subject: [PATCH] Allow an SSHDomain configuration option. Defaults to Domain, preserves legacy behavior --- models/repo.go | 5 +++-- modules/setting/setting.go | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/models/repo.go b/models/repo.go index 7b47c20b1e..cc4b53b0f2 100644 --- a/models/repo.go +++ b/models/repo.go @@ -242,10 +242,11 @@ func (repo *Repository) CloneLink() (cl CloneLink, err error) { if err = repo.GetOwner(); err != nil { return cl, err } + 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.SSHDomain, setting.SSHPort, repo.Owner.LowerName, repo.LowerName) } 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.SSHDomain, repo.Owner.LowerName, repo.LowerName) } cl.HTTPS = fmt.Sprintf("%s%s/%s.git", setting.AppUrl, repo.Owner.LowerName, repo.LowerName) return cl, nil diff --git a/modules/setting/setting.go b/modules/setting/setting.go index aefc3520f9..3ce27b2e3b 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -53,6 +53,7 @@ var ( HttpAddr, HttpPort string DisableSSH bool SSHPort int + SSHDomain string OfflineMode bool DisableRouterLog bool CertFile, KeyFile string @@ -232,6 +233,7 @@ func NewConfigContext() { HttpAddr = sec.Key("HTTP_ADDR").MustString("0.0.0.0") HttpPort = sec.Key("HTTP_PORT").MustString("3000") DisableSSH = sec.Key("DISABLE_SSH").MustBool() + SSHDomain = sec.Key("SSH_DOMAIN").MustString(Domain) SSHPort = sec.Key("SSH_PORT").MustInt(22) OfflineMode = sec.Key("OFFLINE_MODE").MustBool() DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool()