server

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package server provides reusable scaffolding for building CEDAR command servers (daemons that accept connections, authenticate, and dispatch HTCondor commands). It complements the client-focused packages in this module.

Two kinds of command handlers are supported:

  • Authenticated commands: the client opens the exchange with a DC_AUTHENTICATE command and a security ClassAd that carries the real command (e.g. CCB_REGISTER). The server performs the security handshake and dispatches on the real command.
  • Raw commands: the client sends a bare command integer with no security handshake (e.g. CCB_REVERSE_CONNECT, which HTCondor registers as ALLOW and sends via the "raw" command protocol). These are dispatched directly with no authentication.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KeepOpen

func KeepOpen() error

KeepOpen is returned by a handler that has taken ownership of the connection (e.g. a persistent CCB registration socket or a proxied stream). ServeConn will not close the underlying connection in that case.

Types

type Conn

type Conn struct {
	// Stream is the CEDAR stream for the connection. For authenticated
	// commands it is authenticated (and possibly encrypted) by the time the
	// handler runs; for raw commands it is plaintext.
	Stream *stream.Stream

	// Command is the real HTCondor command being dispatched.
	Command int

	// Negotiation is the result of the security handshake, or nil for raw
	// commands.
	Negotiation *security.SecurityNegotiation

	// Message is the inbound Message the leading command integer was read
	// from. Raw-command handlers read their payload (e.g. a ClassAd) from
	// this message; authenticated handlers normally start a fresh message.
	Message *message.Message

	// RemoteAddr is the peer's network address.
	RemoteAddr string
}

Conn is the per-connection context handed to a command handler.

func (*Conn) PeerVersion

func (c *Conn) PeerVersion() string

PeerVersion returns the peer's reported $CondorVersion$ string, or "" if it was not exchanged (e.g. for raw commands).

type HandlerFunc

type HandlerFunc func(ctx context.Context, c *Conn) error

HandlerFunc handles a single dispatched command. Returning an error closes the connection unless the handler has taken ownership of it (see KeepOpen).

type Server

type Server struct {
	// SecurityConfig is used for the server side of the security handshake on
	// authenticated commands. It must be non-nil if any authenticated handler
	// is registered.
	SecurityConfig *security.SecurityConfig
	// contains filtered or unexported fields
}

Server accepts CEDAR connections and dispatches commands to handlers.

func New

func New(secConfig *security.SecurityConfig) *Server

New creates a Server with the given server-side security configuration.

func (*Server) Handle

func (s *Server) Handle(command int, fn HandlerFunc)

Handle registers an authenticated handler for a command.

func (*Server) HandleRaw

func (s *Server) HandleRaw(command int, fn HandlerFunc)

HandleRaw registers a handler for a raw (un-authenticated) command. The command integer arrives with no preceding DC_AUTHENTICATE.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, l net.Listener) error

Serve accepts connections from l until the context is cancelled or Accept fails permanently. Each connection is handled in its own goroutine.

func (*Server) ServeConn

func (s *Server) ServeConn(ctx context.Context, conn net.Conn) error

ServeConn handles a single already-accepted connection: it reads the leading command integer, performs the security handshake for authenticated commands, and dispatches to the registered handler.

Jump to

Keyboard shortcuts

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