service

package
v0.0.0-...-30e1d48 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2019 License: MIT Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClientContainerByDeviceId

func NewClientContainerByDeviceId() *clientContainerByDeviceId

func NewObserveResourceContainer

func NewObserveResourceContainer() *observeResourceContainer

func NewUpdateNotificationContainer

func NewUpdateNotificationContainer() *updateNotificationContainer

func SendResourceContentToObserver

func SendResourceContentToObserver(s gocoap.ResponseWriter, client *Client, contentCtx contentCtx, observe uint32, path string)

func URIToDeviceIdHref

func URIToDeviceIdHref(msg gocoap.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 (*Client) Close

func (client *Client) Close() error

Close closes coap connection

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, authContext pbCQRS.AuthorizationContext) error

func (*Client) UpdateCloudDeviceStatus

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

type ClientContainer

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

ClientContainer client <-> server connections

func (*ClientContainer) Add

func (c *ClientContainer) Add(remoteAddr string, client *Client)

func (*ClientContainer) Find

func (c *ClientContainer) Find(remoteAddr string) *Client

func (*ClientContainer) Pop

func (c *ClientContainer) Pop(remoteAddr string) (*Client, bool)

type CoapClientCertificateVerifier

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

func NewCoapClientCertificateVerifier

func NewCoapClientCertificateVerifier(cacheTimeout time.Duration) *CoapClientCertificateVerifier

func (*CoapClientCertificateVerifier) PopCachedDeviceId

func (c *CoapClientCertificateVerifier) PopCachedDeviceId(remoteAddr string) (string, bool)

func (*CoapClientCertificateVerifier) Verify

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 {
	KeepaliveTime            time.Duration `envconfig:"KEEPALIVE_TIME" default:"20s"`
	KeepaliveInterval        time.Duration `envconfig:"KEEPALIVE_INTERVAL" default:"5s"`
	KeepaliveRetry           int           `envconfig:"KEEPALIVE_RETRY" default:"3"`
	FQDN                     string        `envconfig:"FQDN" default:"gw1.ocf.cloud"`
	ExternalPort             uint16        `envconfig:"EXTERNAL_PORT" default:"5684"`
	Addr                     string        `envconfig:"ADDRESS" default:"0.0.0.0:5684"`
	Net                      string        `envconfig:"NETWORK" default:"tcp"`
	AuthHost                 string        `envconfig:"AUTH_HOST"  default:"127.0.0.1:7000"`
	ResourceAggregateHost    string        `envconfig:"RESOURCE_AGGREGATE_HOST"  default:"127.0.0.1:9083"`
	ResourceDirectoryHost    string        `envconfig:"RESOURCE_DIRECTORY_HOST"  default:"127.0.0.1:9082"`
	QueriesTreshold          int           `envconfig:"QUERIES_TRESHOLD" default:"256"`
	TimeoutForRequests       time.Duration `envconfig:"TIMEOUT_FOR_REQUESTS"  default:"10s"`
	DisableTCPSignalMessages bool          `envconfig:"DISABLE_TCP_SIGNAL_MESSAGES"  default:"false"`
	SendErrorTextInResponse  bool          `envconfig:"SEND_ERROR_TEXT_IN_RESPONSE"  default:"true"`

	TLSConfig security.TLSConfig
}

config for application

type Keepalive

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

Keepalive setup of keepalive

func NewKeepalive

func NewKeepalive(server *Server, client *gocoap.ClientConn) *Keepalive

NewKeepalive create new Keepalive instance and start check of connection

func (*Keepalive) Done

func (k *Keepalive) Done()

Done wake and end goroutine

func (*Keepalive) Terminate

func (k *Keepalive) Terminate()

Terminate terminate connection by keepalive

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.
	Net          string // if "tcp" or "tcp-tls" (COAP over TLS) it will invoke a TCP listener, otherwise an UDP one

	DisableTCPSignalMessages bool
	SendErrorTextInResponse  bool
	TimeoutForRequests       time.Duration
	// contains filtered or unexported fields
}

Server a configuration of coapgateway

func New

func New(config Config, store eventstore.EventStore, subscriber eventbus.Subscriber, pool *ants.Pool) *Server

NewServer setup coap gateway

func (*Server) ListenAndServe

func (server *Server) ListenAndServe() error

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

func (*Server) Serve

func (server *Server) Serve(ln gocoap.Listener) error

Serve starts a coapgateway on the configured address in *Server and handle 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