Documentation ¶
Index ¶
- Variables
- func QueryInterface[T NodeImpl](node *Node) T
- func RegisterNodeImpl(desc *NodeImplDesc)
- func RegisterPolicyImpl(desc *PolicyImplDesc)
- type BaseNodeImpl
- func (n *BaseNodeImpl) CastTo(ptr any) any
- func (n *BaseNodeImpl) NodeImplTrait() NodeImpl
- func (n *BaseNodeImpl) OnAttach() error
- func (n *BaseNodeImpl) OnDetach()
- func (n *BaseNodeImpl) OnInterest(interest ndn.Interest, rawInterest enc.Wire, sigCovered enc.Wire, ...)
- func (n *BaseNodeImpl) TreeNode() *Node
- type CacheEntry
- type Callback
- type Event
- type EventGetter
- type EventTarget
- type ExpressPoint
- func (n *ExpressPoint) CastTo(ptr any) any
- func (n *ExpressPoint) NeedCallback(mNode MatchedNode, callback Callback, appParam enc.Wire, ...) error
- func (n *ExpressPoint) NeedChan(mNode MatchedNode, appParam enc.Wire, intConfig *ndn.InterestConfig, ...) chan NeedResult
- func (n *ExpressPoint) NodeImplTrait() NodeImpl
- func (n *ExpressPoint) OnInterest(interest ndn.Interest, rawInterest enc.Wire, sigCovered enc.Wire, ...)
- func (n *ExpressPoint) SearchCache(event *Event) enc.Wire
- type FixedHmacIntSignerPolicy
- type FixedHmacSignerPolicy
- type LeafNode
- type ListenerList
- type MatchedNode
- type MemStoragePolicy
- type NeedResult
- type Node
- func (n *Node) AddEventListener(eventName PropKey, callback *Callback)
- func (n *Node) Apply(matching enc.Matching) *MatchedNode
- func (n *Node) At(path enc.NamePattern) *Node
- func (n *Node) AttachedPrefix() enc.Name
- func (n *Node) Child(edge enc.ComponentPattern) *Node
- func (n *Node) Children() []*Node
- func (n *Node) ConstructName(matching enc.Matching, ret enc.Name) error
- func (n *Node) ContinueMatch(remainingName enc.Name, curMatching enc.Matching) *Node
- func (n *Node) Depth() uint
- func (n *Node) Engine() ndn.Engine
- func (n *Node) Get(propName PropKey) any
- func (n *Node) GetEvent(eventName PropKey) *EventTarget
- func (n *Node) Impl() NodeImpl
- func (n *Node) Log() *log.Entry
- func (n *Node) Match(name enc.Name) *MatchedNode
- func (n *Node) OnAttach(path enc.NamePattern, engine ndn.Engine) error
- func (n *Node) OnDetach()
- func (n *Node) OnInterest(interest ndn.Interest, rawInterest enc.Wire, sigCovered enc.Wire, ...)
- func (n *Node) Parent() *Node
- func (n *Node) PutNode(path enc.NamePattern, desc *NodeImplDesc) *Node
- func (n *Node) RemoveEventListener(eventName PropKey, callback *Callback)
- func (n *Node) RootNode() *Node
- func (n *Node) Set(propName PropKey, value any) error
- func (n *Node) SetAttachedPrefix(prefix enc.Name)
- func (n *Node) UpEdge() enc.ComponentPattern
- type NodeDesc
- type NodeFunc
- type NodeImpl
- type NodeImplDesc
- type Policy
- type PolicyDesc
- type PolicyImplDesc
- type PropKey
- type PropertyDesc
- type RegisterPolicy
- type SchemaDesc
- type Sha256SignerPolicy
- type Tree
- func (t *Tree) At(path enc.NamePattern) *Node
- func (t *Tree) Attach(prefix enc.Name, engine ndn.Engine) error
- func (t *Tree) Detach()
- func (t *Tree) Engine() ndn.Engine
- func (t *Tree) Match(name enc.Name) *MatchedNode
- func (t *Tree) PutNode(path enc.NamePattern, desc *NodeImplDesc) *Node
- func (t *Tree) RLock()
- func (t *Tree) RUnlock()
- func (t *Tree) Root() *Node
- type ValidRes
Constants ¶
This section is empty.
Variables ¶
var NodeRegister map[string]*NodeImplDesc
var PolicyRegister map[string]*PolicyImplDesc
Functions ¶
func QueryInterface ¶ added in v0.0.2
QueryInterface casts a node to a specific NodeImpl type
func RegisterNodeImpl ¶ added in v0.0.2
func RegisterNodeImpl(desc *NodeImplDesc)
func RegisterPolicyImpl ¶ added in v0.0.2
func RegisterPolicyImpl(desc *PolicyImplDesc)
Types ¶
type BaseNodeImpl ¶ added in v0.0.2
type BaseNodeImpl struct { Node *Node OnAttachEvt *EventTarget OnDetachEvt *EventTarget }
BaseNodeImpl is the default implementation of NodeImpl
func (*BaseNodeImpl) CastTo ¶ added in v0.0.2
func (n *BaseNodeImpl) CastTo(ptr any) any
func (*BaseNodeImpl) NodeImplTrait ¶ added in v0.0.2
func (n *BaseNodeImpl) NodeImplTrait() NodeImpl
func (*BaseNodeImpl) OnAttach ¶ added in v0.0.2
func (n *BaseNodeImpl) OnAttach() error
OnAttach is called when the node is attached to an engine
func (*BaseNodeImpl) OnDetach ¶ added in v0.0.2
func (n *BaseNodeImpl) OnDetach()
OnDetach is called when the node is detached from an engine
func (*BaseNodeImpl) OnInterest ¶ added in v0.0.2
func (n *BaseNodeImpl) OnInterest( interest ndn.Interest, rawInterest enc.Wire, sigCovered enc.Wire, reply ndn.ReplyFunc, deadline time.Time, matching enc.Matching, )
OnInterest is the callback function when there is an incoming Interest.
func (*BaseNodeImpl) TreeNode ¶ added in v0.0.2
func (n *BaseNodeImpl) TreeNode() *Node
type Event ¶
type Event struct { // TargetNode is the node that triggers the event, valid for all events. // Generally equals to Target.Node. Exception: on the callback of Need, // Target.Node is matched with Data name but TargetNode is the Interest node. TargetNode *Node // Target is the target (matched node) that triggers the event // Valid for events handling a specific packet. Target *MatchedNode // Deadline is now + InterestLifetime Deadline *time.Time // RawPacket is the raw Interest or Data wire RawPacket enc.Wire // SigCovered contains the bytes of the raw packet that are covered by the signature SigCovered enc.Wire // Signature is the signature of the packet received. Signature ndn.Signature // Interest is the received Interest. Interest ndn.Interest // Data is the received Data. Data ndn.Data // IntConfig is the config of the Interest that is going to encode. IntConfig *ndn.InterestConfig // DataConfig is the config of the Data that is going to produce. DataConfig *ndn.DataConfig // Content is the content of Data or AppParam of Interest. Content enc.Wire // NackReason is the reason of Network NACK given by the forwarder. NackReason *uint64 // ValidResult is the validation result given by last validator. ValidResult *ValidRes // SelfProduced indicates whether the Data is produced by myself (this program). SelfProduced *bool // ValidDuration is The validity period of a data in the storage produced by this node // i.e. how long the local storage will serve it. // Should be larger than FreshnessPeriod. Not affected data fetched remotely. ValidDuration *time.Duration // Reply is the func called to reply to an Interest Reply ndn.ReplyFunc // NeedStatus is the result status in the callback of need() NeedStatus *ndn.InterestResult // Error is the optional error happened in an event Error error // Extra arguments used by application Extra map[string]any }
Event represents the context of a triggered event
type EventGetter ¶ added in v0.0.2
type EventGetter func(owner any) *EventTarget
func DefaultEventTarget ¶ added in v0.0.2
func DefaultEventTarget(event PropKey) EventGetter
DefaultEventTarget returns the default event target getter of given event name.
type EventTarget ¶ added in v0.0.2
type EventTarget struct {
// contains filtered or unexported fields
}
Event is a chain of callback functions for an event. The execution order is supposed to be the addition order.
func (*EventTarget) Add ¶ added in v0.0.2
func (e *EventTarget) Add(callback *Callback)
Add a callback. Note that callback should be a *func.
func (*EventTarget) Dispatch ¶ added in v0.0.2
func (e *EventTarget) Dispatch(event *Event) any
Dispatch fires the event, calls every callback and returns the last result
func (*EventTarget) DispatchUntil ¶ added in v0.0.2
func (e *EventTarget) DispatchUntil(event *Event, acceptFunc func(any) bool) any
DispatchUntil fires the event until `acceptFunc` returns `true`, and returns the accepted result Returns the last result if no result is acceptable, and nil if no callback is called.
func (*EventTarget) Remove ¶ added in v0.0.2
func (e *EventTarget) Remove(callback *Callback)
Remove a callback Seems not useful at all. Do we remove it?
func (*EventTarget) Val ¶ added in v0.0.2
func (e *EventTarget) Val() []*Callback
Val returns the value of the event. Used by nodes only.
type ExpressPoint ¶
type ExpressPoint struct { BaseNodeImpl OnInt *EventTarget OnValidateInt *EventTarget OnValidateData *EventTarget OnSearchStorage *EventTarget OnSaveStorage *EventTarget OnGetIntSigner *EventTarget CanBePrefix bool MustBeFresh bool Lifetime time.Duration SupressInt bool }
func (*ExpressPoint) CastTo ¶ added in v0.0.2
func (n *ExpressPoint) CastTo(ptr any) any
func (*ExpressPoint) NeedCallback ¶ added in v0.0.2
func (n *ExpressPoint) NeedCallback( mNode MatchedNode, callback Callback, appParam enc.Wire, intConfig *ndn.InterestConfig, supress bool, ) error
NeedCallback is callback version of Need(). The Need() function to obtain the corresponding Data. May express an Interest if the Data is not stored. `intConfig` is optional and if given, will overwrite the default setting. The callback function will be called in another goroutine no matter what the result is. So if `callback` can handle errors, it is safe to ignore the return value. TODO: (Urgent) NeedXXX needs a way for the user to optionally specify the deadline of the Interest without touching anything else in intConfig
func (*ExpressPoint) NeedChan ¶ added in v0.0.2
func (n *ExpressPoint) NeedChan( mNode MatchedNode, appParam enc.Wire, intConfig *ndn.InterestConfig, supress bool, ) chan NeedResult
NeedChan is the channel version of Need()
func (*ExpressPoint) NodeImplTrait ¶ added in v0.0.2
func (n *ExpressPoint) NodeImplTrait() NodeImpl
func (*ExpressPoint) OnInterest ¶
func (*ExpressPoint) SearchCache ¶
func (n *ExpressPoint) SearchCache(event *Event) enc.Wire
type FixedHmacIntSignerPolicy ¶ added in v0.0.2
type FixedHmacIntSignerPolicy struct { Key string // contains filtered or unexported fields }
func (*FixedHmacIntSignerPolicy) Apply ¶ added in v0.0.2
func (p *FixedHmacIntSignerPolicy) Apply(node *Node)
func (*FixedHmacIntSignerPolicy) PolicyTrait ¶ added in v0.0.2
func (p *FixedHmacIntSignerPolicy) PolicyTrait() Policy
type FixedHmacSignerPolicy ¶ added in v0.0.2
type FixedHmacSignerPolicy struct { Key string KeyName enc.Name SignForCert bool ExpireTime time.Duration }
func (*FixedHmacSignerPolicy) Apply ¶ added in v0.0.2
func (p *FixedHmacSignerPolicy) Apply(node *Node)
func (*FixedHmacSignerPolicy) PolicyTrait ¶ added in v0.0.2
func (p *FixedHmacSignerPolicy) PolicyTrait() Policy
type LeafNode ¶
type LeafNode struct { ExpressPoint OnGetDataSigner *EventTarget ContentType ndn.ContentType Freshness time.Duration ValidDur time.Duration }
LeafNode is a leaf of the NTSchema tree, a point where Data packets can be named.
func (*LeafNode) NodeImplTrait ¶ added in v0.0.2
func (*LeafNode) Provide ¶
func (n *LeafNode) Provide( mNode MatchedNode, content enc.Wire, dataCfg *ndn.DataConfig, ) enc.Wire
Provide a Data packet with given name and content. Name is constructed from matching if nil. If given, name must agree with matching.
type ListenerList ¶ added in v0.0.2
type ListenerList []string
type MatchedNode ¶ added in v0.0.2
MatchedNode represents a node with a matching
func (MatchedNode) Call ¶ added in v0.0.2
func (mNode MatchedNode) Call(funcName string, args ...any) any
Call calls the specified function provided by the node with give agruments.
func (MatchedNode) Logger ¶ added in v0.0.2
func (mNode MatchedNode) Logger(module string) *log.Entry
Logger returns the logger used in functions provided by this node. If module is "", the node's impl's class name will be used as a default value.
func (MatchedNode) Refine ¶ added in v0.0.2
func (mNode MatchedNode) Refine(name enc.Name) *MatchedNode
Refine a matching with a longer name. `name` must include current name as a prefix.
type MemStoragePolicy ¶ added in v0.0.2
type MemStoragePolicy struct {
// contains filtered or unexported fields
}
MemStoragePolicy is a policy that stored data in a memory storage. It will iteratively applies to all children in a subtree.
func (*MemStoragePolicy) Apply ¶ added in v0.0.2
func (p *MemStoragePolicy) Apply(node *Node)
func (*MemStoragePolicy) PolicyTrait ¶ added in v0.0.2
func (p *MemStoragePolicy) PolicyTrait() Policy
type NeedResult ¶ added in v0.0.2
type NeedResult struct { // Status is the result of Need (data, NACKed, timed out, validation failure) Status ndn.InterestResult // Content is the needed data object Content enc.Wire // Data packet if available. Note that this may be nil if the node aggregates multiple packets. // Please use Extra to obtain extra info in that case. Data ndn.Data // ValidResult is the result of validation of this data object ValidResult *ValidRes // NackReason is the reason for NACK NackReason *uint64 // Extra info used by application Extra map[string]any }
func (NeedResult) Get ¶ added in v0.0.2
func (r NeedResult) Get() (ndn.InterestResult, enc.Wire)
type Node ¶ added in v0.0.2
type Node struct {
// contains filtered or unexported fields
}
Node is the class for a NTSchema node, the container of NodeImpl. TODO: Inheritance from BaseNode is really a bad model of this thing but I cannot come up with a better one in limited time. If possible, a mixin programming model may be better. TODO: (updated) a better choice may be separate the tree node (that handles Child, Parent, etc.) and the polymorphic functional part (than handles Get, Set, Events, etc.) For WASM use in the future, we may need a list of properties. Also, add ENV for Init.
func (*Node) AddEventListener ¶ added in v0.0.2
AddEventListener adds `callback` to the event `eventName` Note that callback is a function pointer (so it's comparable)
func (*Node) Apply ¶ added in v0.0.2
func (n *Node) Apply(matching enc.Matching) *MatchedNode
Apply a (variable) matching and obtain the corresponding NDN name For example, apply {"id":[]byte{"aa"}} to a node at /ndn/<id> will get /ndn/aa Will attach "params-sha256" and "sha256digest" to the end of the name if exists.
func (*Node) At ¶ added in v0.0.2
func (n *Node) At(path enc.NamePattern) *Node
At gets a node/subtree at a given pattern path. The path does not include the attached prefix.
func (*Node) AttachedPrefix ¶ added in v0.0.2
AttachedPrefix of the root node. Must be nil for all other nodes and before Attach.
func (*Node) Child ¶ added in v0.0.2
func (n *Node) Child(edge enc.ComponentPattern) *Node
Child of given edge
func (*Node) ConstructName ¶ added in v0.0.2
ConstructName is the aux function used by Apply
func (*Node) ContinueMatch ¶ added in v0.0.2
ContinueMatch is a sub-function used by Match
func (*Node) Depth ¶ added in v0.0.2
Depth of the node in the tree. It includes the attached prefix, so the root node may have a positive depth For example, if the root is attached at prefix /ndn, then the child of path /<id> from the root will have a depth=2.
func (*Node) GetEvent ¶ added in v0.0.2
func (n *Node) GetEvent(eventName PropKey) *EventTarget
GetEvent returns an event with a given event name. Return nil if not exists.
func (*Node) Match ¶ added in v0.0.2
func (n *Node) Match(name enc.Name) *MatchedNode
Match an NDN name to a (variable) matching For example, /ndn/aa may match to a node at /ndn/<id> with matching <id> = "aa"
func (*Node) OnAttach ¶ added in v0.0.2
OnAttach is called when the node is attached to an engine Node will call the event set by policy
func (*Node) OnDetach ¶ added in v0.0.2
func (n *Node) OnDetach()
OnDetach is called when the node is detached from an engine BaseNode will call the event set by policy
func (*Node) OnInterest ¶ added in v0.0.2
func (n *Node) OnInterest( interest ndn.Interest, rawInterest enc.Wire, sigCovered enc.Wire, reply ndn.ReplyFunc, deadline time.Time, matching enc.Matching, )
OnInterest is the function called when an Interest comes. A base node shouldn't receive any Interest, so drops it.
func (*Node) PutNode ¶ added in v0.0.2
func (n *Node) PutNode(path enc.NamePattern, desc *NodeImplDesc) *Node
PutNode creates a node/subtree at a given pattern path. The path does not include the attached prefix. Returns the new node.
func (*Node) RemoveEventListener ¶ added in v0.0.2
RemoveEventListener removes `callback` from the event `eventName` Note that callback is a function pointer (so it's comparable)
func (*Node) SetAttachedPrefix ¶ added in v0.0.2
SetAttachedPrefix sets the attached prefix of the root node.
func (*Node) UpEdge ¶ added in v0.0.2
func (n *Node) UpEdge() enc.ComponentPattern
UpEdge is the edge value from its parent to itself
type NodeDesc ¶ added in v0.0.2
type NodeDesc struct { Type string `json:"type"` Attrs map[string]any `json:"attrs,omitempty"` Events map[string]ListenerList `json:"events,omitempty"` }
type NodeFunc ¶ added in v0.0.2
type NodeFunc func(mNode MatchedNode, args ...any) any
type NodeImpl ¶ added in v0.0.2
type NodeImpl interface { // NodeImplTrait is the type trait of NTNode NodeImplTrait() NodeImpl // CastTo cast the current struct to a pointer which has the same type as ptr // Supposed to be used as: // // leafNode.CastTo((*ExpressPoint)(nil)) // Get *ExpressPoint // // This is because `leafNode.(*ExpressPoint)` fails. CastTo(ptr any) any // OnInterest is the callback function when there is an incoming Interest. OnInterest(interest ndn.Interest, rawInterest enc.Wire, sigCovered enc.Wire, reply ndn.ReplyFunc, deadline time.Time, matching enc.Matching) // OnAttach is called when the node is attached to an engine OnAttach() error // OnDetach is called when the node is detached from an engine OnDetach() // TreeNode returns the node container it is in. TreeNode() *Node }
NodeImpl represents the functional part of a node (subtree) of NTSchema. Besides functions listed here, NodeImpl also needs a creator that creates the Node.
func CreateBaseNode ¶ added in v0.0.2
func CreateExpressPoint ¶ added in v0.0.2
func CreateLeafNode ¶ added in v0.0.2
type NodeImplDesc ¶ added in v0.0.2
type NodeImplDesc struct { ClassName string Properties map[PropKey]PropertyDesc Events map[PropKey]EventGetter Create func(*Node) NodeImpl Functions map[string]NodeFunc }
var BaseNodeDesc *NodeImplDesc
var ExpressPointDesc *NodeImplDesc
var LeafNodeDesc *NodeImplDesc
type Policy ¶ added in v0.0.2
type Policy interface { // PolicyTrait is the type trait of NTPolicy PolicyTrait() Policy // Apply the policy at a node (subtree). May modify the children of the given node. // The execution order is node.Init() -> policy.Apply() -> onAttach() // So the properties set here will overwrite Init()'s default values, // but be overwriten by onAttach(). Apply(node *Node) }
NTPolicy represents a policy, which is a modifier that sets properties and registers events during the initialization of a schema tree. The execution order is: construct the tree -> apply policies & env setup -> attach to engine (see Tree) Though policies are also considered as static knowledge (at compile time), they may be configured differently on different nodes. For example, an storage may access different folders for different instances. TODO: Design for this configuration under different environments. For example, the path to a storage, the name of the self-key, etc are knowledge specific to one instance, and thus dynamically configured. Currently I don't have an idea on the best way to separate the "statically shared part" (NTTree and the nodes) and the "dynamically configure part". (#ENV)
func NewFixedHmacIntSignerPolicy ¶ added in v0.0.2
func NewFixedHmacIntSignerPolicy() Policy
func NewFixedHmacSignerPolicy ¶ added in v0.0.2
func NewFixedHmacSignerPolicy() Policy
func NewMemStoragePolicy ¶ added in v0.0.2
func NewMemStoragePolicy() Policy
func NewRegisterPolicy ¶ added in v0.0.2
func NewRegisterPolicy() Policy
func NewSha256SignerPolicy ¶ added in v0.0.2
func NewSha256SignerPolicy() Policy
type PolicyDesc ¶ added in v0.0.2
type PolicyImplDesc ¶ added in v0.0.2
type PolicyImplDesc struct { ClassName string Properties map[PropKey]PropertyDesc Events map[PropKey]EventGetter Create func() Policy }
type PropKey ¶
type PropKey string
PropKey is the type of properties of a node. A property of a node gives the default setting of some procedure as well as event callbacks. We design in this way to support DSL and WASM in future.
const ( // The event called when the node is attached to an engine. [NodeOnAttachEvent] PropOnAttach PropKey = "OnAttachEvt" // The event called when the node is detached from an engine. [NodeOnDetachEvent] PropOnDetach PropKey = "OnDetachEvt" // The event called when an ExpressingPoint or LeafNode receives an Interest. [NodeOnIntEvent] PropOnInterest PropKey = "OnInt" // The event called when an ExpressingPoint or LeafNode verifies the signature of an Interest. [NodeValidateEvent] PropOnValidateInt PropKey = "OnValidateInt" // The event called when an ExpressingPoint or LeafNode verifies the signature of a Data. [NodeValidateEvent] PropOnValidateData PropKey = "OnValidateData" // The event called when an ExpressingPoint or LeafNode searches the storage on Need(). [NodeSearchStorageEvent] PropOnSearchStorage PropKey = "OnSearchStorage" // The event called to get a signer for an Interest PropOnGetIntSigner PropKey = "OnGetIntSigner" // The event called to get a signer for a Data PropOnGetDataSigner PropKey = "OnGetDataSigner" // The event called when an ExpressingPoint or LeafNode saves a packet into the storage. // The packet may be produced locally or fetched from the network. // TODO: Add a sign to distinguish them. // [NodeSaveStorageEvent] PropOnSaveStorage PropKey = "OnSaveStorage" // Default CanBePrefix for outgoing Interest. [bool] PropCanBePrefix PropKey = "CanBePrefix" // Default MustBeFresh for outgoing Interest. [bool] PropMustBeFresh PropKey = "MustBeFresh" // Default Lifetime for outgoing Interest. [time.Duration] PropLifetime PropKey = "Lifetime" // If true, only local storage is searched. No Interest will be expressed. // Note: may be overwritten by the Context. // [bool] PropSuppressInt PropKey = "SupressInt" // Default ContentType for produced Data. [ndn.ContentType] PropContentType PropKey = "ContentType" // Default FreshnessPeriod for produced Data. [time.Duration] PropFreshness PropKey = "Freshness" // How long the data is supposed to be stored in the storage. [time.Duration] // The validity period of a data in the storage produced by this node, // i.e. how long the local storage will serve it. // Should be larger than FreshnessPeriod. Not affected data fetched remotely. // This is only the rough way to express the life period of some temporary data. // For long durable data stored in databases, etc., the users should use the ways // specified by the storage developers to express the lifetime. PropValidDuration PropKey = "ValidDur" )
type PropertyDesc ¶ added in v0.0.2
func DefaultPropertyDesc ¶ added in v0.0.2
func DefaultPropertyDesc(prop PropKey) PropertyDesc
DefaultPropertyDesc returns the default property descriptor of given property name.
func MatchingPropertyDesc ¶ added in v0.0.2
func MatchingPropertyDesc(prop PropKey) PropertyDesc
MatchingPropertyDesc returns the descriptor of a `enc.Matching` property. It is of type `map[string]any` in JSON, where `any` is a string.
func NamePropertyDesc ¶ added in v0.0.2
func NamePropertyDesc(prop PropKey) PropertyDesc
NamePropertyDesc returns the descriptor of a enc.Name property, which gives an NDN Name in string. Note: Get/Set functions are less used by the go program, as Go can access the field directly.
func SubNodePropertyDesc ¶ added in v0.0.2
func SubNodePropertyDesc(pathStr string, prop PropKey) PropertyDesc
SubNodePropertyDesc inherites a subnode's property as a property of the subtree's root.
func TimePropertyDesc ¶ added in v0.0.2
func TimePropertyDesc(prop PropKey) PropertyDesc
TimePropertyDesc returns the descriptor of a time property, which gives numbers&strings in milliseconds. Note: Get/Set functions are less used by the go program, as Go can access the field directly.
type RegisterPolicy ¶ added in v0.0.2
type RegisterPolicy struct { RegisterIf bool // It is map[string]any in json // but the any can be a string Patterns enc.Matching }
func (*RegisterPolicy) Apply ¶ added in v0.0.2
func (p *RegisterPolicy) Apply(node *Node)
func (*RegisterPolicy) PolicyTrait ¶ added in v0.0.2
func (p *RegisterPolicy) PolicyTrait() Policy
type SchemaDesc ¶ added in v0.0.2
type SchemaDesc struct { Nodes map[string]NodeDesc `json:"nodes"` Policies []PolicyDesc `json:"policies"` }
func (*SchemaDesc) Instantiate ¶ added in v0.0.2
func (sd *SchemaDesc) Instantiate(environment map[string]any) *Tree
type Sha256SignerPolicy ¶ added in v0.0.2
type Sha256SignerPolicy struct{}
func (*Sha256SignerPolicy) Apply ¶ added in v0.0.2
func (p *Sha256SignerPolicy) Apply(node *Node)
func (*Sha256SignerPolicy) PolicyTrait ¶ added in v0.0.2
func (p *Sha256SignerPolicy) PolicyTrait() Policy
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree represents an NTSchema tree. It is supposed to be a static knowledge and shared by all parties in the system at compile time. The execution order: construct the tree -> apply policies & env setup -> attach to engine
func CreateFromJson ¶ added in v0.0.2
CreateFromJson creates a schema tree from json description and a given environment
func (*Tree) At ¶
func (t *Tree) At(path enc.NamePattern) *Node
At the path return the node. Path does not include the attached prefix.
func (*Tree) Match ¶
func (t *Tree) Match(name enc.Name) *MatchedNode
Match an NDN name to a (variable) matching
func (*Tree) PutNode ¶
func (t *Tree) PutNode(path enc.NamePattern, desc *NodeImplDesc) *Node
PutNode puts the specified node at the specified path. Path does not include the attached prefix.
type ValidRes ¶
type ValidRes = int
ValidRes is the result of data/interest signature validation, given by one validator. When there are multiple validators chained, a packet is valid when there is at least one VrPass and no VrFail.
const ( VrFail ValidRes = -2 // An immediate failure. Abort the validation. VrTimeout ValidRes = -1 // Timeout. Abort the validation. VrSilence ValidRes = 0 // The current validator cannot give any result. VrPass ValidRes = 1 // The current validator approves the packet. VrBypass ValidRes = 2 // An immediate success. Bypasses the rest validators that are not executed yet. VrCachedData ValidRes = 3 // The data is obtained from a local cache, and the signature is checked before. )
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
demosec gives a proof-of-concept demo of how security will be implemented in NTSchema
|
demosec gives a proof-of-concept demo of how security will be implemented in NTSchema |
Generated by the generator, DO NOT modify manually
|
Generated by the generator, DO NOT modify manually |
Generated by the generator, DO NOT modify manually
|
Generated by the generator, DO NOT modify manually |