Documentation
¶
Index ¶
- func IsNotFound(err error) bool
- type BlobReqObj
- type BrotherFetchResultObj
- type BrotherIndexEntryObj
- type BrotherSessionInterface
- type BrotherSessionObj
- func (s *BrotherSessionObj) BlobsFetch(ctx context.Context, version string, reqs []BlobReqObj, destDir string) (BrotherFetchResultObj, error)
- func (s *BrotherSessionObj) Close() error
- func (s *BrotherSessionObj) FetchLimits() (uint64, uint)
- func (s *BrotherSessionObj) Healthy() bool
- func (s *BrotherSessionObj) Hello(ctx context.Context) (HelloResultObj, error)
- func (s *BrotherSessionObj) Index(ctx context.Context, page uint32) ([]BrotherIndexEntryObj, uint32, BrotherSourceInfoObj, error)
- func (s *BrotherSessionObj) Version(ctx context.Context, version string) (BrotherVersionObj, error)
- type BrotherSourceInfoObj
- type BrotherVersionObj
- type DiscoveryResultObj
- type GitFetchRequestObj
- type GitFetchResultObj
- type GitReleaseObj
- type HelloResultObj
- type MeshInterface
- type Obj
- func (obj *Obj) BrotherDial(ctx context.Context, localKey, remoteKey, brotherURL string) (BrotherSessionInterface, error)
- func (obj *Obj) Close(_ context.Context) error
- func (obj *Obj) Discover(ctx context.Context, key, rootURL string) (DiscoveryResultObj, error)
- func (obj *Obj) FetchArchive(ctx context.Context, reqObj GitFetchRequestObj) (GitFetchResultObj, error)
- func (obj *Obj) PublicMirrorVersions(ctx context.Context, rootURL string, remoteKey string) ([]PublicMirrorVersionObj, bool, error)
- func (obj *Obj) Refs(ctx context.Context, sourceURL string) (map[string]string, error)
- func (obj *Obj) Releases(ctx context.Context, sourceURL string, depth uint) ([]GitReleaseObj, bool, error)
- func (obj *Obj) Tags(ctx context.Context, sourceURL string, depth uint) ([]GitReleaseObj, bool, error)
- type Option
- type PublicMirrorVersionObj
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsNotFound ¶
IsNotFound reports a provider-level "resource missing" response. For Gitea/Forgejo, a disabled releases module looks like this and should trigger tag fallback.
Types ¶
type BlobReqObj ¶
BlobReqObj carries a hash and size so batch size can be checked before sending.
type BrotherFetchResultObj ¶
type BrotherFetchResultObj struct {
Blobs []core.StagedBlobObj
}
BrotherFetchResultObj contains staged blobs written to the spool and verified by hash24.
type BrotherIndexEntryObj ¶
type BrotherIndexEntryObj struct {
Version string
ReleaseNotes string
TreeHash core.HashObj
SourceHash core.HashObj
UpstreamSeq int64 // brother source position; 0 means legacy node and local assignment
}
BrotherIndexEntryObj is one brother index entry with release notes and origin hashes. TreeHash enables index-driven skips without fetching the tree; SourceHash carries archive provenance. A zero SourceHash means the brother is old or did not report it.
type BrotherSessionInterface ¶
type BrotherSessionInterface interface {
Hello(ctx context.Context) (HelloResultObj, error)
Index(ctx context.Context, page uint32) ([]BrotherIndexEntryObj, uint32, BrotherSourceInfoObj, error)
Version(ctx context.Context, version string) (BrotherVersionObj, error)
BlobsFetch(ctx context.Context, version string, reqs []BlobReqObj, destDir string) (BrotherFetchResultObj, error)
FetchLimits() (uint64, uint)
// Healthy reports whether the session has seen no transport/context error.
Healthy() bool
Close() error
}
BrotherSessionInterface defines the brother session contract for rescan. BrotherDial returns the interface so callers and tests do not depend on the concrete session type.
type BrotherSessionObj ¶
type BrotherSessionObj struct {
// contains filtered or unexported fields
}
BrotherSessionObj describes a single brother session over net/rpc via CONNECT, hijack and gob. localKey is used for diagnostics; remoteKey goes into RPC arguments.
The session is not concurrent-safe: a single goroutine owns it, and mu makes each call atomic. Invariant errors do not kill the session; transport/context errors mark it unhealthy for a rescan redial.
func (*BrotherSessionObj) BlobsFetch ¶
func (s *BrotherSessionObj) BlobsFetch(ctx context.Context, version string, reqs []BlobReqObj, destDir string) (BrotherFetchResultObj, error)
BlobsFetch requests sized blobs, verifies their hash24 and writes them to destDir. The total declared size is checked before sending so that valid large batches fit within the codec cap. Unrequested, duplicate or oversized blobs are dropped or map to brother_rpc_invalid.
func (*BrotherSessionObj) Close ¶
func (s *BrotherSessionObj) Close() error
Close idempotently closes the rpc client and the connection.
func (*BrotherSessionObj) FetchLimits ¶
func (s *BrotherSessionObj) FetchLimits() (uint64, uint)
FetchLimits returns effective blob fetch limits for this session.
func (*BrotherSessionObj) Healthy ¶
func (s *BrotherSessionObj) Healthy() bool
Healthy reports whether the session is fit for further use.
func (*BrotherSessionObj) Hello ¶
func (s *BrotherSessionObj) Hello(ctx context.Context) (HelloResultObj, error)
Hello returns the protocol and instance checksums; callers validate the protocol.
func (*BrotherSessionObj) Index ¶
func (s *BrotherSessionObj) Index(ctx context.Context, page uint32) ([]BrotherIndexEntryObj, uint32, BrotherSourceInfoObj, error)
Index returns one page of remoteKey versions with release notes and source info. NextPage==0 means the end; otherwise the page must strictly increase. Non-monotonic pages, oversize fields or source info map to brother_rpc_invalid.
func (*BrotherSessionObj) Version ¶
func (s *BrotherSessionObj) Version(ctx context.Context, version string) (BrotherVersionObj, error)
Version returns the canonical tree bytes and checks transport integrity against the declared hash24.
type BrotherSourceInfoObj ¶
type BrotherSourceInfoObj struct {
SourceURL string
}
BrotherSourceInfoObj is normalized source info announced by a brother for a key. It is only a hint: rescan still classifies and verifies the first source itself, so only the URL is kept.
type BrotherVersionObj ¶
type BrotherVersionObj struct {
TreeBytes []byte
}
BrotherVersionObj carries the canonical version tree bytes; their hash24 is verified against the declared hash inside Version before return, so the hash is not re-exposed here.
type DiscoveryResultObj ¶
type DiscoveryResultObj struct {
Class stcode.SourceClassType
RemoteKey string
SourceURL string
BrotherURL string
WebAddr string
YggAddr string
}
DiscoveryResultObj is the source classification result; rescan writes it to state. For brother sources, WebAddr and YggAddr are learned public addresses used for transport fallback. SourceURL is the first source for git and the brother URL for brother sources.
type GitFetchRequestObj ¶
type GitFetchRequestObj struct {
Key string
Version string
ArchiveURL string
Format string
DestDir string
}
GitFetchRequestObj requests downloading one version archive into DestDir.
type GitFetchResultObj ¶
GitFetchResultObj points to the downloaded archive; rescan performs extract and publish.
type GitReleaseObj ¶
GitReleaseObj is one git-source release after prereleases have been filtered out.
type HelloResultObj ¶
HelloResultObj is normalized Brother.Hello data. Only Protocol is consumed; the brother's node-wide checksums are content-derived sync fingerprints (change on every ingest), so they are not carried here.
type MeshInterface ¶
type MeshInterface interface {
DialContext(ctx context.Context, network, address string) (net.Conn, error)
OwnsHost(host string) bool
Enabled() bool
}
MeshInterface is the narrow Yggdrasil node surface required by source. OwnsHost keeps Yggdrasil suffix policy in mesh, so source does not duplicate it.
type Obj ¶
type Obj struct {
// contains filtered or unexported fields
}
Obj is the source module facade with routed HTTP clients, RPC dialing, limits, and retry policy.
func New ¶
New builds clients and limits from config. meshNode may be nil, in which case Yggdrasil hosts are rejected. It also installs the routed transport into lightweigit's package-global client for metadata calls.
func (*Obj) BrotherDial ¶
func (obj *Obj) BrotherDial(ctx context.Context, localKey, remoteKey, brotherURL string) (BrotherSessionInterface, error)
BrotherDial opens a session via routedDial, optional TLS, CONNECT /rpc and a gob rpc.Client.
func (*Obj) Close ¶
Close releases idle transport connections and the package-global loader client slot.
func (*Obj) Discover ¶
Discover classifies a source and returns facts; rescan writes state. If /health confirms yggvault but Hello is invalid, this is brother unavailability, not a silent git fallback.
func (*Obj) FetchArchive ¶
func (obj *Obj) FetchArchive(ctx context.Context, reqObj GitFetchRequestObj) (GitFetchResultObj, error)
FetchArchive downloads a version archive into DestDir with retry, backoff, and size caps. It returns the file path; rescan owns extract, publish, and spool cleanup.
func (*Obj) PublicMirrorVersions ¶
func (obj *Obj) PublicMirrorVersions(ctx context.Context, rootURL string, remoteKey string) ([]PublicMirrorVersionObj, bool, error)
PublicMirrorVersions reads a yggvault public API release list and resolves each version's universal archive.
func (*Obj) Refs ¶
Refs returns tag-to-commit SHA from a smart-HTTP refs advertisement, like `git ls-remote --tags`. It uses one anonymous GET and works across common git forges without provider dispatch.
func (*Obj) Releases ¶
func (obj *Obj) Releases(ctx context.Context, sourceURL string, depth uint) ([]GitReleaseObj, bool, error)
Releases lists source release versions and drops prereleases by policy. depth==0 means full history; the loader channel is closed by our goroutine. The second result reports truncation at cMaxReleases, which callers must not treat as authoritative for deletion grace.
func (*Obj) Tags ¶
func (obj *Obj) Tags(ctx context.Context, sourceURL string, depth uint) ([]GitReleaseObj, bool, error)
Tags lists source tags as release records for keys whose upstream publishes no releases. Tags carry no prerelease flag, so storable-semver tags with a prerelease suffix are dropped for parity with the release path; non-semver names pass through as raw versions. The second result reports truncation at cMaxReleases, same semantics as Releases.
type Option ¶
type Option func(*Obj)
Option configures Obj construction.
func WithAllowLoopback ¶
func WithAllowLoopback() Option
WithAllowLoopback permits clearnet loopback dials for tests using httptest on 127/8. It is enforced as test-only, so accidental production use does not weaken SSRF protection.