(refs #115)Use system settings port number

This commit is contained in:
Tomofumi Tanaka
2014-03-13 01:47:28 +09:00
parent 017631e337
commit 78ca9b3f1a

View File

@@ -4,8 +4,9 @@ import org.apache.sshd.common.Factory
import org.apache.sshd.server.{Environment, ExitCallback, Command} import org.apache.sshd.server.{Environment, ExitCallback, Command}
import java.io.{OutputStream, InputStream} import java.io.{OutputStream, InputStream}
import org.eclipse.jgit.lib.Constants import org.eclipse.jgit.lib.Constants
import service.SystemSettingsService
class NoShell extends Factory[Command] { class NoShell extends Factory[Command] with SystemSettingsService {
override def create(): Command = new Command() { override def create(): Command = new Command() {
private var in: InputStream = null private var in: InputStream = null
private var out: OutputStream = null private var out: OutputStream = null
@@ -13,6 +14,8 @@ class NoShell extends Factory[Command] {
private var callback: ExitCallback = null private var callback: ExitCallback = null
override def start(env: Environment): Unit = { override def start(env: Environment): Unit = {
val user = env.getEnv.get("USER")
val port = loadSystemSettings().sshPort.getOrElse(SystemSettingsService.DefaultSshPort)
val message = val message =
""" """
| Welcome to | Welcome to
@@ -28,8 +31,8 @@ class NoShell extends Factory[Command] {
| |
| Please use: | Please use:
| |
| git clone ssh://username@host_or_ip:29418/owner/repository_name.git | git clone ssh://%s@GITBUCKET_HOST:%d/OWNER/REPOSITORY_NAME.git
""".stripMargin.replace("\n", "\r\n") + "\r\n" """.stripMargin.format(user, port).replace("\n", "\r\n") + "\r\n"
err.write(Constants.encode(message)) err.write(Constants.encode(message))
err.flush() err.flush()
in.close() in.close()