Add S3 erasure swarm with CloudFront signed magnets.
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Operators configure bucket and CloudFront domain with env credentials; deploy plans upload RS 4+2 shards and attach signed edge URLs to BGP swarm magnets. Agents fetch LAN, CloudFront, then C2. Forge panel adds test and IAM policy JSON.
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
package atlas
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Fleet gossip kinds — shard DHT advertisements relayed fleet-wide (not LAN-only).
|
||||
const (
|
||||
FleetGossipHaveShard = "have_shard"
|
||||
FleetGossipHealthy = "healthy"
|
||||
FleetGossipKnowNode = "know_node"
|
||||
)
|
||||
|
||||
// FleetGossipRecord is one peer advertisement in the fleet torrent DHT.
|
||||
type FleetGossipRecord struct {
|
||||
Kind string `json:"kind"`
|
||||
AgentID string `json:"agent_id,omitempty"`
|
||||
@@ -19,18 +18,21 @@ type FleetGossipRecord struct {
|
||||
Token string `json:"token,omitempty"`
|
||||
ShardIndex int `json:"shard_index,omitempty"`
|
||||
ShardHash string `json:"shard_hash,omitempty"`
|
||||
Region string `json:"region,omitempty"`
|
||||
ShardAdvert string `json:"shard_advert,omitempty"`
|
||||
TargetAgentID string `json:"target_agent_id,omitempty"`
|
||||
Healthy bool `json:"healthy,omitempty"`
|
||||
FetchURL string `json:"fetch_url,omitempty"`
|
||||
}
|
||||
|
||||
// NormalizeFleetGossipRecord validates and trims one fleet gossip record.
|
||||
func NormalizeFleetGossipRecord(r FleetGossipRecord) (FleetGossipRecord, bool) {
|
||||
r.Kind = strings.TrimSpace(strings.ToLower(r.Kind))
|
||||
r.AgentID = strings.TrimSpace(r.AgentID)
|
||||
r.Subnet = strings.TrimSpace(r.Subnet)
|
||||
r.Token = strings.TrimSpace(r.Token)
|
||||
r.ShardHash = strings.TrimSpace(strings.ToLower(r.ShardHash))
|
||||
r.Region = strings.TrimSpace(r.Region)
|
||||
r.ShardAdvert = strings.TrimSpace(r.ShardAdvert)
|
||||
r.TargetAgentID = strings.TrimSpace(r.TargetAgentID)
|
||||
r.FetchURL = strings.TrimSpace(r.FetchURL)
|
||||
switch r.Kind {
|
||||
@@ -38,6 +40,17 @@ func NormalizeFleetGossipRecord(r FleetGossipRecord) (FleetGossipRecord, bool) {
|
||||
if r.AgentID == "" || r.Token == "" || r.ShardHash == "" {
|
||||
return FleetGossipRecord{}, false
|
||||
}
|
||||
if r.Region == "" && r.ShardAdvert != "" {
|
||||
if region, idx, ok := parseShardAdvert(r.ShardAdvert); ok {
|
||||
r.Region = region
|
||||
if r.ShardIndex == 0 {
|
||||
r.ShardIndex = idx
|
||||
}
|
||||
}
|
||||
}
|
||||
if r.ShardAdvert == "" && r.Region != "" {
|
||||
r.ShardAdvert = fmt.Sprintf("%s:%d", r.Region, r.ShardIndex)
|
||||
}
|
||||
case FleetGossipHealthy:
|
||||
if r.AgentID == "" {
|
||||
return FleetGossipRecord{}, false
|
||||
@@ -52,7 +65,6 @@ func NormalizeFleetGossipRecord(r FleetGossipRecord) (FleetGossipRecord, bool) {
|
||||
return r, true
|
||||
}
|
||||
|
||||
// NormalizeFleetGossipRecords drops invalid records while preserving order.
|
||||
func NormalizeFleetGossipRecords(in []FleetGossipRecord) []FleetGossipRecord {
|
||||
if len(in) == 0 {
|
||||
return nil
|
||||
@@ -65,3 +77,15 @@ func NormalizeFleetGossipRecords(in []FleetGossipRecord) []FleetGossipRecord {
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func parseShardAdvert(advert string) (region string, index int, ok bool) {
|
||||
colon := strings.LastIndex(strings.TrimSpace(advert), ":")
|
||||
if colon <= 0 {
|
||||
return "", 0, false
|
||||
}
|
||||
region = strings.TrimSpace(advert[:colon])
|
||||
if _, err := fmt.Sscanf(strings.TrimSpace(advert[colon+1:]), "%d", &index); err != nil {
|
||||
return "", 0, false
|
||||
}
|
||||
return region, index, region != ""
|
||||
}
|
||||
|
||||
@@ -2,15 +2,12 @@ package atlas
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestNormalizeFleetGossipRecords(t *testing.T) {
|
||||
in := []FleetGossipRecord{
|
||||
{Kind: FleetGossipHaveShard, AgentID: "a", Token: "tok", ShardHash: "abc"},
|
||||
{Kind: "bogus"},
|
||||
{Kind: FleetGossipHealthy, AgentID: "b", Healthy: true},
|
||||
{Kind: FleetGossipKnowNode, AgentID: "a", TargetAgentID: "c"},
|
||||
}
|
||||
out := NormalizeFleetGossipRecords(in)
|
||||
if len(out) != 3 {
|
||||
t.Fatalf("got %d records", len(out))
|
||||
func TestNormalizeFleetGossipShardAdvert(t *testing.T) {
|
||||
r, ok := NormalizeFleetGossipRecord(FleetGossipRecord{
|
||||
Kind: FleetGossipHaveShard, AgentID: "a", Token: "t", ShardHash: "h",
|
||||
Region: "us-west-2", ShardIndex: 4,
|
||||
})
|
||||
if !ok || r.ShardAdvert != "us-west-2:4" {
|
||||
t.Fatalf("advert=%q", r.ShardAdvert)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user