git

package
v6.0.0-alpha.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package git provides an in-process git:// protocol server.

It listens on a TCP port and handles the git:// wire protocol (git-upload-pack, git-receive-pack, git-upload-archive) using the backend.Backend handler. The server supports configurable timeouts and maximum connections, similar to git-daemon.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	// Loader resolves repository URLs to storage. If nil,
	// [transport.DefaultLoader] is used.
	Loader transport.Loader

	// ErrorLog is used to log errors. If nil, errors are not logged.
	ErrorLog *log.Logger

	// Timeout is the idle timeout for each connection. If a connection
	// has no read or write activity for this duration, it is closed.
	// If zero, there is no idle timeout. Corresponds to git-daemon's
	// --timeout.
	Timeout time.Duration

	// InitTimeout is the timeout for the initial protocol handshake
	// (reading the GitProtoRequest). If zero, there is no handshake
	// timeout. Corresponds to git-daemon's --init-timeout.
	InitTimeout time.Duration

	// MaxTimeout is the absolute maximum duration a connection is
	// allowed to live, regardless of activity. If zero, there is no
	// maximum. This is useful to prevent long-lived connections from
	// consuming server resources indefinitely.
	MaxTimeout time.Duration

	// MaxConnections is the maximum number of simultaneous connections.
	// If zero, there is no limit. Corresponds to git-daemon's
	// --max-connections. Connections beyond the limit are immediately
	// closed.
	MaxConnections int
	// contains filtered or unexported fields
}

Server is a git:// protocol server.

func FromLoader

func FromLoader(loader transport.Loader) *Server

FromLoader creates a git:// server backed by the given loader.

func (*Server) Close

func (s *Server) Close() error

Close immediately closes the listener and all active connections.

func (*Server) Endpoint

func (s *Server) Endpoint() (string, error)

Endpoint returns the git:// URL clients should connect to.

func (*Server) Start

func (s *Server) Start() (string, error)

Start starts the git:// server on a random port. It returns the endpoint URL (e.g. "git://127.0.0.1:XXXXX") that clients can use to connect.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL