Index: uberfire-nio2-backport/uberfire-nio2-impls/uberfire-nio2-jgit/src/main/java/org/uberfire/java/nio/fs/jgit/JGitFileSystemProvider.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- uberfire-nio2-backport/uberfire-nio2-impls/uberfire-nio2-jgit/src/main/java/org/uberfire/java/nio/fs/jgit/JGitFileSystemProvider.java (date 1397253871000) +++ uberfire-nio2-backport/uberfire-nio2-impls/uberfire-nio2-jgit/src/main/java/org/uberfire/java/nio/fs/jgit/JGitFileSystemProvider.java (revision ) @@ -67,6 +67,8 @@ import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException; import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException; import org.eclipse.jgit.util.FileUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.uberfire.commons.cluster.ClusterService; import org.uberfire.commons.data.Pair; import org.uberfire.commons.message.MessageType; @@ -137,6 +139,8 @@ public class JGitFileSystemProvider implements FileSystemProvider, SecurityAware { + private static final Logger logger = LoggerFactory.getLogger(JGitFileSystemProvider.class); + protected static final String DEFAULT_IO_SERVICE_NAME = "default"; public static final String GIT_DEFAULT_REMOTE_NAME = DEFAULT_REMOTE_NAME; @@ -158,11 +162,13 @@ public static File FILE_REPOSITORIES_ROOT; public static boolean DAEMON_ENABLED; public static int DAEMON_PORT; + public static int DAEMON_BIND_PORT; private static String DAEMON_HOST_ADDR; private static String DAEMON_HOST_NAME; private static boolean SSH_ENABLED; private static int SSH_PORT; + private static int SSH_BIND_PORT; private static String SSH_HOST_ADDR; private static String SSH_HOST_NAME; private static File SSH_FILE_CERT_DIR; @@ -201,12 +207,14 @@ final String host = System.getProperty( "org.uberfire.nio.git.daemon.host" ); final String hostName = System.getProperty( "org.uberfire.nio.git.daemon.hostname" ); final String port = System.getProperty( "org.uberfire.nio.git.daemon.port" ); + final String bindPort = System.getProperty( "org.uberfire.nio.git.daemon.bind.port" ); final String sshEnabled = System.getProperty( "org.uberfire.nio.git.ssh.enabled" ); final String sshHost = System.getProperty( "org.uberfire.nio.git.ssh.host" ); final String sshHostName = System.getProperty( "org.uberfire.nio.git.ssh.hostname" ); final String sshPort = System.getProperty( "org.uberfire.nio.git.ssh.port" ); final String sshCertDir = System.getProperty( "org.uberfire.nio.git.ssh.cert.dir" ); + final String sshBindPort = System.getProperty( "org.uberfire.nio.git.ssh.bind.port" ); if ( bareReposDir == null || bareReposDir.trim().isEmpty() ) { FILE_REPOSITORIES_ROOT = new File( REPOSITORIES_ROOT_DIR ); @@ -230,6 +238,15 @@ } else { DAEMON_PORT = Integer.valueOf( port ); } + + if ( bindPort == null || bindPort.trim().isEmpty() ) { + // Set binding port as the same as the daemon port by default + DAEMON_BIND_PORT = DAEMON_PORT; + } else { + DAEMON_BIND_PORT = Integer.valueOf(bindPort); + } + + if ( host == null || host.trim().isEmpty() ) { DAEMON_HOST_ADDR = DEFAULT_HOST_ADDR; } else { @@ -262,6 +279,12 @@ } else { SSH_PORT = Integer.valueOf( sshPort ); } + if ( sshBindPort == null || sshBindPort.trim().isEmpty() ) { + SSH_BIND_PORT = SSH_PORT; + } else { + SSH_BIND_PORT = Integer.valueOf( sshBindPort ); + } + if ( sshHost == null || sshHost.trim().isEmpty() ) { SSH_HOST_ADDR = DEFAULT_HOST_ADDR; } else { @@ -459,13 +482,16 @@ gitSSHService = new GitSSHService(); - gitSSHService.setup( SSH_FILE_CERT_DIR, SSH_HOST_ADDR, SSH_PORT, authenticationManager, authorizationManager, receivePackFactory, new RepositoryResolverImpl() ); + logger.info("GIT SSH DAEMON: Binding to " + SSH_HOST_ADDR + ":" + SSH_BIND_PORT); + gitSSHService.setup( SSH_FILE_CERT_DIR, SSH_HOST_ADDR, SSH_BIND_PORT, authenticationManager, authorizationManager, receivePackFactory, new RepositoryResolverImpl() ); + gitSSHService.start(); } private void buildAndStartDaemon() { - daemonService = new Daemon( new InetSocketAddress( DAEMON_HOST_ADDR, DAEMON_PORT ) ); + logger.info("GIT DAEMON: Trying to bind to " + DAEMON_HOST_ADDR + ":" + DAEMON_BIND_PORT); + daemonService = new Daemon( new InetSocketAddress( DAEMON_HOST_ADDR, DAEMON_BIND_PORT ) ); daemonService.setRepositoryResolver( new RepositoryResolverImpl() ); try { daemonService.start();