http

package
v1.0.15 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: Apache-2.0, BSD-3-Clause Imports: 33 Imported by: 13

Documentation

Overview

*

  • Copyright 2022 Comcast Cable Communications Management, LLC *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License. *
  • SPDX-License-Identifier: Apache-2.0

*

  • Copyright 2022 Comcast Cable Communications Management, LLC *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License. *
  • SPDX-License-Identifier: Apache-2.0

*

  • Copyright 2022 Comcast Cable Communications Management, LLC *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License. *
  • SPDX-License-Identifier: Apache-2.0

*

  • Copyright 2022 Comcast Cable Communications Management, LLC *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License. *
  • SPDX-License-Identifier: Apache-2.0

*

  • Copyright 2022 Comcast Cable Communications Management, LLC *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License. *
  • SPDX-License-Identifier: Apache-2.0

*

  • Copyright 2022 Comcast Cable Communications Management, LLC *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License. *
  • SPDX-License-Identifier: Apache-2.0

*

  • Copyright 2022 Comcast Cable Communications Management, LLC *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License. *
  • SPDX-License-Identifier: Apache-2.0

*

  • Copyright 2022 Comcast Cable Communications Management, LLC *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License. *
  • SPDX-License-Identifier: Apache-2.0

*

  • Copyright 2022 Comcast Cable Communications Management, LLC *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License. *
  • SPDX-License-Identifier: Apache-2.0

*

  • Copyright 2022 Comcast Cable Communications Management, LLC *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License. *
  • SPDX-License-Identifier: Apache-2.0

*

  • Copyright 2022 Comcast Cable Communications Management, LLC *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License. *
  • SPDX-License-Identifier: Apache-2.0

*

  • Copyright 2022 Comcast Cable Communications Management, LLC *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License. *
  • SPDX-License-Identifier: Apache-2.0

*

  • Copyright 2022 Comcast Cable Communications Management, LLC *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License. *
  • SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	Accept                    = "Accept"
	ContentType               = "Content-Type"
	ApplicationProtobufHeader = "application/x-protobuf"
)
View Source
const (
	OkResponseTemplate = `{"status":200,"message":"OK","data":%v}`

	// TODO, this is should be retired
	TR181ResponseTemplate = `{"parameters":%v,"version":"%v"}`
)
View Source
const (
	HTTP_CLIENT_PROTOCOL           = "http"
	HTTPS_CLIENT_PROTOCOL          = "https"
	MTLS_CLIENT_PROTOCOL           = "mtls"
	MTLS_OPTIONAL_CLIENT_PROTOCOL  = "mtls-optional"
	MTLS_RECOVERY_CLIENT_PROTOCOL  = "mtls-recovery"
	SECURITY_TOKEN_KEY             = "xds"
	SECURITY_TOKEN_CLIENT_PROTOCOL = "clientProtocol"
	SECURITY_TOKEN_ESTB_MAC        = "estbMac"
	SECURITY_TOKEN_ESTB_IP         = "estbIP"
	SECURITY_TOKEN_MODEL           = "model"
	SECURITY_TOKEN_PARTNER         = "partnerId"
	SECURITY_TOKEN_FW_FILENAME     = "firmwareFilename"
	SECURITY_TOKEN_FW_VERSION      = "fwVersion"
	SECURITY_TOKEN_FW_DOWNLOAD_TS  = "fwDownloadTs"
	SECURITY_TOKEN_LOG_UPLOAD_TS   = "logUploadTs"
	URL_PROTOCOL_PREFIX            = "http://"
	FQDN_CHECK                     = "://"
)
View Source
const (
	LevelWarn = iota
	LevelInfo
	LevelDebug
	MetricsEnabledDefault = true
)
View Source
const (
	Default404ResponseTemplate = `` /* 284-byte string literal not displayed */

)

Variables

View Source
var SecurityTokenCustomBase64Encoding = base64.NewEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_").WithPadding(base64.NoPadding)

Define a custom Base64 encoding with a custom alphabet

Functions

func AppName

func AppName() string

AppName is just a convenience func that returns the AppName, used in metrics

func CanSkipSecurityTokenForClientProtocol

func CanSkipSecurityTokenForClientProtocol(deviceInfo map[string]string) bool

func Error

func Error(w http.ResponseWriter, status int, err error)

func GetTokenExpiryTime

func GetTokenExpiryTime() string

GetTokenExpiryTime - expiration time of sat token

func IncreaseAccountIdChangedCounter

func IncreaseAccountIdChangedCounter(partner, model string)

func IncreaseAccountIdChangedIn200Counter

func IncreaseAccountIdChangedIn200Counter(partner, model string)

func IncreaseAccountServiceEmptyResponseCounter

func IncreaseAccountServiceEmptyResponseCounter(model string)

func IncreaseCtxHashMismatchCounter

func IncreaseCtxHashMismatchCounter(partner, model string)

func IncreaseExperienceChangedCounter

func IncreaseExperienceChangedCounter(partner, model string)

func IncreaseExperienceChangedIn200Counter

func IncreaseExperienceChangedIn200Counter(partner, model string)

func IncreaseFirmwareVersionMismatchCounter

func IncreaseFirmwareVersionMismatchCounter(partner, model string)

func IncreaseFwVersionChangedCounter

func IncreaseFwVersionChangedCounter(partner, model string)

func IncreaseFwVersionChangedIn200Counter

func IncreaseFwVersionChangedIn200Counter(partner, model string)

func IncreaseIpNotInSameNetworkCounter

func IncreaseIpNotInSameNetworkCounter(partner, model string)

func IncreaseIpNotInSameNetworkIn200Counter

func IncreaseIpNotInSameNetworkIn200Counter(partner, model string)

func IncreaseModelChangedCounter

func IncreaseModelChangedCounter(partner, model string)

func IncreaseModelChangedIn200Counter

func IncreaseModelChangedIn200Counter(partner, model string)

func IncreaseNoPrecookDataCounter

func IncreaseNoPrecookDataCounter(partner, model string)

func IncreaseOfferedFwVersionMatchCounter

func IncreaseOfferedFwVersionMatchCounter(partner, model string)

func IncreasePartnerChangedCounter

func IncreasePartnerChangedCounter(partner, model string)

func IncreasePartnerChangedIn200Counter

func IncreasePartnerChangedIn200Counter(partner, model string)

func IncreasePrecookExcludeMacListCounter

func IncreasePrecookExcludeMacListCounter(partner, model string)

func IncreaseReturn200FromPrecookCounter

func IncreaseReturn200FromPrecookCounter(partner, model string)

func IncreaseReturn200RulesEngineCounter

func IncreaseReturn200RulesEngineCounter(partner, model string)

func IncreaseReturn304FromPrecookCounter

func IncreaseReturn304FromPrecookCounter(partner, model string)

func IncreaseReturn304RulesEngineCounter

func IncreaseReturn304RulesEngineCounter(partner, model string)

func IncreaseReturnPostProcessFromPrecookCounter

func IncreaseReturnPostProcessFromPrecookCounter(partner, model string)

func IncreaseReturnPostProcessOnTheFlyCounter

func IncreaseReturnPostProcessOnTheFlyCounter(partner, model string)

func IncreaseTitanEmptyResponseCounter

func IncreaseTitanEmptyResponseCounter(model string)

func InitConnectionTypeMap

func InitConnectionTypeMap() map[string]string

func InitSatTokenManager

func InitSatTokenManager(ws *XconfServer, args ...bool)

InitSatTokenManager - init sat token manager

func LogError

func LogError(w http.ResponseWriter, err error)

func NewTlsConfig

func NewTlsConfig(conf *configuration.Config) (*tls.Config, error)

func SetLocalSatToken

func SetLocalSatToken(fields log.Fields) error

SetLocalSatToken - setting up local sat token from SatService

func UpdateFirmwarePenetrationCounts

func UpdateFirmwarePenetrationCounts(partner string, model string, version string)

UpdateFirmwarePenetrationCounts updates the counts for firmware penetration dashboard

func UpdateLogCounter

func UpdateLogCounter(logType string)

updateLogCounter updates count for new logs

func WriteContentTypeAndResponse

func WriteContentTypeAndResponse(w http.ResponseWriter, r *http.Request, rbytes []byte, version string, contentType string)

this is used to return default tr-181 payload while the cpe is not in the db

func WriteErrorResponse

func WriteErrorResponse(w http.ResponseWriter, status int, err error)

helper function to write a failure json response into ResponseWriter

func WriteOkResponse

func WriteOkResponse(w http.ResponseWriter, r *http.Request, data interface{})

helper function to wirte a json response into ResponseWriter

func WriteOkResponseByTemplate

func WriteOkResponseByTemplate(w http.ResponseWriter, r *http.Request, dataStr string)

func WriteResponseBytes

func WriteResponseBytes(w http.ResponseWriter, rbytes []byte, statusCode int, vargs ...string)

func WriteTR181Response

func WriteTR181Response(w http.ResponseWriter, r *http.Request, params string, version string)

func WriteXconfResponse

func WriteXconfResponse(w http.ResponseWriter, status int, data []byte)

func WriteXconfResponseAsText

func WriteXconfResponseAsText(w http.ResponseWriter, status int, data []byte)

func WriteXconfResponseHtmlWithHeaders

func WriteXconfResponseHtmlWithHeaders(w http.ResponseWriter, headers map[string]string, status int, data []byte)

func WriteXconfResponseWithHeaders

func WriteXconfResponseWithHeaders(w http.ResponseWriter, headers map[string]string, status int, data []byte)

Types

type Account

type Account struct {
	Id          string      `json:"id"`
	AccountData AccountData `json:"data"`
}

type AccountAttributes

type AccountAttributes struct {
	TimeZone    string `json:"timeZone"`
	CountryCode string `json:"countryCode"`
}

type AccountData

type AccountData struct {
	AccountAttributes AccountAttributes `json:"attributes"`
}

type AccountServiceConnector

type AccountServiceConnector interface {
	AccountServiceHost() string
	SetAccountServiceHost(host string)
	GetAccountData(serviceAccountId string, token string, fields log.Fields) (Account, error)
	GetDevices(macKey string, macValue string, token string, fields log.Fields) (AccountServiceDevices, error)
}

func NewAccountServiceConnector

func NewAccountServiceConnector(conf *configuration.Config, tlsConfig *tls.Config, externalAccountService AccountServiceConnector) AccountServiceConnector

type AccountServiceDevices

type AccountServiceDevices struct {
	Id         string     `json:"id"`
	DeviceData DeviceData `json:"data"`
}

func (*AccountServiceDevices) IsEmpty

func (d *AccountServiceDevices) IsEmpty() bool

type AppMetrics

type AppMetrics struct {
	AccountServiceEmptyResponseCounter *prometheus.CounterVec
	// contains filtered or unexported fields
}

AppMetrics just collects all the needed metrics

func NewMetrics

func NewMetrics() *AppMetrics

NewMetrics creates all the metrics needed for xconfwebconfig

func (*AppMetrics) MetricsHandler

func (m *AppMetrics) MetricsHandler(next http.Handler) http.Handler

MetricsHandler returns the prometheus handler

func (*AppMetrics) UpdateAPIMetrics

func (metrics *AppMetrics) UpdateAPIMetrics(r *http.Request, statusCode int, startTime time.Time)

UpdateAPIMetrics updates api_req_total, number of API calls

func (*AppMetrics) UpdateExternalAPIMetrics

func (metrics *AppMetrics) UpdateExternalAPIMetrics(service string, method string, statusCode int, startTime time.Time)

UpdateExternalAPIMetrics updates duration and counts for external API calls to AccountService, sat etc.

type AppMetricsConfig

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

func (*AppMetricsConfig) GetAllowedModelLabelsSet

func (m *AppMetricsConfig) GetAllowedModelLabelsSet() util.Set

func (*AppMetricsConfig) GetConnectionTypeMap

func (m *AppMetricsConfig) GetConnectionTypeMap() map[string]string

type DefaultAccountService

type DefaultAccountService struct {
	*HttpClient
	// contains filtered or unexported fields
}

func (*DefaultAccountService) AccountServiceHost

func (c *DefaultAccountService) AccountServiceHost() string

func (*DefaultAccountService) GetAccountData

func (c *DefaultAccountService) GetAccountData(serviceAccountId string, token string, fields log.Fields) (Account, error)

func (*DefaultAccountService) GetDevices

func (c *DefaultAccountService) GetDevices(macKey string, macValue string, token string, fields log.Fields) (AccountServiceDevices, error)

func (*DefaultAccountService) SetAccountServiceHost

func (c *DefaultAccountService) SetAccountServiceHost(host string)

type DefaultDeviceService

type DefaultDeviceService struct {
	*HttpClient
	// contains filtered or unexported fields
}

func (*DefaultDeviceService) DeviceServiceHost

func (c *DefaultDeviceService) DeviceServiceHost() string

func (*DefaultDeviceService) GetMeshPodAccountBySerialNum

func (c *DefaultDeviceService) GetMeshPodAccountBySerialNum(serialNum string, fields log.Fields) (DeviceServiceObject, error)

func (*DefaultDeviceService) SetDeviceServiceHost

func (c *DefaultDeviceService) SetDeviceServiceHost(host string)

type DefaultGroupService

type DefaultGroupService struct {
	*HttpClient
	// contains filtered or unexported fields
}

func (*DefaultGroupService) CreateListFromGroupServiceProto

func (c *DefaultGroupService) CreateListFromGroupServiceProto(cpeGroup *conversion.CpeGroup) []string

func (*DefaultGroupService) GetCpeGroups

func (c *DefaultGroupService) GetCpeGroups(cpeMac string, fields log.Fields) ([]string, error)

func (*DefaultGroupService) GetFeatureTagsHashedItems

func (c *DefaultGroupService) GetFeatureTagsHashedItems(name string, fields log.Fields) (map[string]string, error)

func (*DefaultGroupService) GetRfcPrecookDetails

func (c *DefaultGroupService) GetRfcPrecookDetails(cpeMac string, fields log.Fields) (*conversion.XconfDevice, error)

func (*DefaultGroupService) GetSecurityTokenInfo

func (c *DefaultGroupService) GetSecurityTokenInfo(securityIdentifier string, fields log.Fields) (map[string]string, error)

func (*DefaultGroupService) GroupPrefix

func (c *DefaultGroupService) GroupPrefix() string

func (*DefaultGroupService) GroupServiceHost

func (c *DefaultGroupService) GroupServiceHost() string

func (*DefaultGroupService) SetGroupPrefix

func (c *DefaultGroupService) SetGroupPrefix(prefix string)

func (*DefaultGroupService) SetGroupServiceHost

func (c *DefaultGroupService) SetGroupServiceHost(host string)

type DefaultGroupServiceSync

type DefaultGroupServiceSync struct {
	*HttpClient
	// contains filtered or unexported fields
}

func (*DefaultGroupServiceSync) AddSecurityTokenInfo

func (c *DefaultGroupServiceSync) AddSecurityTokenInfo(securityIdenfier string, deviceInfo map[string]string, fields log.Fields) error

func (*DefaultGroupServiceSync) GroupServiceSyncHost

func (c *DefaultGroupServiceSync) GroupServiceSyncHost() string

func (*DefaultGroupServiceSync) SetGroupServiceSyncHost

func (c *DefaultGroupServiceSync) SetGroupServiceSyncHost(host string)

type DefaultSatService

type DefaultSatService struct {
	*HttpClient
	// contains filtered or unexported fields
}

func (*DefaultSatService) ConsumerHost

func (c *DefaultSatService) ConsumerHost() string

func (*DefaultSatService) GetSatTokenFromSatService

func (c *DefaultSatService) GetSatTokenFromSatService(fields log.Fields, vargs ...string) (*SatServiceResponse, error)

func (*DefaultSatService) SatServiceHost

func (c *DefaultSatService) SatServiceHost() string

func (*DefaultSatService) SatServiceName

func (c *DefaultSatService) SatServiceName() string

func (*DefaultSatService) SetSatServiceHost

func (c *DefaultSatService) SetSatServiceHost(host string)

func (*DefaultSatService) SetSatServiceName

func (c *DefaultSatService) SetSatServiceName(name string)

type DefaultTaggingService

type DefaultTaggingService struct {
	*HttpClient
	// contains filtered or unexported fields
}

func (*DefaultTaggingService) GetTagsForAccount

func (c *DefaultTaggingService) GetTagsForAccount(accountId string, token string, fields log.Fields) ([]string, error)

func (*DefaultTaggingService) GetTagsForContext

func (c *DefaultTaggingService) GetTagsForContext(contextMap map[string]string, token string, fields log.Fields) ([]string, error)

func (*DefaultTaggingService) GetTagsForMacAddress

func (c *DefaultTaggingService) GetTagsForMacAddress(macAddress string, token string, fields log.Fields) ([]string, error)

func (*DefaultTaggingService) GetTagsForMacAddressAndAccount

func (c *DefaultTaggingService) GetTagsForMacAddressAndAccount(macAddress string, accountId string, token string, fields log.Fields) ([]string, error)

func (*DefaultTaggingService) GetTagsForPartner

func (c *DefaultTaggingService) GetTagsForPartner(partnerId string, token string, fields log.Fields) ([]string, error)

func (*DefaultTaggingService) GetTagsForPartnerAndAccount

func (c *DefaultTaggingService) GetTagsForPartnerAndAccount(partnerId string, accountId string, token string, fields log.Fields) ([]string, error)

func (*DefaultTaggingService) GetTagsForPartnerAndMacAddress

func (c *DefaultTaggingService) GetTagsForPartnerAndMacAddress(partnerId string, macAddress string, token string, fields log.Fields) ([]string, error)

func (*DefaultTaggingService) GetTagsForPartnerAndMacAddressAndAccount

func (c *DefaultTaggingService) GetTagsForPartnerAndMacAddressAndAccount(partnerId string, macAddress string, accountId string, token string, fields log.Fields) ([]string, error)

func (*DefaultTaggingService) MakeGetTagsRequest

func (c *DefaultTaggingService) MakeGetTagsRequest(url string, token string, vargs ...log.Fields) ([]string, error)

func (*DefaultTaggingService) SetTaggingHost

func (c *DefaultTaggingService) SetTaggingHost(host string)

func (*DefaultTaggingService) TaggingHost

func (c *DefaultTaggingService) TaggingHost() string

type DeviceData

type DeviceData struct {
	Partner           string `json:"partner"`
	ServiceAccountUri string `json:"serviceAccountId"`
}

type DeviceServiceConnector

type DeviceServiceConnector interface {
	DeviceServiceHost() string
	SetDeviceServiceHost(host string)
	GetMeshPodAccountBySerialNum(serialNum string, fields log.Fields) (DeviceServiceObject, error)
}

func NewDeviceServiceConnector

func NewDeviceServiceConnector(conf *configuration.Config, tlsConfig *tls.Config, externalDeviceConnector DeviceServiceConnector) DeviceServiceConnector

type DeviceServiceData

type DeviceServiceData struct {
	AccountId string `json:"account_id"`
	CpeMac    string `json:"cpe_mac"`
	TimeZone  string `json:"timezone"`
	PartnerId string `json:"partner_id"`
}

type DeviceServiceObject

type DeviceServiceObject struct {
	Status            int                `json:"status"`
	Message           string             `json:"message"`
	DeviceServiceData *DeviceServiceData `json:"data"`
}

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
}

type GroupServiceConnector

type GroupServiceConnector interface {
	GroupServiceHost() string
	SetGroupServiceHost(host string)
	GroupPrefix() string
	SetGroupPrefix(prefix string)
	GetRfcPrecookDetails(cpeMac string, fields log.Fields) (*conversion.XconfDevice, error)
	GetCpeGroups(cpeMac string, fields log.Fields) ([]string, error)
	CreateListFromGroupServiceProto(cpeGroup *conversion.CpeGroup) []string
	GetFeatureTagsHashedItems(name string, fields log.Fields) (map[string]string, error)
	GetSecurityTokenInfo(securityIdentifier string, fields log.Fields) (map[string]string, error)
}

func NewGroupServiceConnector

func NewGroupServiceConnector(conf *configuration.Config, tlsConfig *tls.Config, externalGroupService GroupServiceConnector) GroupServiceConnector

type GroupServiceSyncConnector

type GroupServiceSyncConnector interface {
	GroupServiceSyncHost() string
	SetGroupServiceSyncHost(host string)
	AddSecurityTokenInfo(securityIdenfier string, deviceInfo map[string]string, fields log.Fields) error
}

func NewGroupServiceSyncConnector

func NewGroupServiceSyncConnector(conf *configuration.Config, tlsConfig *tls.Config, externalGroupServiceSync GroupServiceSyncConnector) GroupServiceSyncConnector

type HttpClient

type HttpClient struct {
	*http.Client
	// contains filtered or unexported fields
}

func NewHttpClient

func NewHttpClient(conf *configuration.Config, serviceName string, tlsConfig *tls.Config) *HttpClient

func (*HttpClient) Do

func (c *HttpClient) Do(method string, url string, headers map[string]string, bbytes []byte, baseFields log.Fields, loggerName string, retry int) ([]byte, error, bool, int)

Do is a wrapper around http.Client.Do Inputs: method, url, headers, body as bytes (bbytes), fields for logging (baseFields),

external service being called (loggerName), attempt # (retry)

Returns: response body as bytes, any err, whether a retry is useful or not, and the status code

func (*HttpClient) DoWithRetries

func (c *HttpClient) DoWithRetries(method string, url string, inHeaders map[string]string, bbytes []byte, fields log.Fields, loggerName string) ([]byte, error)

type HttpErrorResponse

type HttpErrorResponse struct {
	Status    int         `json:"status"`
	ErrorCode int         `json:"error_code,omitempty"`
	Message   string      `json:"message,omitempty"`
	Errors    interface{} `json:"errors,omitempty"`
}

http error response

type HttpResponse

type HttpResponse struct {
	Status  int         `json:"status"`
	Message string      `json:"message,omitempty"`
	Data    interface{} `json:"data,omitempty"`
}

http ok response

type IAppMetrics

type IAppMetrics interface {
	MetricsHandler(next http.Handler) http.Handler
	UpdateAPIMetrics(req *http.Request, statusCode int, startTime time.Time)
	UpdateExternalAPIMetrics(service string, method string, statusCode int, startTime time.Time)
}

Define the interface for core metrics so other packages can provide their own implementation

type ResponseEntity

type ResponseEntity struct {
	Status int
	Error  error
	Data   interface{}
}

func NewResponseEntity

func NewResponseEntity(status int, err error, data interface{}) *ResponseEntity

type SatServiceConnector

type SatServiceConnector interface {
	SatServiceName() string
	SatServiceHost() string
	ConsumerHost() string
	SetSatServiceName(name string)
	SetSatServiceHost(host string)
	GetSatTokenFromSatService(fields log.Fields, vargs ...string) (*SatServiceResponse, error)
}

func NewSatServiceConnector

func NewSatServiceConnector(conf *configuration.Config, tlsConfig *tls.Config, externalSatConnector SatServiceConnector) SatServiceConnector

type SatServiceResponse

type SatServiceResponse struct {
	AccessToken  string `json:"access_token"`
	ExpiresIn    int    `json:"expires_in"`
	Scope        string `json:"score"`
	TokenType    string `json:"token_type"`
	ResponseCode int    `json:"responseCode"`
	Description  string `json:"description"`
}

type SatToken

type SatToken struct {
	Token    string `json:"token"`
	Source   string `json:"source"`
	KeyName  string `json:"key_name"`
	Expiry   string `json:"expiry"`
	TokenTTL int    `json:"token_ttl"`
}

SatToken - response object of sat token from SatService

func GetLocalSatToken

func GetLocalSatToken(fields log.Fields) (*SatToken, error)

GetLocalSatToken - get local sattoken

func GetSatTokenFromSatService

func GetSatTokenFromSatService(fields log.Fields) (*SatToken, error)

GetSatTokenFromSatService - getting sat token from SatService

func (*SatToken) IsTokenExpired

func (xst *SatToken) IsTokenExpired(fields log.Fields) bool

IsTokenExpired - making sure token is still valid

type SatTokenMgr

type SatTokenMgr struct {
	*SatToken
	// contains filtered or unexported fields
}

SatTokenMgr - token manager

func GetSatTokenManager

func GetSatTokenManager() *SatTokenMgr

GetSatTokenManager - return Sattoken manager object

func NewSatTokenMgr

func NewSatTokenMgr(args ...bool) *SatTokenMgr

NewSatTokenMgr - new SAT token manager

func (*SatTokenMgr) GetSatToken

func (s *SatTokenMgr) GetSatToken(fields log.Fields) (string, error)

GetSatToken logic as below...

  1. try to check local cache, has token, token is still valid
  2. try to get from REDIS, has token, token is still valid
  3. try to get the token from SatService, update local cache and redis Cache

func (*SatTokenMgr) SetTestOnly

func (s *SatTokenMgr) SetTestOnly(testOnly bool)

func (*SatTokenMgr) TestOnly

func (s *SatTokenMgr) TestOnly() bool

type SecurityTokenConfig

type SecurityTokenConfig struct {
	SecurityTokenOnlyForNewOfferedFwEnabled bool
	SkipSecurityTokenClientProtocolSet      util.Set
	SecurityTokenModelSet                   util.Set
	SecurityTokenDevicePercentEnabled       bool
	SecurityTokenDevicePercentValue         float64
	SecurityTokenHostKeyword                string
	SecurityTokenKey                        string
	SecurityTokenHashEnabled                bool
	SecurityTokenGroupServiceEnabled        bool
}

func NewSecurityTokenConfig

func NewSecurityTokenConfig(conf *configuration.Config) *SecurityTokenConfig

type SecurityTokenPathConfig

type SecurityTokenPathConfig struct {
	UrlPathMap             map[string]bool
	UrlHostKeywordMap      map[string]bool
	TimestampKey           string
	FilenameInTokenEnabled bool
}

func NewFirmwareNonMtlSsrTokenPathConfig

func NewFirmwareNonMtlSsrTokenPathConfig(conf *configuration.Config) *SecurityTokenPathConfig

func NewLogUploaderNonMtlSsrTokenPathConfig

func NewLogUploaderNonMtlSsrTokenPathConfig(conf *configuration.Config) *SecurityTokenPathConfig

func (*SecurityTokenPathConfig) AddSecurityTokenToUrl

func (s *SecurityTokenPathConfig) AddSecurityTokenToUrl(deviceInfo map[string]string, urlString string, fields log.Fields) string

type TaggingConnector

type TaggingConnector interface {
	MakeGetTagsRequest(url string, token string, vargs ...log.Fields) ([]string, error)
	GetTagsForContext(contextMap map[string]string, token string, fields log.Fields) ([]string, error)
	TaggingHost() string
	SetTaggingHost(host string)
	GetTagsForMacAddress(macAddress string, token string, fields log.Fields) ([]string, error)
	GetTagsForPartner(partnerId string, token string, fields log.Fields) ([]string, error)
	GetTagsForPartnerAndMacAddress(partnerId string, macAddress string, token string, fields log.Fields) ([]string, error)
	GetTagsForMacAddressAndAccount(macAddress string, accountId string, token string, fields log.Fields) ([]string, error)
	GetTagsForAccount(accountId string, token string, fields log.Fields) ([]string, error)
	GetTagsForPartnerAndMacAddressAndAccount(partnerId string, macAddress string, accountId string, token string, fields log.Fields) ([]string, error)
	GetTagsForPartnerAndAccount(partnerId string, accountId string, token string, fields log.Fields) ([]string, error)
}

func NewTaggingConnector

func NewTaggingConnector(conf *configuration.Config, tlsConfig *tls.Config, externalTagging TaggingConnector) TaggingConnector

type XResponseWriter

type XResponseWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

func NewXResponseWriter

func NewXResponseWriter(w http.ResponseWriter, vargs ...interface{}) *XResponseWriter

func (*XResponseWriter) Audit

func (w *XResponseWriter) Audit() log.Fields

func (*XResponseWriter) AuditData

func (w *XResponseWriter) AuditData(k string) string

func (*XResponseWriter) AuditId

func (w *XResponseWriter) AuditId() string

func (*XResponseWriter) Body

func (w *XResponseWriter) Body() string

func (*XResponseWriter) LogDebug

func (xw *XResponseWriter) LogDebug(r *http.Request, logger string, message string)

func (*XResponseWriter) LogInfo

func (xw *XResponseWriter) LogInfo(r *http.Request, logger string, message string)

func (*XResponseWriter) LogWarn

func (xw *XResponseWriter) LogWarn(r *http.Request, logger string, message string)

func (*XResponseWriter) Response

func (w *XResponseWriter) Response() string

func (*XResponseWriter) SetAuditData

func (w *XResponseWriter) SetAuditData(k string, v interface{})

func (*XResponseWriter) SetBody

func (w *XResponseWriter) SetBody(body string)

func (*XResponseWriter) SetBodyObfuscated

func (w *XResponseWriter) SetBodyObfuscated(obfuscated bool)

func (*XResponseWriter) StartTime

func (w *XResponseWriter) StartTime() time.Time

func (*XResponseWriter) Status

func (w *XResponseWriter) Status() int

get/set

func (*XResponseWriter) String

func (w *XResponseWriter) String() string

func (*XResponseWriter) Token

func (w *XResponseWriter) Token() string

func (*XResponseWriter) TraceId

func (w *XResponseWriter) TraceId() string

func (*XResponseWriter) Write

func (w *XResponseWriter) Write(b []byte) (int, error)

func (*XResponseWriter) WriteHeader

func (w *XResponseWriter) WriteHeader(status int)

interface/override

type XconfServer

type XconfServer struct {
	*http.Server
	db.DatabaseClient
	*common.ServerConfig
	SatServiceConnector
	DeviceServiceConnector
	AccountServiceConnector
	TaggingConnector
	*AppMetricsConfig
	GroupServiceConnector
	GroupServiceSyncConnector
	*tracing.XpcTracer
	SecurityTokenConfig          *SecurityTokenConfig
	LogUploadSecurityTokenConfig *SecurityTokenPathConfig
	FirmwareSecurityTokenConfig  *SecurityTokenPathConfig
	AppMetrics                   IAppMetrics

	AppName string
	// contains filtered or unexported fields
}
var (
	Ws *XconfServer
)

stm variable

func NewXconfServer

func NewXconfServer(sc *common.ServerConfig, testOnly bool, ec *ExternalConnectors) *XconfServer

testOnly=true ==> running unit test

func (*XconfServer) AddBaseRoutes

func (s *XconfServer) AddBaseRoutes(testOnly bool, router *mux.Router)

func (*XconfServer) GetRouter

func (s *XconfServer) GetRouter(testOnly bool) *mux.Router

func (*XconfServer) HealthZHandler

func (s *XconfServer) HealthZHandler(w http.ResponseWriter, r *http.Request)

func (*XconfServer) InfoVersionHandler

func (s *XconfServer) InfoVersionHandler(w http.ResponseWriter, r *http.Request)

func (*XconfServer) LogRequestEnds

func (s *XconfServer) LogRequestEnds(xw *XResponseWriter, r *http.Request)

func (*XconfServer) LogRequestStarts

func (s *XconfServer) LogRequestStarts(w http.ResponseWriter, r *http.Request) XResponseWriter

func (*XconfServer) MetricsEnabled

func (s *XconfServer) MetricsEnabled() bool

func (*XconfServer) MonitorHandler

func (s *XconfServer) MonitorHandler(w http.ResponseWriter, r *http.Request)

func (*XconfServer) NoAuthMiddleware

func (s *XconfServer) NoAuthMiddleware(next http.Handler) http.Handler

func (*XconfServer) NotFoundHandler

func (s *XconfServer) NotFoundHandler(w http.ResponseWriter, r *http.Request)

func (*XconfServer) NotLoggedHeaders

func (s *XconfServer) NotLoggedHeaders() []string

func (*XconfServer) NotificationHandler

func (s *XconfServer) NotificationHandler(w http.ResponseWriter, r *http.Request)

func (*XconfServer) ServerConfigHandler

func (s *XconfServer) ServerConfigHandler(w http.ResponseWriter, r *http.Request)

func (*XconfServer) SetWebMetrics

func (s *XconfServer) SetWebMetrics(m IAppMetrics) IAppMetrics

WebMetrics updates infligh, reqSize and respSize metrics

func (*XconfServer) SetupMocks

func (server *XconfServer) SetupMocks()

setupMocks sets up mock servers that return the same predefined response for any call to the server mock servers are set up for all external services - SatService, DeviceService, TaggingService, AccountService If a different mock response is desired for a test, use the same template below, but just define a different mockResponse An example for a different mock response can be seen in http/supplementary_handler_test.go

func (*XconfServer) SpanMiddleware

func (s *XconfServer) SpanMiddleware(next http.Handler) http.Handler

func (*XconfServer) StopXpcTracer

func (s *XconfServer) StopXpcTracer()

func (*XconfServer) TestingMiddleware

func (s *XconfServer) TestingMiddleware(next http.Handler) http.Handler

func (*XconfServer) TlsConfig

func (s *XconfServer) TlsConfig() *tls.Config

func (*XconfServer) VersionHandler

func (s *XconfServer) VersionHandler(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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