Documentation
¶
Overview ¶
Package addresses provides utilities for parsing HTCondor addresses and handling different connection types including shared port connections.
Index ¶
- func BrokerIsCCB(brokerAddr string) bool
- func EncodeParamValue(v string) string
- func IsValidSharedPortID(id string) bool
- func SplitCCBContact(contact string) (brokerAddr, ccbid string, ok bool)
- func WithParam(addr, key, value string) string
- func WithoutParam(addr, key string) string
- type CCBContact
- type SharedPortInfo
- type SinfulInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BrokerIsCCB ¶ added in v0.4.0
BrokerIsCCB reports whether a broker address extracted by SplitCCBContact is itself CCB-routed (a nested contact with a further hop), i.e. it still carries a '#'. A new client uses this to decide whether to recurse.
func EncodeParamValue ¶ added in v0.7.1
EncodeParamValue escapes a value for use in a sinful parameter.
This is HTCondor's encoding, from needsUrlEncodeEscape in condor_sinful.cpp: alphanumerics and . _ - : # [ ] + pass through and everything else becomes a lower-case %xx escape.
Deliberately not net/url. QueryEscape writes a space as '+', and the decoder on the other side treats '+' as a literal plus -- it is in the set above -- so a value with a space in it would come back changed. This is the inverse of urlDecode, which is url.PathUnescape for the same reason.
func IsValidSharedPortID ¶
IsValidSharedPortID validates a shared port ID according to HTCondor rules The ID must contain only alphanumeric characters, dots, dashes, and underscores
func SplitCCBContact ¶ added in v0.1.0
SplitCCBContact splits a "<broker-address>#<ccbid>" contact into its broker address and id, peeling ONE hop. It splits on the LAST '#' so that a *nested* (multi-hop tunnel) contact works: brokerAddr may itself be a contact, e.g. "192.0.2.10:9618#42#17" -> broker="192.0.2.10:9618#42", id="17" (recurse on the broker; see the CCB tunneling design §4.7). A flat single-hop contact has one '#', for which split-on-last == split-on-first, so normal CCB is unchanged.
Angle brackets are stripped only when they wrap the whole broker (a bare "<host:port>" entry broker), never when the broker is itself a nested contact like "<host:port>#42" (whose brackets belong to the inner sinful). Use '#' (not '%') as the hop separator because '%' collides with %XX sinful escaping.
func WithParam ¶ added in v0.7.1
WithParam returns addr with key set to value, replacing any existing one.
The value is escaped with EncodeParamValue; the key is written as the caller spelled it, since a caller adding a parameter this package does not know about has to be able to choose its name.
func WithoutParam ¶ added in v0.7.1
WithoutParam returns addr with one parameter removed.
The key is matched the way ParseSinful reads it: case-folded through the canonical names, so asking for "ccbid" removes the "CCBID" that HTCondor actually writes. Matching literally instead is invisible when it fails -- the parameter stays, the address still parses, and it simply keeps meaning what the caller was trying to stop it meaning.
An address with no such parameter, or no query string at all, comes back unchanged.
Types ¶
type CCBContact ¶ added in v0.1.0
type CCBContact struct {
BrokerAddr string // broker address without angle brackets, e.g. "192.168.1.1:9618"
CCBID string // the broker-assigned id, e.g. "42"
Raw string // the full "addr#id" contact string
}
CCBContact is a single Condor Connection Broker contact extracted from a sinful string's "ccbid" parameter. On the wire a contact has the form "<broker-address>#<ccbid>" where the broker address has NO angle brackets (e.g. "192.168.1.1:9618#42"), matching CCBServer::CCBIDToContactString in the HTCondor C++ source.
type SharedPortInfo ¶
type SharedPortInfo struct {
}
SharedPortInfo contains information extracted from a shared port address
func ParseHTCondorAddress ¶
func ParseHTCondorAddress(address string) SharedPortInfo
ParseHTCondorAddress parses HTCondor addresses that may contain shared port information
HTCondor addresses with shared port info look like: - "<host:port?sock=shared_port_id>" - "host:port?sock=shared_port_id"
HTCondor addresses may also contain other query parameters (e.g., addrs, alias, CCBID) which should be stripped from the server address: - "<127.0.0.1:41919?addrs=127.0.0.1-41919&alias=hostname>"
Returns SharedPortInfo with the parsed information
type SinfulInfo ¶ added in v0.1.0
type SinfulInfo struct {
Raw string // the original input
PrimaryAddr string // primary "host:port" (brackets/params stripped)
Host string // host portion of PrimaryAddr
Port string // port portion of PrimaryAddr
CCBContacts []CCBContact // "ccbid" parameter, parsed (space-separated list)
PrivateAddr string // "PrivAddr" parameter, if any
PrivateNet string // "PrivNet" parameter, if any
Alias string // "alias" parameter, if any
NoUDP bool // "noUDP" parameter present
Addrs []string // "addrs" parameter, split on '+'
Params map[string]string // all decoded query parameters, the known ones under HTCondor's own spelling
}
SinfulInfo is the parsed form of an HTCondor "sinful" string. It supersedes SharedPortInfo (which only understood the "sock" parameter) by also understanding CCB routing ("ccbid"), private addresses ("PrivAddr"), "noUDP", and the other v0 sinful query parameters. The v0 format is:
<host:port?key1=value1&key2=value2&...>
where keys and values are url-encoded with %XX escapes and pairs are delimited by '&' or ';' (see parseUrlEncodedParams in condor_sinful.cpp).
func ParseSinful ¶ added in v0.1.0
func ParseSinful(addr string) (SinfulInfo, error)
ParseSinful parses an HTCondor v0 sinful string. Angle brackets are optional. It never fails on unknown parameters; an error is returned only for malformed url-encoding.
func (SinfulInfo) IsCCB ¶ added in v0.1.0
func (s SinfulInfo) IsCCB() bool
IsCCB reports whether the address must be reached via the Condor Connection Broker (i.e. it carries one or more ccb contacts).
func (SinfulInfo) IsSharedPort ¶ added in v0.1.0
func (s SinfulInfo) IsSharedPort() bool
IsSharedPort reports whether the address routes through a shared-port daemon.