| | |
| | | /**
|
| | | * Gitblit's Git Daemon ignores any and all per-repository daemon settings and
|
| | | * integrates into Gitblit's security model.
|
| | | * |
| | | *
|
| | | * @author James Moger
|
| | | * |
| | | *
|
| | | */
|
| | | public class GitDaemon {
|
| | |
|
| | |
| | |
|
| | | /**
|
| | | * Construct the Gitblit Git daemon.
|
| | | * |
| | | *
|
| | | * @param bindInterface
|
| | | * the ip address of the interface to bind
|
| | | * @param port
|
| | |
| | | // set the repository resolver and pack factories
|
| | | repositoryResolver = new RepositoryResolver<GitDaemonClient>(folder);
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * Configure a new daemon for the specified network address.
|
| | | * |
| | | *
|
| | | * @param addr
|
| | | * address to listen for connections on. If null, any available
|
| | | * port will be chosen on all network interfaces.
|
| | |
| | | }
|
| | | } };
|
| | | }
|
| | | |
| | |
|
| | | public int getPort() {
|
| | | return myAddress.getPort();
|
| | | }
|
| | | |
| | |
|
| | | public String formatUrl(String servername, String repository) {
|
| | | if (getPort() == 9418) {
|
| | | // standard port
|
| | |
| | |
|
| | | /**
|
| | | * Set the timeout before willing to abort an IO call.
|
| | | * |
| | | *
|
| | | * @param seconds
|
| | | * number of seconds to wait (with no data transfer occurring)
|
| | | * before aborting an IO read or write operation with the
|
| | |
| | |
|
| | | /**
|
| | | * Start this daemon on a background thread.
|
| | | * |
| | | *
|
| | | * @throws IOException
|
| | | * the server socket could not be opened.
|
| | | * @throws IllegalStateException
|
| | |
| | | run.set(true);
|
| | | acceptSocket = listenSock;
|
| | | acceptThread = new Thread(processors, "Git-Daemon-Accept") {
|
| | | @Override
|
| | | public void run() {
|
| | | while (isRunning()) {
|
| | | try {
|
| | |
| | | //
|
| | | } finally {
|
| | | acceptSocket = null;
|
| | | acceptThread = null;
|
| | | }
|
| | |
|
| | | }
|
| | | };
|
| | | acceptThread.start();
|
| | | |
| | |
|
| | | logger.info(MessageFormat.format("Git Daemon is listening on {0}:{1,number,0}", myAddress.getAddress().getHostAddress(), myAddress.getPort()));
|
| | | }
|
| | |
|
| | |
| | |
|
| | | /** Stop this daemon. */
|
| | | public synchronized void stop() {
|
| | | if (acceptThread != null) {
|
| | | logger.info("Git Daemon stopping...");
|
| | | if (isRunning() && acceptThread != null) {
|
| | | run.set(false);
|
| | | logger.info("Git Daemon stopping...");
|
| | | try {
|
| | | // close the accept socket
|
| | | // this throws a SocketException in the accept thread
|
| | |
| | | logger.info("Git Daemon stopped.");
|
| | | } catch (InterruptedException e) {
|
| | | logger.error("Accept thread join interrupted", e);
|
| | | } finally {
|
| | | acceptThread = null;
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | dc.setRemoteAddress(((InetSocketAddress) peer).getAddress());
|
| | |
|
| | | new Thread(processors, "Git-Daemon-Client " + peer.toString()) {
|
| | | @Override
|
| | | public void run() {
|
| | | try {
|
| | | dc.execute(s);
|