diff --git a/gql.go b/gql.go index 8b31955..9b3e359 100644 --- a/gql.go +++ b/gql.go @@ -1195,6 +1195,13 @@ type GQLExt struct { Listen string `gv:"listen"` } +func (ext *GQLExt) PostDeserialize(*Context) error { + ext.resolver_response = map[uuid.UUID]chan Signal{} + ext.subscriptions = []SubscriptionInfo{} + + return nil +} + func (ext *GQLExt) AddSubscription(id uuid.UUID) (chan interface{}, error) { ext.subscriptions_lock.Lock() defer ext.subscriptions_lock.Unlock() @@ -1265,7 +1272,7 @@ func (ext *GQLExt) Process(ctx *Context, node *Node, source NodeID, signal Signa if response_chan != nil { select { case response_chan <- sig: - ctx.Log.Logf("gql", "Forwarded error to resolver, %+v", sig) + ctx.Log.Logf("gql", "Forwarded error to resolver, %+v", sig.Error) default: ctx.Log.Logf("gql", "Resolver channel overflow %+v", sig) } @@ -1309,14 +1316,6 @@ func (ext *GQLExt) Process(ctx *Context, node *Node, source NodeID, signal Signa return nil } -func (ext *GQLExt) Type() ExtType { - return GQLExtType -} - -func (ext *GQLExt) MarshalBinary() ([]byte, error) { - return json.Marshal(ext) -} - var ecdsa_curves = map[uint8]elliptic.Curve{ 0: elliptic.P256(), } @@ -1333,11 +1332,6 @@ var ecdh_curve_ids = map[ecdh.Curve]uint8{ ecdh.P256(): 0, } -func (ext *GQLExt) Deserialize(ctx *Context, data []byte) error { - ext.resolver_response = map[uuid.UUID]chan Signal{} - return json.Unmarshal(data, &ext) -} - func NewGQLExt(ctx *Context, listen string, tls_cert []byte, tls_key []byte) (*GQLExt, error) { if tls_cert == nil || tls_key == nil { ssl_key, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) @@ -1378,6 +1372,7 @@ func NewGQLExt(ctx *Context, listen string, tls_cert []byte, tls_key []byte) (*G tls_cert = ssl_cert_pem tls_key = ssl_key_pem } + return &GQLExt{ Listen: listen, resolver_response: map[uuid.UUID]chan Signal{}, diff --git a/gql_node.go b/gql_node.go index 8591206..f75de80 100644 --- a/gql_node.go +++ b/gql_node.go @@ -67,6 +67,7 @@ func ResolveNodes(ctx *ResolveContext, p graphql.ResolveParams, ids []NodeID) ([ if err != nil { return nil, err } + ctx.Context.Log.Logf("gql", "ACL Fields from request: %+v", ext_fields) responses := make([]NodeResult, len(ids)) @@ -107,6 +108,7 @@ func ResolveNodes(ctx *ResolveContext, p graphql.ResolveParams, ids []NodeID) ([ } else { read_signal = NewReadSignal(ext_fields) } + ctx.Context.Log.Logf("gql", "READ_SIGNAL for %s - %+v", id, read_signal) // Create a read signal, send it to the specified node, and add the wait to the response map if the send returns no error msgs := Messages{} msgs = msgs.Add(ctx.Context, ctx.Server.ID, ctx.Key, read_signal, id) @@ -121,8 +123,12 @@ func ResolveNodes(ctx *ResolveContext, p graphql.ResolveParams, ids []NodeID) ([ ctx.Ext.FreeResponseChannel(read_signal.ID) return nil, err } + + ctx.Context.Log.Logf("gql", "SENT_READ_SIGNAL to %+s", id) } + ctx.Context.Log.Logf("gql", "Resolved cached nodes: %+v", responses) + for sig_id, response_chan := range(resp_channels) { // Wait for the response, returning an error on timeout response, err := WaitForSignal(response_chan, time.Millisecond*100, func(sig *ReadResultSignal)bool{ diff --git a/node.go b/node.go index a4b1bea..ebab3a6 100644 --- a/node.go +++ b/node.go @@ -300,7 +300,7 @@ func nodeLoop(ctx *Context, node *Node) error { if princ_id != node.ID { pends, resp := node.Allows(ctx, princ_id, msg.Signal.Permission()) if resp == Deny { - ctx.Log.Logf("policy", "SIGNAL_POLICY_DENY: %s->%s - %s", princ_id, node.ID, msg.Signal.Permission()) + ctx.Log.Logf("policy", "SIGNAL_POLICY_DENY: %s->%s - %+v(%+s)", princ_id, node.ID, reflect.TypeOf(msg.Signal), msg.Signal) ctx.Log.Logf("policy", "SIGNAL_POLICY_SOURCE: %s", msg.Source) msgs := Messages{} msgs = msgs.Add(ctx, node.ID, node.Key, NewErrorSignal(msg.Signal.Header().ID, "acl denied"), msg.Source) diff --git a/signal.go b/signal.go index cd4570d..04b35ad 100644 --- a/signal.go +++ b/signal.go @@ -24,7 +24,12 @@ func (header SignalHeader) Header() SignalHeader { return header } +func (header SignalHeader) String() string { + return fmt.Sprintf("Signal(%d, %s->%s)", header.Direction, header.ID, header.ReqID) +} + type Signal interface { + fmt.Stringer Header() SignalHeader Permission() Tree } @@ -190,7 +195,7 @@ func NewStatusSignal(source NodeID, status string) *StatusSignal { type LinkSignal struct { SignalHeader - NodeID + NodeID NodeID Action string } @@ -206,6 +211,7 @@ func (signal LinkSignal) Permission() Tree { }, } } + func NewLinkSignal(action string, id NodeID) Signal { return &LinkSignal{ NewSignalHeader(Direct),