Documentation
¶
Overview ¶
Package s3d is `bstore s3d`, the S3 gateway of spec section 16: a reader and a writer for clients that speak S3, authenticated with AWS Signature Version 4 in gateway mode. Reads are proven against the bucket's chain (package reader); writes are published by the identity an access key maps to (package publish). docs/s3.md is the operator's guide and the compatibility matrix.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessKey ¶
type AccessKey struct {
ID string `json:"id"`
Secret string `json:"secret,omitempty"`
SecretFile string `json:"secret_file,omitempty"`
Identity string `json:"identity"`
Buckets []string `json:"buckets,omitempty"`
}
AccessKey is one S3 access key.
type Auth ¶
type Auth struct {
Key *Key
// Seed is the request's signature: a streaming body's chunks chain
// from it, and replay protection is keyed by it.
Seed string
Scope string
Time time.Time
Payload string // the x-amz-content-sha256 value
Presign bool
// contains filtered or unexported fields
}
Auth is a request whose signature verified.
type BountyConfig ¶
type BountyConfig struct {
Satoshis uint64 `json:"satoshis"`
T uint64 `json:"t"`
K uint64 `json:"k"`
RetentionSeconds uint64 `json:"retention_seconds"`
DeadlineBlocks uint64 `json:"deadline_blocks"`
CheckC uint64 `json:"check_c"`
}
BountyConfig is the hold bounty a put asks for (spec section 4.3).
type BucketConfig ¶
type BucketConfig struct {
Bucket string `json:"bucket"`
Owner string `json:"owner"`
ID string `json:"id"`
}
BucketConfig is one bucket chain the gateway serves: the identifier, the owner's key and the bucket id (spec sections 3.3 and 16.1).
type Config ¶
type Config struct {
// Data is the data directory: identities/<name>/ (each a wallet, its
// funding trees and its outbox), store/ (the local closures), uploads/,
// state.json. Absolute.
Data string `json:"data"`
// Listen is the address S3 is served on; TLSCert and TLSKey, when both
// set, serve it over TLS (otherwise a proxy in front terminates it).
Listen string `json:"listen"`
TLSCert string `json:"tls_cert,omitempty"`
TLSKey string `json:"tls_key,omitempty"`
// Region is the SigV4 region clients sign for; Domain, when set, also
// serves virtual-host addressing (<bucket>.<domain>).
Region string `json:"region"`
Domain string `json:"domain,omitempty"`
// Node is a Teranode asset API; Settle the settlement leg (tcp:,
// rpc: or arcade:, with RPCUser, RPCPass, ArcadeKey); Headers a header
// source (bcommon headers).
Node string `json:"node"`
Settle string `json:"settle"`
RPCUser string `json:"rpc_user,omitempty"`
RPCPass string `json:"rpc_pass,omitempty"`
ArcadeKey string `json:"arcade_key,omitempty"`
Headers string `json:"headers"`
// Hosts are the overlay hosts asked and written to; Facade, when set,
// is the plane; Providers are providers pieces and entries are
// unicast to (their submit route). Quorum is how many hosts must take
// an entry when there is no facade.
Hosts []string `json:"hosts"`
Facade string `json:"facade,omitempty"`
Providers []string `json:"providers,omitempty"`
Quorum int `json:"quorum,omitempty"`
// CA, when set, is a PEM file of certificates trusted, besides the
// system's, for TLS to hosts, providers and advertisers.
CA string `json:"ca,omitempty"`
// FetchPrivate lets the gateway fetch from advertised URLs whose host
// resolves to a loopback, private or link-local address; off, such an
// advertisement is never fetched from.
FetchPrivate bool `json:"fetch_private,omitempty"`
// Identities are the writer identities, each with a wallet under
// identities/<name>; AccessKeys map S3 access keys to them; Buckets are
// the chains served.
Identities []string `json:"identities"`
AccessKeys []AccessKey `json:"access_keys"`
Buckets []BucketConfig `json:"buckets"`
// Bounty, when set, is the hold bounty every put asks for; HoldAhead is
// how many mined hold outputs of it each identity keeps ready.
Bounty *BountyConfig `json:"bounty,omitempty"`
HoldAhead int `json:"hold_ahead,omitempty"`
Limits Limits `json:"limits"`
// PieceTree and EntryTree size funding trees; FeeRate and FeeFloor are
// the fee policy.
PieceTree int `json:"piece_tree"`
EntryTree int `json:"entry_tree"`
FeeRate uint64 `json:"fee_sat_per_byte"`
FeeFloor uint64 `json:"fee_floor"`
Mainnet bool `json:"mainnet"`
// PieceWorkers is how many piece carriers a put mints and sends at once
// (default 4); PieceAhead how few outputs left on a piece tree start the
// next one in the background (default piece_tree: one always ready).
PieceWorkers int `json:"piece_workers,omitempty"`
PieceAhead int `json:"piece_ahead,omitempty"`
// Race is the hold race, settlement and reclaim the gateway runs in the
// background for its own puts.
Race RaceConfig `json:"race"`
// StoreBytes bounds the local closures kept for reading the gateway's
// own writes and for copies.
StoreBytes int64 `json:"store_bytes"`
// MetricsListen, when set, serves /metrics there, and only there.
MetricsListen string `json:"metrics_listen,omitempty"`
}
Config is the gateway's configuration file, JSON; an unknown key is refused. Every field has a default but Data, Node, Settle, Headers, Hosts, Identities, AccessKeys and Buckets.
func LoadConfig ¶
LoadConfig reads and checks a configuration file.
func (*Config) IdentityDir ¶
IdentityDir is an identity's directory.
type Key ¶
type Key struct {
ID string
Secret string
Identity string
// Buckets are the S3 bucket names the key may use; empty is every
// configured bucket.
Buckets map[string]bool
}
Key is one access key.
type Limits ¶
type Limits struct {
// MaxObject bounds a PutObject body; MaxUpload a multipart upload's
// assembled object; MaxPart one part; MaxParts the part numbers.
MaxObject int64 `json:"max_object"`
MaxUpload int64 `json:"max_upload"`
MaxPart int64 `json:"max_part"`
MaxParts int `json:"max_parts"`
// Uploads open at once, in all and per access key; UploadSeconds how
// long one may stay open.
Uploads int `json:"uploads"`
UploadsPerKey int `json:"uploads_per_key"`
UploadSeconds int `json:"upload_seconds"`
// Writes are puts, copies and completions at once; PartWrites part
// uploads at once; Reads object reads at once. Past each the gateway
// answers 503 SlowDown.
Writes int `json:"writes"`
PartWrites int `json:"part_writes"`
Reads int `json:"reads"`
// Stages are put and copy bodies streaming in at once; Lookups the
// heads, gets and listings asking hosts at once.
Stages int `json:"stages"`
Lookups int `json:"lookups"`
// MinRate is the slowest a request body may arrive, bytes a second
// averaged after its first IdleSeconds; slower is cut off.
MinRate int64 `json:"min_rate"`
// ReplayPerKey bounds the signatures one access key has remembered
// against replay; past it that key's writes wait.
ReplayPerKey int `json:"replay_per_key"`
// RequestsPerSec and Burst bound the requests of one access key.
RequestsPerSec float64 `json:"requests_per_sec"`
Burst float64 `json:"burst"`
// IdleSeconds is the longest a request body or a response may stall.
IdleSeconds int `json:"idle_seconds"`
// DeleteKeys bounds one DeleteObjects request.
DeleteKeys int `json:"delete_keys"`
}
Limits are the gateway's hardening; zero takes the default.
type Options ¶
type Options struct {
Now func() time.Time
Logf func(format string, args ...any)
// Tick paces the background work.
Tick time.Duration
// LockWait is how long an identity another process has open (a
// command run against it) is waited for at start.
LockWait time.Duration
}
Options are what an embedding caller may set beyond the configuration.
type RaceConfig ¶ added in v0.3.0
type RaceConfig struct {
// Off leaves races to the command line, run against a stopped gateway.
Off bool `json:"off,omitempty"`
// WindowSeconds is the race window (default an hour); TickSeconds the
// pause between passes (default 10).
WindowSeconds int64 `json:"window_seconds,omitempty"`
TickSeconds int `json:"tick_seconds,omitempty"`
// Budget is the most paid for one settlement challenge a provider
// prices (default 0: only free answers).
Budget uint64 `json:"budget,omitempty"`
// NoPublish keeps failed challenges unpublished as outcome records.
NoPublish bool `json:"no_publish,omitempty"`
}
RaceConfig is the gateway's background race (spec section 9.4): for each identity's own puts with a bounty, the race judged, settled by rank once closed, the remittances sent, and the hold output reclaimed after the deadline when nothing settled, as `bstore holds`, `settle` and `reclaim` would. On by default.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is one running gateway.
func New ¶
New opens a gateway over a checked configuration: every identity's wallet (bstore s3d init creates them), its funding trees and outbox, the local store and the state.