diff --git a/pkg/node/dispatcher.go b/pkg/node/dispatcher.go index f6b4124..67be89e 100644 --- a/pkg/node/dispatcher.go +++ b/pkg/node/dispatcher.go @@ -1,34 +1,43 @@ +package node + +import ( + "fmt" + + "github.com/Snider/Mining/pkg/ueps" +) + // pkg/node/dispatcher.go func (n *NodeManager) DispatchUEPS(pkt *ueps.ParsedPacket) error { - // 1. The "Threat" Circuit Breaker (L5 Guard) - if pkt.Header.ThreatScore > 50000 { - // High threat? Drop it. Don't even parse the payload. - // This protects the Agent from "semantic viruses" - return fmt.Errorf("packet rejected: threat score %d exceeds safety limit", pkt.Header.ThreatScore) - } + // 1. The "Threat" Circuit Breaker (L5 Guard) + if pkt.Header.ThreatScore > 50000 { + // High threat? Drop it. Don't even parse the payload. + // This protects the Agent from "semantic viruses" + return fmt.Errorf("packet rejected: threat score %d exceeds safety limit", pkt.Header.ThreatScore) + } // 2. The "Intent" Router (L9 Semantic) switch pkt.Header.IntentID { case 0x01: // Handshake / Hello - return n.handleHandshake(pkt) + // return n.handleHandshake(pkt) case 0x20: // Compute / Job Request // "Hey, can you run this Docker container?" // Check local resources first (Self-Validation) - return n.handleComputeRequest(pkt.Payload) + // return n.handleComputeRequest(pkt.Payload) case 0x30: // Rehab / Intervention // "Violet says you are hallucinating. Pause execution." // This is the "Benevolent Intervention" Axiom. - return n.enterRehabMode(pkt.Payload) + // return n.enterRehabMode(pkt.Payload) case 0xFF: // Extended / Custom // Check the payload for specific sub-protocols (e.g. your JSON blobs) - return n.handleApplicationData(pkt.Payload) + // return n.handleApplicationData(pkt.Payload) default: return fmt.Errorf("unknown intent ID: 0x%X", pkt.Header.IntentID) } + return nil } diff --git a/pkg/node/peer.go b/pkg/node/peer.go index 4c76962..71b815b 100644 --- a/pkg/node/peer.go +++ b/pkg/node/peer.go @@ -10,6 +10,7 @@ import ( "time" "github.com/Snider/Mining/pkg/logging" + "github.com/Snider/Mining/pkg/ueps" "github.com/Snider/Poindexter" "github.com/adrg/xdg" ) @@ -718,7 +719,7 @@ func (n *NodeManager) SendEthicalPacket(peerID string, intent uint8, data []byte pkt := ueps.NewBuilder(intent, data) // 3. Seal it - wireBytes, err := pkt.MarshalAndSign(secret) + _, err = pkt.MarshalAndSign(secret) if err != nil { return err } diff --git a/pkg/ueps/packet.go b/pkg/ueps/packet.go index 8331202..7c75334 100644 --- a/pkg/ueps/packet.go +++ b/pkg/ueps/packet.go @@ -6,7 +6,6 @@ import ( "crypto/sha256" "encoding/binary" "errors" - "fmt" "io" )