Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Commit

Permalink
Merge pull request #609 from TheThingsNetwork/develop
Browse files Browse the repository at this point in the history
v2.7.1
  • Loading branch information
johanstokking authored May 22, 2017
2 parents d4d85a9 + f51487c commit 247faf6
Show file tree
Hide file tree
Showing 41 changed files with 601 additions and 871 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dev-deps: deps

PROTO_FILES = $(shell find api -name "*.proto" -and -not -name ".git")
COMPILED_PROTO_FILES = $(patsubst api%.proto, api%.pb.go, $(PROTO_FILES))
PROTOC_IMPORTS= -I/usr/local/include -I$(GO_PATH)/src -I$(PARENT_DIRECTORY) \
PROTOC_IMPORTS= -I/usr/local/include -I$(GO_PATH)/src -I$(PWD)/vendor -I$(PARENT_DIRECTORY) \
-I$(GO_PATH)/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis
PROTOC = protoc $(PROTOC_IMPORTS) \
--gogottn_out=plugins=grpc:$(GO_SRC) \
Expand Down
4 changes: 2 additions & 2 deletions api/API_AUTHENTICATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ You can authenticate to the gRPC endpoint by supplying a `token` field in the Me
md := metadata.Pairs(
"token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhcHBzIjp7InRlc3QiOlsic2V0dGluZ3MiXX19.VGhpcyBpcyB0aGUgc2lnbmF0dXJl",
)
ctx := metadata.NewContext(context.Background(), md)
ctx := metadata.NewOutgoingContext(context.Background(), md)
```

### HTTP
Expand All @@ -46,7 +46,7 @@ You can authenticate to the gRPC endpoint by supplying a `key` field in the Meta
md := metadata.Pairs(
"key", "ttn-account-v2.n4BAoKOGuK2hj7MXg_OVtpLO0BTJI8lLzt66UsvTlUvZPsi6FADOptnmSH3e3PuQzbLLEUhXxYhkxr34xyUqBQ",
)
ctx := metadata.NewContext(context.Background(), md)
ctx := metadata.NewOutgoingContext(context.Background(), md)
```

### HTTP
Expand Down
49 changes: 0 additions & 49 deletions api/auth/auth.go

This file was deleted.

9 changes: 5 additions & 4 deletions api/broker/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"sync"

"github.com/TheThingsNetwork/go-utils/grpc/restartstream"
"github.com/TheThingsNetwork/go-utils/grpc/ttnctx"
"github.com/TheThingsNetwork/go-utils/log"
"github.com/TheThingsNetwork/ttn/api"
"github.com/TheThingsNetwork/ttn/utils"
Expand Down Expand Up @@ -157,8 +158,8 @@ func (s *routerStreams) Close() {
func (c *Client) NewRouterStreams(id string, token string) RouterStream {
log := c.log
ctx, cancel := context.WithCancel(c.ctx)
ctx = api.ContextWithID(ctx, id)
ctx = api.ContextWithToken(ctx, token)
ctx = ttnctx.OutgoingContextWithID(ctx, id)
ctx = ttnctx.OutgoingContextWithToken(ctx, token)
s := &routerStreams{
log: log,
ctx: ctx,
Expand Down Expand Up @@ -300,8 +301,8 @@ func (s *handlerStreams) Close() {
func (c *Client) NewHandlerStreams(id string, token string) HandlerStream {
log := c.log
ctx, cancel := context.WithCancel(c.ctx)
ctx = api.ContextWithID(ctx, id)
ctx = api.ContextWithToken(ctx, token)
ctx = ttnctx.OutgoingContextWithID(ctx, id)
ctx = ttnctx.OutgoingContextWithToken(ctx, token)
s := &handlerStreams{
log: log,
ctx: ctx,
Expand Down
10 changes: 5 additions & 5 deletions api/broker/reference_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"sync"
"sync/atomic"

"github.com/TheThingsNetwork/go-utils/grpc/ttnctx"
"github.com/TheThingsNetwork/go-utils/log"
"github.com/TheThingsNetwork/ttn/api"
"github.com/TheThingsNetwork/ttn/utils/errors"
"github.com/golang/protobuf/ptypes/empty"
"golang.org/x/net/context"
Expand Down Expand Up @@ -125,11 +125,11 @@ func (s *ReferenceBrokerServer) removeUplinkSubscriber(handlerID string) {
}

func (s *ReferenceBrokerServer) getAndAuthRouter(ctx context.Context) (string, error) {
id, err := api.IDFromContext(ctx)
id, err := ttnctx.IDFromIncomingContext(ctx)
if err != nil {
return "", err
}
token, err := api.TokenFromContext(ctx)
token, err := ttnctx.TokenFromIncomingContext(ctx)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -199,11 +199,11 @@ func (s *ReferenceBrokerServer) Associate(stream Broker_AssociateServer) error {
}

func (s *ReferenceBrokerServer) getAndAuthHandler(ctx context.Context) (string, error) {
id, err := api.IDFromContext(ctx)
id, err := ttnctx.IDFromIncomingContext(ctx)
if err != nil {
return "", err
}
token, err := api.TokenFromContext(ctx)
token, err := ttnctx.TokenFromIncomingContext(ctx)
if err != nil {
return "", err
}
Expand Down
8 changes: 4 additions & 4 deletions api/broker/server_streams.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ package broker
import (
"io"

"github.com/TheThingsNetwork/go-utils/grpc/ttnctx"
"github.com/TheThingsNetwork/go-utils/log"
"github.com/TheThingsNetwork/ttn/api"
"github.com/golang/protobuf/ptypes/empty"
"google.golang.org/grpc/metadata"
)
Expand All @@ -34,7 +34,7 @@ func (s *BrokerStreamServer) SetLogger(logger log.Interface) {

// Associate handles uplink streams from and downlink streams to the router
func (s *BrokerStreamServer) Associate(stream Broker_AssociateServer) (err error) {
md := api.MetadataFromContext(stream.Context())
md := ttnctx.MetadataFromIncomingContext(stream.Context())
upChan, downChan, downCancel, err := s.RouterAssociateChanFunc(md)
if err != nil {
return err
Expand Down Expand Up @@ -98,7 +98,7 @@ func (s *BrokerStreamServer) Associate(stream Broker_AssociateServer) (err error

// Subscribe handles uplink streams towards the handler
func (s *BrokerStreamServer) Subscribe(req *SubscribeRequest, stream Broker_SubscribeServer) (err error) {
md := api.MetadataFromContext(stream.Context())
md := ttnctx.MetadataFromIncomingContext(stream.Context())
ch, cancel, err := s.HandlerSubscribeChanFunc(md)
if err != nil {
return err
Expand All @@ -118,7 +118,7 @@ func (s *BrokerStreamServer) Subscribe(req *SubscribeRequest, stream Broker_Subs

// Publish handles downlink streams from the handler
func (s *BrokerStreamServer) Publish(stream Broker_PublishServer) error {
md := api.MetadataFromContext(stream.Context())
md := ttnctx.MetadataFromIncomingContext(stream.Context())
ch, err := s.HandlerPublishChanFunc(md)
if err != nil {
return err
Expand Down
166 changes: 0 additions & 166 deletions api/context.go

This file was deleted.

Loading

0 comments on commit 247faf6

Please sign in to comment.