service

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2020 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAuthInterceptor

func NewAuthInterceptor() kitNetCoap.Interceptor

func SendResourceContentToObserver

func SendResourceContentToObserver(client *Client, resourceChanged *pb.Event_ResourceChanged, observe uint32, token message.Token)

func URIToDeviceIDHref

func URIToDeviceIDHref(msg *mux.Message) (deviceID, href string, err error)

URIToDeviceIDHref convert uri to deviceID and href. Expected input "/oic/route/{deviceID}/{Href}".

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client a setup of connection

func ToClient

func ToClient(v interface{}, ok bool) (*Client, bool)

func (*Client) Close

func (client *Client) Close() error

Close closes coap connection

func (*Client) Context

func (client *Client) Context() context.Context

func (*Client) OnClose

func (client *Client) OnClose()

OnClose action when coap connection was closed.

func (*Client) PublishCloudDeviceStatus

func (client *Client) PublishCloudDeviceStatus(ctx context.Context, deviceID string, authCtx pbCQRS.AuthorizationContext) error

func (*Client) UpdateCloudDeviceStatus

func (client *Client) UpdateCloudDeviceStatus(ctx context.Context, deviceID string, authCtx pbCQRS.AuthorizationContext, online bool) error

type CoapRefreshTokenReq

type CoapRefreshTokenReq struct {
	DeviceID     string `json:"di"`
	UserID       string `json:"uid"`
	RefreshToken string `json:"refreshtoken"`
}

type CoapRefreshTokenResp

type CoapRefreshTokenResp struct {
	ExpiresIn    int64  `json:"expiresin"`
	AccessToken  string `json:"accesstoken"`
	RefreshToken string `json:"refreshtoken"`
}

type CoapSignInReq

type CoapSignInReq struct {
	DeviceID    string `json:"di"`
	UserID      string `json:"uid"`
	AccessToken string `json:"accesstoken"`
	Login       bool   `json:"login"`
}

type CoapSignInResp

type CoapSignInResp struct {
	ExpiresIn int64 `json:"expiresin"`
}

type CoapSignUpRequest

type CoapSignUpRequest struct {
	DeviceID                string `json:"di"`
	AuthorizationCode       string `json:"accesstoken"`
	AuthorizationProvider   string `json:"authprovider"`
	AuthorizationCodeLegacy string `json:"authcode"`
}

type CoapSignUpResponse

type CoapSignUpResponse struct {
	AccessToken  string `json:"accesstoken"`
	UserID       string `json:"uid"`
	RefreshToken string `json:"refreshtoken"`
	ExpiresIn    int64  `json:"expiresin"`
	RedirectURI  string `json:"redirecturi"`
}

type Config

type Config struct {
	Addr                            string         `envconfig:"ADDRESS" default:"0.0.0.0:5684"`
	ExternalPort                    uint16         `envconfig:"EXTERNAL_PORT" default:"5684"`
	FQDN                            string         `envconfig:"FQDN" default:"coapgw.ocf.cloud"`
	AuthServerAddr                  string         `envconfig:"AUTH_SERVER_ADDRESS" default:"127.0.0.1:9100"`
	ResourceAggregateAddr           string         `envconfig:"RESOURCE_AGGREGATE_ADDRESS"  default:"127.0.0.1:9100"`
	ResourceDirectoryAddr           string         `envconfig:"RESOURCE_DIRECTORY_ADDRESS"  default:"127.0.0.1:9100"`
	RequestTimeout                  time.Duration  `envconfig:"REQUEST_TIMEOUT"  default:"10s"`
	KeepaliveEnable                 bool           `envconfig:"KEEPALIVE_ENABLE" default:"true"`
	KeepaliveTimeoutConnection      time.Duration  `envconfig:"KEEPALIVE_TIMEOUT_CONNECTION" default:"20s"`
	DisableBlockWiseTransfer        bool           `envconfig:"DISABLE_BLOCKWISE_TRANSFER" default:"false"`
	BlockWiseTransferSZX            string         `envconfig:"BLOCKWISE_TRANSFER_SZX" default:"1024"`
	DisableTCPSignalMessageCSM      bool           `envconfig:"DISABLE_TCP_SIGNAL_MESSAGE_CSM"  default:"false"`
	DisablePeerTCPSignalMessageCSMs bool           `envconfig:"DISABLE_PEER_TCP_SIGNAL_MESSAGE_CSMS"  default:"false"`
	SendErrorTextInResponse         bool           `envconfig:"ERROR_IN_RESPONSE"  default:"true"`
	OAuth                           manager.Config `envconfig:"OAUTH"`
	ReconnectInterval               time.Duration  `envconfig:"RECONNECT_TIMEOUT" default:"10s"`
	HeartBeat                       time.Duration  `envconfig:"HEARTBEAT" default:"4s"`
	MaxMessageSize                  int            `envconfig:"MAX_MESSAGE_SIZE" default:"262144"`
}

Config for application.

type DialCertManager

type DialCertManager = interface {
	GetClientTLSConfig() *tls.Config
}

type ListenCertManager

type ListenCertManager = interface {
	GetServerTLSConfig() *tls.Config
}

type Server

type Server struct {
	FQDN                            string // fully qualified domain name of GW
	ExternalPort                    uint16 // used to construct oic/res response
	Addr                            string // Address to listen on, ":COAP" if empty.
	IsTLSListener                   bool
	Keepalive                       *keepalive.KeepAlive
	DisableTCPSignalMessageCSM      bool
	DisablePeerTCPSignalMessageCSMs bool
	SendErrorTextInResponse         bool
	RequestTimeout                  time.Duration
	BlockWiseTransfer               bool
	BlockWiseTransferSZX            blockwise.SZX
	ReconnectInterval               time.Duration
	HeartBeat                       time.Duration
	MaxMessageSize                  int
	// contains filtered or unexported fields
}

Server a configuration of coapgateway

func New

func New(config Config, dialCertManager DialCertManager, listenCertManager ListenCertManager) *Server

New creates server.

func (*Server) Serve

func (server *Server) Serve() error

Serve starts a coapgateway on the configured address in *Server.

func (*Server) ServiceRequestContext

func (server *Server) ServiceRequestContext(userID string) (context.Context, error)

func (*Server) Shutdown

func (server *Server) Shutdown() error

Shutdown turn off server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL