id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
23,000 | TheThingsNetwork/ttn | core/component/auth.go | BuildJWT | func (c *Component) BuildJWT() (string, error) {
if c.privateKey == nil {
return "", nil
}
if c.Identity == nil {
return "", nil
}
privPEM, err := security.PrivatePEM(c.privateKey)
if err != nil {
return "", err
}
return security.BuildJWT(c.Identity.ID, 20*time.Second, privPEM)
} | go | func (c *Component) BuildJWT() (string, error) {
if c.privateKey == nil {
return "", nil
}
if c.Identity == nil {
return "", nil
}
privPEM, err := security.PrivatePEM(c.privateKey)
if err != nil {
return "", err
}
return security.BuildJWT(c.Identity.ID, 20*time.Second, privPEM)
} | [
"func",
"(",
"c",
"*",
"Component",
")",
"BuildJWT",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"c",
".",
"privateKey",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"nil",
"\n",
"}",
"\n",
"if",
"c",
".",
"Identity",
"==",
"nil",
"{... | // BuildJWT builds a short-lived JSON Web Token for this component | [
"BuildJWT",
"builds",
"a",
"short",
"-",
"lived",
"JSON",
"Web",
"Token",
"for",
"this",
"component"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/component/auth.go#L201-L213 |
23,001 | TheThingsNetwork/ttn | core/component/auth.go | GetContext | func (c *Component) GetContext(token string) context.Context {
if c.Context == nil {
c.initBgCtx()
}
ctx := c.Context
if token == "" && c.Identity != nil {
token, _ = c.BuildJWT()
}
ctx = ttnctx.OutgoingContextWithToken(ctx, token)
return ctx
} | go | func (c *Component) GetContext(token string) context.Context {
if c.Context == nil {
c.initBgCtx()
}
ctx := c.Context
if token == "" && c.Identity != nil {
token, _ = c.BuildJWT()
}
ctx = ttnctx.OutgoingContextWithToken(ctx, token)
return ctx
} | [
"func",
"(",
"c",
"*",
"Component",
")",
"GetContext",
"(",
"token",
"string",
")",
"context",
".",
"Context",
"{",
"if",
"c",
".",
"Context",
"==",
"nil",
"{",
"c",
".",
"initBgCtx",
"(",
")",
"\n",
"}",
"\n",
"ctx",
":=",
"c",
".",
"Context",
"... | // GetContext returns a context for outgoing RPC request. If token is "", this function will generate a short lived token from the component | [
"GetContext",
"returns",
"a",
"context",
"for",
"outgoing",
"RPC",
"request",
".",
"If",
"token",
"is",
"this",
"function",
"will",
"generate",
"a",
"short",
"lived",
"token",
"from",
"the",
"component"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/component/auth.go#L216-L226 |
23,002 | TheThingsNetwork/ttn | core/component/auth.go | ExchangeAppKeyForToken | func (c *Component) ExchangeAppKeyForToken(appID, key string) (string, error) {
issuerID := keys.KeyIssuer(key)
if issuerID == "" {
// Take the first configured auth server
for k := range c.Config.AuthServers {
issuerID = k
break
}
key = fmt.Sprintf("%s.%s", issuerID, key)
}
issuer, ok := c.Config.Aut... | go | func (c *Component) ExchangeAppKeyForToken(appID, key string) (string, error) {
issuerID := keys.KeyIssuer(key)
if issuerID == "" {
// Take the first configured auth server
for k := range c.Config.AuthServers {
issuerID = k
break
}
key = fmt.Sprintf("%s.%s", issuerID, key)
}
issuer, ok := c.Config.Aut... | [
"func",
"(",
"c",
"*",
"Component",
")",
"ExchangeAppKeyForToken",
"(",
"appID",
",",
"key",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"issuerID",
":=",
"keys",
".",
"KeyIssuer",
"(",
"key",
")",
"\n",
"if",
"issuerID",
"==",
"\"",
"\"",
... | // ExchangeAppKeyForToken enables authentication with the App Access Key | [
"ExchangeAppKeyForToken",
"enables",
"authentication",
"with",
"the",
"App",
"Access",
"Key"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/component/auth.go#L231-L272 |
23,003 | TheThingsNetwork/ttn | core/component/auth.go | ValidateTTNAuthContext | func (c *Component) ValidateTTNAuthContext(ctx context.Context) (*claims.Claims, error) {
token, err := ttnctx.TokenFromIncomingContext(ctx)
if err != nil {
return nil, err
}
if c.TokenKeyProvider == nil {
return nil, errors.NewErrInternal("No token provider configured")
}
claims, err := claims.FromToken(c.... | go | func (c *Component) ValidateTTNAuthContext(ctx context.Context) (*claims.Claims, error) {
token, err := ttnctx.TokenFromIncomingContext(ctx)
if err != nil {
return nil, err
}
if c.TokenKeyProvider == nil {
return nil, errors.NewErrInternal("No token provider configured")
}
claims, err := claims.FromToken(c.... | [
"func",
"(",
"c",
"*",
"Component",
")",
"ValidateTTNAuthContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"claims",
".",
"Claims",
",",
"error",
")",
"{",
"token",
",",
"err",
":=",
"ttnctx",
".",
"TokenFromIncomingContext",
"(",
"ctx",
")... | // ValidateTTNAuthContext gets a token from the context and validates it | [
"ValidateTTNAuthContext",
"gets",
"a",
"token",
"from",
"the",
"context",
"and",
"validates",
"it"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/component/auth.go#L324-L340 |
23,004 | TheThingsNetwork/ttn | api/stats/stats.go | GetSystem | func GetSystem() *api.SystemStats {
status := new(api.SystemStats)
if load, err := load.Avg(); err == nil {
status.Load = &api.SystemStats_Loadstats{
Load1: float32(load.Load1),
Load5: float32(load.Load5),
Load15: float32(load.Load15),
}
}
status.Cpu = &api.SystemStats_CPUStats{
Percentage: float32... | go | func GetSystem() *api.SystemStats {
status := new(api.SystemStats)
if load, err := load.Avg(); err == nil {
status.Load = &api.SystemStats_Loadstats{
Load1: float32(load.Load1),
Load5: float32(load.Load5),
Load15: float32(load.Load15),
}
}
status.Cpu = &api.SystemStats_CPUStats{
Percentage: float32... | [
"func",
"GetSystem",
"(",
")",
"*",
"api",
".",
"SystemStats",
"{",
"status",
":=",
"new",
"(",
"api",
".",
"SystemStats",
")",
"\n",
"if",
"load",
",",
"err",
":=",
"load",
".",
"Avg",
"(",
")",
";",
"err",
"==",
"nil",
"{",
"status",
".",
"Load... | // GetSystem gets statistics about the system | [
"GetSystem",
"gets",
"statistics",
"about",
"the",
"system"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/api/stats/stats.go#L58-L83 |
23,005 | TheThingsNetwork/ttn | api/stats/stats.go | GetComponent | func GetComponent() *api.ComponentStats {
status := new(api.ComponentStats)
status.Uptime = uint64(time.Now().Sub(startTime).Seconds())
process, err := process.NewProcess(int32(os.Getpid()))
if err == nil {
if memory, err := process.MemoryInfo(); err == nil {
status.Memory = &api.ComponentStats_MemoryStats{
... | go | func GetComponent() *api.ComponentStats {
status := new(api.ComponentStats)
status.Uptime = uint64(time.Now().Sub(startTime).Seconds())
process, err := process.NewProcess(int32(os.Getpid()))
if err == nil {
if memory, err := process.MemoryInfo(); err == nil {
status.Memory = &api.ComponentStats_MemoryStats{
... | [
"func",
"GetComponent",
"(",
")",
"*",
"api",
".",
"ComponentStats",
"{",
"status",
":=",
"new",
"(",
"api",
".",
"ComponentStats",
")",
"\n",
"status",
".",
"Uptime",
"=",
"uint64",
"(",
"time",
".",
"Now",
"(",
")",
".",
"Sub",
"(",
"startTime",
")... | // GetComponent gets statistics about this component | [
"GetComponent",
"gets",
"statistics",
"about",
"this",
"component"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/api/stats/stats.go#L86-L116 |
23,006 | TheThingsNetwork/ttn | ttnctl/util/config.go | GetAppEUI | func GetAppEUI(ctx ttnlog.Interface) types.AppEUI {
appEUIString := viper.GetString("app-eui")
if appEUIString == "" {
appData := readData(appFilename)
eui, ok := appData[euiKey].(string)
if !ok {
ctx.Fatal("Invalid AppEUI in config file")
}
appEUIString = eui
}
if appEUIString == "" {
ctx.Fatal("Mi... | go | func GetAppEUI(ctx ttnlog.Interface) types.AppEUI {
appEUIString := viper.GetString("app-eui")
if appEUIString == "" {
appData := readData(appFilename)
eui, ok := appData[euiKey].(string)
if !ok {
ctx.Fatal("Invalid AppEUI in config file")
}
appEUIString = eui
}
if appEUIString == "" {
ctx.Fatal("Mi... | [
"func",
"GetAppEUI",
"(",
"ctx",
"ttnlog",
".",
"Interface",
")",
"types",
".",
"AppEUI",
"{",
"appEUIString",
":=",
"viper",
".",
"GetString",
"(",
"\"",
"\"",
")",
"\n",
"if",
"appEUIString",
"==",
"\"",
"\"",
"{",
"appData",
":=",
"readData",
"(",
"... | // GetAppEUI returns the AppEUI that must be set in the command options or config | [
"GetAppEUI",
"returns",
"the",
"AppEUI",
"that",
"must",
"be",
"set",
"in",
"the",
"command",
"options",
"or",
"config"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/config.go#L141-L161 |
23,007 | TheThingsNetwork/ttn | ttnctl/util/config.go | SetAppEUI | func SetAppEUI(ctx ttnlog.Interface, appEUI types.AppEUI) {
err := setData(appFilename, euiKey, appEUI.String())
if err != nil {
ctx.WithError(err).Fatal("Could not save app EUI")
}
} | go | func SetAppEUI(ctx ttnlog.Interface, appEUI types.AppEUI) {
err := setData(appFilename, euiKey, appEUI.String())
if err != nil {
ctx.WithError(err).Fatal("Could not save app EUI")
}
} | [
"func",
"SetAppEUI",
"(",
"ctx",
"ttnlog",
".",
"Interface",
",",
"appEUI",
"types",
".",
"AppEUI",
")",
"{",
"err",
":=",
"setData",
"(",
"appFilename",
",",
"euiKey",
",",
"appEUI",
".",
"String",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",... | // SetAppEUI stores the app EUI preference | [
"SetAppEUI",
"stores",
"the",
"app",
"EUI",
"preference"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/config.go#L164-L169 |
23,008 | TheThingsNetwork/ttn | ttnctl/util/config.go | GetAppID | func GetAppID(ctx ttnlog.Interface) string {
appID := viper.GetString("app-id")
if appID == "" {
appData := readData(appFilename)
id, ok := appData[idKey].(string)
if !ok {
ctx.Fatal("Invalid appID in config file.")
}
appID = id
}
if appID == "" {
ctx.Fatal("Missing Application ID. You should select... | go | func GetAppID(ctx ttnlog.Interface) string {
appID := viper.GetString("app-id")
if appID == "" {
appData := readData(appFilename)
id, ok := appData[idKey].(string)
if !ok {
ctx.Fatal("Invalid appID in config file.")
}
appID = id
}
if appID == "" {
ctx.Fatal("Missing Application ID. You should select... | [
"func",
"GetAppID",
"(",
"ctx",
"ttnlog",
".",
"Interface",
")",
"string",
"{",
"appID",
":=",
"viper",
".",
"GetString",
"(",
"\"",
"\"",
")",
"\n",
"if",
"appID",
"==",
"\"",
"\"",
"{",
"appData",
":=",
"readData",
"(",
"appFilename",
")",
"\n",
"i... | // GetAppID returns the AppID that must be set in the command options or config | [
"GetAppID",
"returns",
"the",
"AppID",
"that",
"must",
"be",
"set",
"in",
"the",
"command",
"options",
"or",
"config"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/config.go#L172-L192 |
23,009 | TheThingsNetwork/ttn | ttnctl/util/config.go | SetApp | func SetApp(ctx ttnlog.Interface, appID string, appEUI types.AppEUI) {
config := readData(appFilename)
config[idKey] = appID
config[euiKey] = appEUI.String()
err := writeData(appFilename, config)
if err != nil {
ctx.WithError(err).Fatal("Could not save app preference")
}
} | go | func SetApp(ctx ttnlog.Interface, appID string, appEUI types.AppEUI) {
config := readData(appFilename)
config[idKey] = appID
config[euiKey] = appEUI.String()
err := writeData(appFilename, config)
if err != nil {
ctx.WithError(err).Fatal("Could not save app preference")
}
} | [
"func",
"SetApp",
"(",
"ctx",
"ttnlog",
".",
"Interface",
",",
"appID",
"string",
",",
"appEUI",
"types",
".",
"AppEUI",
")",
"{",
"config",
":=",
"readData",
"(",
"appFilename",
")",
"\n",
"config",
"[",
"idKey",
"]",
"=",
"appID",
"\n",
"config",
"["... | // SetApp stores the app ID and app EUI preferences | [
"SetApp",
"stores",
"the",
"app",
"ID",
"and",
"app",
"EUI",
"preferences"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/config.go#L195-L203 |
23,010 | TheThingsNetwork/ttn | core/component/component.go | New | func New(ctx ttnlog.Interface, serviceName string, announcedAddress string) (*Component, error) {
component := &Component{
Config: ConfigFromViper(),
Ctx: ctx,
Identity: &pb_discovery.Announcement{
ID: viper.GetString("id"),
Description: viper.GetString("description"),
ServiceName: ... | go | func New(ctx ttnlog.Interface, serviceName string, announcedAddress string) (*Component, error) {
component := &Component{
Config: ConfigFromViper(),
Ctx: ctx,
Identity: &pb_discovery.Announcement{
ID: viper.GetString("id"),
Description: viper.GetString("description"),
ServiceName: ... | [
"func",
"New",
"(",
"ctx",
"ttnlog",
".",
"Interface",
",",
"serviceName",
"string",
",",
"announcedAddress",
"string",
")",
"(",
"*",
"Component",
",",
"error",
")",
"{",
"component",
":=",
"&",
"Component",
"{",
"Config",
":",
"ConfigFromViper",
"(",
")"... | // New creates a new Component | [
"New",
"creates",
"a",
"new",
"Component"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/component/component.go#L59-L118 |
23,011 | TheThingsNetwork/ttn | core/discovery/announcement/store.go | NewRedisAnnouncementStore | func NewRedisAnnouncementStore(client *redis.Client, prefix string) Store {
if prefix == "" {
prefix = defaultRedisPrefix
}
store := storage.NewRedisMapStore(client, prefix+":"+redisAnnouncementPrefix)
store.SetBase(Announcement{}, "")
for v, f := range migrate.AnnouncementMigrations(prefix) {
store.AddMigrati... | go | func NewRedisAnnouncementStore(client *redis.Client, prefix string) Store {
if prefix == "" {
prefix = defaultRedisPrefix
}
store := storage.NewRedisMapStore(client, prefix+":"+redisAnnouncementPrefix)
store.SetBase(Announcement{}, "")
for v, f := range migrate.AnnouncementMigrations(prefix) {
store.AddMigrati... | [
"func",
"NewRedisAnnouncementStore",
"(",
"client",
"*",
"redis",
".",
"Client",
",",
"prefix",
"string",
")",
"Store",
"{",
"if",
"prefix",
"==",
"\"",
"\"",
"{",
"prefix",
"=",
"defaultRedisPrefix",
"\n",
"}",
"\n",
"store",
":=",
"storage",
".",
"NewRed... | // NewRedisAnnouncementStore creates a new Redis-based Announcement store | [
"NewRedisAnnouncementStore",
"creates",
"a",
"new",
"Redis",
"-",
"based",
"Announcement",
"store"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/discovery/announcement/store.go#L45-L61 |
23,012 | TheThingsNetwork/ttn | core/discovery/announcement/store.go | GetMetadata | func (s *RedisAnnouncementStore) GetMetadata(serviceName, serviceID string) ([]Metadata, error) {
var out []Metadata
metadata, err := s.metadata.Get(fmt.Sprintf("%s:%s", serviceName, serviceID))
if errors.GetErrType(err) == errors.NotFound {
return nil, nil
}
if err != nil {
return nil, err
}
for _, meta := ... | go | func (s *RedisAnnouncementStore) GetMetadata(serviceName, serviceID string) ([]Metadata, error) {
var out []Metadata
metadata, err := s.metadata.Get(fmt.Sprintf("%s:%s", serviceName, serviceID))
if errors.GetErrType(err) == errors.NotFound {
return nil, nil
}
if err != nil {
return nil, err
}
for _, meta := ... | [
"func",
"(",
"s",
"*",
"RedisAnnouncementStore",
")",
"GetMetadata",
"(",
"serviceName",
",",
"serviceID",
"string",
")",
"(",
"[",
"]",
"Metadata",
",",
"error",
")",
"{",
"var",
"out",
"[",
"]",
"Metadata",
"\n",
"metadata",
",",
"err",
":=",
"s",
".... | // GetMetadata returns the metadata of the specified service | [
"GetMetadata",
"returns",
"the",
"metadata",
"of",
"the",
"specified",
"service"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/discovery/announcement/store.go#L130-L145 |
23,013 | TheThingsNetwork/ttn | core/discovery/announcement/store.go | GetForAppEUI | func (s *RedisAnnouncementStore) GetForAppEUI(appEUI types.AppEUI) (*Announcement, error) {
serviceName, serviceID, err := s.getForAppEUI(appEUI)
if err != nil {
return nil, err
}
return s.Get(serviceName, serviceID)
} | go | func (s *RedisAnnouncementStore) GetForAppEUI(appEUI types.AppEUI) (*Announcement, error) {
serviceName, serviceID, err := s.getForAppEUI(appEUI)
if err != nil {
return nil, err
}
return s.Get(serviceName, serviceID)
} | [
"func",
"(",
"s",
"*",
"RedisAnnouncementStore",
")",
"GetForAppEUI",
"(",
"appEUI",
"types",
".",
"AppEUI",
")",
"(",
"*",
"Announcement",
",",
"error",
")",
"{",
"serviceName",
",",
"serviceID",
",",
"err",
":=",
"s",
".",
"getForAppEUI",
"(",
"appEUI",
... | // GetForAppEUI returns the last Announcement that contains metadata for the given AppEUI | [
"GetForAppEUI",
"returns",
"the",
"last",
"Announcement",
"that",
"contains",
"metadata",
"for",
"the",
"given",
"AppEUI"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/discovery/announcement/store.go#L193-L199 |
23,014 | TheThingsNetwork/ttn | core/discovery/announcement/store.go | Set | func (s *RedisAnnouncementStore) Set(new *Announcement) error {
now := time.Now()
new.UpdatedAt = now
key := fmt.Sprintf("%s:%s", new.ServiceName, new.ID)
if new.old == nil {
new.CreatedAt = now
}
err := s.store.Set(key, *new)
if err != nil {
return err
}
return nil
} | go | func (s *RedisAnnouncementStore) Set(new *Announcement) error {
now := time.Now()
new.UpdatedAt = now
key := fmt.Sprintf("%s:%s", new.ServiceName, new.ID)
if new.old == nil {
new.CreatedAt = now
}
err := s.store.Set(key, *new)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"s",
"*",
"RedisAnnouncementStore",
")",
"Set",
"(",
"new",
"*",
"Announcement",
")",
"error",
"{",
"now",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"new",
".",
"UpdatedAt",
"=",
"now",
"\n",
"key",
":=",
"fmt",
".",
"Sprintf",
"(",
"\... | // Set a new Announcement or update an existing one
// The metadata of the announcement is ignored, as metadata should be managed with AddMetadata and RemoveMetadata | [
"Set",
"a",
"new",
"Announcement",
"or",
"update",
"an",
"existing",
"one",
"The",
"metadata",
"of",
"the",
"announcement",
"is",
"ignored",
"as",
"metadata",
"should",
"be",
"managed",
"with",
"AddMetadata",
"and",
"RemoveMetadata"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/discovery/announcement/store.go#L203-L215 |
23,015 | TheThingsNetwork/ttn | core/discovery/announcement/store.go | AddMetadata | func (s *RedisAnnouncementStore) AddMetadata(serviceName, serviceID string, metadata ...Metadata) error {
key := fmt.Sprintf("%s:%s", serviceName, serviceID)
metadataStrings := make([]string, 0, len(metadata))
for _, meta := range metadata {
txt, err := meta.MarshalText()
if err != nil {
return err
}
met... | go | func (s *RedisAnnouncementStore) AddMetadata(serviceName, serviceID string, metadata ...Metadata) error {
key := fmt.Sprintf("%s:%s", serviceName, serviceID)
metadataStrings := make([]string, 0, len(metadata))
for _, meta := range metadata {
txt, err := meta.MarshalText()
if err != nil {
return err
}
met... | [
"func",
"(",
"s",
"*",
"RedisAnnouncementStore",
")",
"AddMetadata",
"(",
"serviceName",
",",
"serviceID",
"string",
",",
"metadata",
"...",
"Metadata",
")",
"error",
"{",
"key",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"serviceName",
",",
"servi... | // AddMetadata adds metadata to the announcement of the specified service | [
"AddMetadata",
"adds",
"metadata",
"to",
"the",
"announcement",
"of",
"the",
"specified",
"service"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/discovery/announcement/store.go#L218-L288 |
23,016 | TheThingsNetwork/ttn | core/discovery/announcement/store.go | RemoveMetadata | func (s *RedisAnnouncementStore) RemoveMetadata(serviceName, serviceID string, metadata ...Metadata) error {
metadataStrings := make([]string, 0, len(metadata))
for _, meta := range metadata {
if txt, err := meta.MarshalText(); err == nil {
metadataStrings = append(metadataStrings, string(txt))
}
switch meta... | go | func (s *RedisAnnouncementStore) RemoveMetadata(serviceName, serviceID string, metadata ...Metadata) error {
metadataStrings := make([]string, 0, len(metadata))
for _, meta := range metadata {
if txt, err := meta.MarshalText(); err == nil {
metadataStrings = append(metadataStrings, string(txt))
}
switch meta... | [
"func",
"(",
"s",
"*",
"RedisAnnouncementStore",
")",
"RemoveMetadata",
"(",
"serviceName",
",",
"serviceID",
"string",
",",
"metadata",
"...",
"Metadata",
")",
"error",
"{",
"metadataStrings",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"... | // RemoveMetadata removes metadata from the announcement of the specified service | [
"RemoveMetadata",
"removes",
"metadata",
"from",
"the",
"announcement",
"of",
"the",
"specified",
"service"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/discovery/announcement/store.go#L291-L311 |
23,017 | TheThingsNetwork/ttn | core/discovery/announcement/store.go | Delete | func (s *RedisAnnouncementStore) Delete(serviceName, serviceID string) error {
metadata, err := s.GetMetadata(serviceName, serviceID)
if err != nil && errors.GetErrType(err) != errors.NotFound {
return err
}
if len(metadata) > 0 {
s.RemoveMetadata(serviceName, serviceID, metadata...)
}
key := fmt.Sprintf("%s:... | go | func (s *RedisAnnouncementStore) Delete(serviceName, serviceID string) error {
metadata, err := s.GetMetadata(serviceName, serviceID)
if err != nil && errors.GetErrType(err) != errors.NotFound {
return err
}
if len(metadata) > 0 {
s.RemoveMetadata(serviceName, serviceID, metadata...)
}
key := fmt.Sprintf("%s:... | [
"func",
"(",
"s",
"*",
"RedisAnnouncementStore",
")",
"Delete",
"(",
"serviceName",
",",
"serviceID",
"string",
")",
"error",
"{",
"metadata",
",",
"err",
":=",
"s",
".",
"GetMetadata",
"(",
"serviceName",
",",
"serviceID",
")",
"\n",
"if",
"err",
"!=",
... | // Delete an Announcement and its metadata | [
"Delete",
"an",
"Announcement",
"and",
"its",
"metadata"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/discovery/announcement/store.go#L314-L328 |
23,018 | TheThingsNetwork/ttn | api/dial.go | Dial | func Dial(target string) (*grpc.ClientConn, error) {
conn, err := pool.Global.DialSecure(target, nil)
if err == nil {
return conn, nil
}
if _, ok := err.(tls.RecordHeaderError); ok && AllowInsecureFallback {
pool.Global.Close(target)
log.Get().Warn("Could not connect to gRPC server with TLS, will reconnect wi... | go | func Dial(target string) (*grpc.ClientConn, error) {
conn, err := pool.Global.DialSecure(target, nil)
if err == nil {
return conn, nil
}
if _, ok := err.(tls.RecordHeaderError); ok && AllowInsecureFallback {
pool.Global.Close(target)
log.Get().Warn("Could not connect to gRPC server with TLS, will reconnect wi... | [
"func",
"Dial",
"(",
"target",
"string",
")",
"(",
"*",
"grpc",
".",
"ClientConn",
",",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"pool",
".",
"Global",
".",
"DialSecure",
"(",
"target",
",",
"nil",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"r... | // Dial an address with default TLS config | [
"Dial",
"an",
"address",
"with",
"default",
"TLS",
"config"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/api/dial.go#L20-L32 |
23,019 | TheThingsNetwork/ttn | api/dial.go | DialWithCert | func DialWithCert(target string, cert string) (*grpc.ClientConn, error) {
certPool := x509.NewCertPool()
ok := certPool.AppendCertsFromPEM([]byte(cert))
if !ok {
panic("failed to parse root certificate")
}
return pool.Global.DialSecure(target, credentials.NewClientTLSFromCert(certPool, ""))
} | go | func DialWithCert(target string, cert string) (*grpc.ClientConn, error) {
certPool := x509.NewCertPool()
ok := certPool.AppendCertsFromPEM([]byte(cert))
if !ok {
panic("failed to parse root certificate")
}
return pool.Global.DialSecure(target, credentials.NewClientTLSFromCert(certPool, ""))
} | [
"func",
"DialWithCert",
"(",
"target",
"string",
",",
"cert",
"string",
")",
"(",
"*",
"grpc",
".",
"ClientConn",
",",
"error",
")",
"{",
"certPool",
":=",
"x509",
".",
"NewCertPool",
"(",
")",
"\n",
"ok",
":=",
"certPool",
".",
"AppendCertsFromPEM",
"("... | // DialWithCert dials the target using the given TLS cert | [
"DialWithCert",
"dials",
"the",
"target",
"using",
"the",
"given",
"TLS",
"cert"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/api/dial.go#L35-L42 |
23,020 | TheThingsNetwork/ttn | core/networkserver/networkserver.go | NewRedisNetworkServer | func NewRedisNetworkServer(client *redis.Client, netID int) NetworkServer {
ns := &networkServer{
devices: device.NewRedisDeviceStore(client, "ns"),
prefixes: map[types.DevAddrPrefix][]string{},
}
ns.netID = [3]byte{byte(netID >> 16), byte(netID >> 8), byte(netID)}
return ns
} | go | func NewRedisNetworkServer(client *redis.Client, netID int) NetworkServer {
ns := &networkServer{
devices: device.NewRedisDeviceStore(client, "ns"),
prefixes: map[types.DevAddrPrefix][]string{},
}
ns.netID = [3]byte{byte(netID >> 16), byte(netID >> 8), byte(netID)}
return ns
} | [
"func",
"NewRedisNetworkServer",
"(",
"client",
"*",
"redis",
".",
"Client",
",",
"netID",
"int",
")",
"NetworkServer",
"{",
"ns",
":=",
"&",
"networkServer",
"{",
"devices",
":",
"device",
".",
"NewRedisDeviceStore",
"(",
"client",
",",
"\"",
"\"",
")",
"... | // NewRedisNetworkServer creates a new Redis-backed NetworkServer | [
"NewRedisNetworkServer",
"creates",
"a",
"new",
"Redis",
"-",
"backed",
"NetworkServer"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/networkserver/networkserver.go#L36-L43 |
23,021 | TheThingsNetwork/ttn | ttnctl/cmd/devices_info.go | cStyle | func cStyle(bytes []byte, msbf bool) string {
output := "{"
if !msbf {
bytes = reverse(bytes)
}
for i, b := range bytes {
if i != 0 {
output += ", "
}
output += fmt.Sprintf("0x%02X", b)
}
output += "}"
return output
} | go | func cStyle(bytes []byte, msbf bool) string {
output := "{"
if !msbf {
bytes = reverse(bytes)
}
for i, b := range bytes {
if i != 0 {
output += ", "
}
output += fmt.Sprintf("0x%02X", b)
}
output += "}"
return output
} | [
"func",
"cStyle",
"(",
"bytes",
"[",
"]",
"byte",
",",
"msbf",
"bool",
")",
"string",
"{",
"output",
":=",
"\"",
"\"",
"\n",
"if",
"!",
"msbf",
"{",
"bytes",
"=",
"reverse",
"(",
"bytes",
")",
"\n",
"}",
"\n",
"for",
"i",
",",
"b",
":=",
"range... | // cStyle prints the byte slice in C-Style | [
"cStyle",
"prints",
"the",
"byte",
"slice",
"in",
"C",
"-",
"Style"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/cmd/devices_info.go#L147-L160 |
23,022 | TheThingsNetwork/ttn | ttnctl/cmd/devices_info.go | reverse | func reverse(in []byte) (out []byte) {
for i := len(in) - 1; i >= 0; i-- {
out = append(out, in[i])
}
return
} | go | func reverse(in []byte) (out []byte) {
for i := len(in) - 1; i >= 0; i-- {
out = append(out, in[i])
}
return
} | [
"func",
"reverse",
"(",
"in",
"[",
"]",
"byte",
")",
"(",
"out",
"[",
"]",
"byte",
")",
"{",
"for",
"i",
":=",
"len",
"(",
"in",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"out",
"=",
"append",
"(",
"out",
",",
"in",
"[",
... | // reverse is used to convert between MSB-first and LSB-first | [
"reverse",
"is",
"used",
"to",
"convert",
"between",
"MSB",
"-",
"first",
"and",
"LSB",
"-",
"first"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/cmd/devices_info.go#L163-L168 |
23,023 | TheThingsNetwork/ttn | api/pool/pool.go | TLSConfig | func TLSConfig(serverName string) *tls.Config {
return &tls.Config{ServerName: serverName, RootCAs: RootCAs}
} | go | func TLSConfig(serverName string) *tls.Config {
return &tls.Config{ServerName: serverName, RootCAs: RootCAs}
} | [
"func",
"TLSConfig",
"(",
"serverName",
"string",
")",
"*",
"tls",
".",
"Config",
"{",
"return",
"&",
"tls",
".",
"Config",
"{",
"ServerName",
":",
"serverName",
",",
"RootCAs",
":",
"RootCAs",
"}",
"\n",
"}"
] | // TLSConfig that will be used when dialing securely without supplying TransportCredentials | [
"TLSConfig",
"that",
"will",
"be",
"used",
"when",
"dialing",
"securely",
"without",
"supplying",
"TransportCredentials"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/api/pool/pool.go#L37-L39 |
23,024 | TheThingsNetwork/ttn | api/pool/pool.go | KeepAliveDialer | func KeepAliveDialer(addr string, timeout time.Duration) (net.Conn, error) {
return (&net.Dialer{Timeout: timeout, KeepAlive: 10 * time.Second}).Dial("tcp", addr)
} | go | func KeepAliveDialer(addr string, timeout time.Duration) (net.Conn, error) {
return (&net.Dialer{Timeout: timeout, KeepAlive: 10 * time.Second}).Dial("tcp", addr)
} | [
"func",
"KeepAliveDialer",
"(",
"addr",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"return",
"(",
"&",
"net",
".",
"Dialer",
"{",
"Timeout",
":",
"timeout",
",",
"KeepAlive",
":",
"10",
"*... | // KeepAliveDialer is a dialer that adds a 10 second TCP KeepAlive | [
"KeepAliveDialer",
"is",
"a",
"dialer",
"that",
"adds",
"a",
"10",
"second",
"TCP",
"KeepAlive"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/api/pool/pool.go#L69-L71 |
23,025 | TheThingsNetwork/ttn | api/pool/pool.go | NewPool | func NewPool(ctx context.Context, dialOptions ...grpc.DialOption) *Pool {
return &Pool{
bgCtx: ctx,
dialOptions: dialOptions,
conns: make(map[string]*conn),
}
} | go | func NewPool(ctx context.Context, dialOptions ...grpc.DialOption) *Pool {
return &Pool{
bgCtx: ctx,
dialOptions: dialOptions,
conns: make(map[string]*conn),
}
} | [
"func",
"NewPool",
"(",
"ctx",
"context",
".",
"Context",
",",
"dialOptions",
"...",
"grpc",
".",
"DialOption",
")",
"*",
"Pool",
"{",
"return",
"&",
"Pool",
"{",
"bgCtx",
":",
"ctx",
",",
"dialOptions",
":",
"dialOptions",
",",
"conns",
":",
"make",
"... | // NewPool returns a new connection pool that uses the given DialOptions | [
"NewPool",
"returns",
"a",
"new",
"connection",
"pool",
"that",
"uses",
"the",
"given",
"DialOptions"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/api/pool/pool.go#L94-L100 |
23,026 | TheThingsNetwork/ttn | api/pool/pool.go | AddDialOption | func (p *Pool) AddDialOption(opts ...grpc.DialOption) {
p.dialOptions = append(p.dialOptions, opts...)
} | go | func (p *Pool) AddDialOption(opts ...grpc.DialOption) {
p.dialOptions = append(p.dialOptions, opts...)
} | [
"func",
"(",
"p",
"*",
"Pool",
")",
"AddDialOption",
"(",
"opts",
"...",
"grpc",
".",
"DialOption",
")",
"{",
"p",
".",
"dialOptions",
"=",
"append",
"(",
"p",
".",
"dialOptions",
",",
"opts",
"...",
")",
"\n",
"}"
] | // AddDialOption adds DialOption for the pool. Only new connections will use these new DialOptions | [
"AddDialOption",
"adds",
"DialOption",
"for",
"the",
"pool",
".",
"Only",
"new",
"connections",
"will",
"use",
"these",
"new",
"DialOptions"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/api/pool/pool.go#L108-L110 |
23,027 | TheThingsNetwork/ttn | api/pool/pool.go | Close | func (p *Pool) Close(target ...string) {
p.mu.Lock()
defer p.mu.Unlock()
if len(target) == 0 {
for target := range p.conns {
p.closeTarget(target)
}
} else {
for _, target := range target {
p.closeTarget(target)
}
}
} | go | func (p *Pool) Close(target ...string) {
p.mu.Lock()
defer p.mu.Unlock()
if len(target) == 0 {
for target := range p.conns {
p.closeTarget(target)
}
} else {
for _, target := range target {
p.closeTarget(target)
}
}
} | [
"func",
"(",
"p",
"*",
"Pool",
")",
"Close",
"(",
"target",
"...",
"string",
")",
"{",
"p",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"len",
"(",
"target",
")",
"==",
"0",
"{",
"fo... | // Close connections. If no target names supplied, just closes all. | [
"Close",
"connections",
".",
"If",
"no",
"target",
"names",
"supplied",
"just",
"closes",
"all",
"."
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/api/pool/pool.go#L113-L125 |
23,028 | TheThingsNetwork/ttn | api/pool/pool.go | CloseConn | func (p *Pool) CloseConn(conn *grpc.ClientConn) {
p.mu.Lock()
defer p.mu.Unlock()
for target, c := range p.conns {
if c.conn == conn {
p.closeTarget(target)
break
}
}
return
} | go | func (p *Pool) CloseConn(conn *grpc.ClientConn) {
p.mu.Lock()
defer p.mu.Unlock()
for target, c := range p.conns {
if c.conn == conn {
p.closeTarget(target)
break
}
}
return
} | [
"func",
"(",
"p",
"*",
"Pool",
")",
"CloseConn",
"(",
"conn",
"*",
"grpc",
".",
"ClientConn",
")",
"{",
"p",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"for",
"target",
",",
"c",
":=",
"ran... | // CloseConn closes a connection. | [
"CloseConn",
"closes",
"a",
"connection",
"."
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/api/pool/pool.go#L138-L148 |
23,029 | TheThingsNetwork/ttn | core/types/access_keys.go | HasRight | func (k *AccessKey) HasRight(right Right) bool {
for _, r := range k.Rights {
if r == right {
return true
}
}
return false
} | go | func (k *AccessKey) HasRight(right Right) bool {
for _, r := range k.Rights {
if r == right {
return true
}
}
return false
} | [
"func",
"(",
"k",
"*",
"AccessKey",
")",
"HasRight",
"(",
"right",
"Right",
")",
"bool",
"{",
"for",
"_",
",",
"r",
":=",
"range",
"k",
".",
"Rights",
"{",
"if",
"r",
"==",
"right",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"... | // HasRight checks if an AccessKey has a certain right | [
"HasRight",
"checks",
"if",
"an",
"AccessKey",
"has",
"a",
"certain",
"right"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/types/access_keys.go#L23-L30 |
23,030 | TheThingsNetwork/ttn | core/discovery/announcement/announcement.go | MetadataFromProto | func MetadataFromProto(proto *pb.Metadata) Metadata {
if euiBytes := proto.GetAppEUI(); euiBytes != nil {
eui := new(types.AppEUI)
if err := eui.Unmarshal(euiBytes); err != nil {
return nil
}
return AppEUIMetadata{*eui}
}
if appID := proto.GetAppID(); appID != "" {
return AppIDMetadata{appID}
}
if pre... | go | func MetadataFromProto(proto *pb.Metadata) Metadata {
if euiBytes := proto.GetAppEUI(); euiBytes != nil {
eui := new(types.AppEUI)
if err := eui.Unmarshal(euiBytes); err != nil {
return nil
}
return AppEUIMetadata{*eui}
}
if appID := proto.GetAppID(); appID != "" {
return AppIDMetadata{appID}
}
if pre... | [
"func",
"MetadataFromProto",
"(",
"proto",
"*",
"pb",
".",
"Metadata",
")",
"Metadata",
"{",
"if",
"euiBytes",
":=",
"proto",
".",
"GetAppEUI",
"(",
")",
";",
"euiBytes",
"!=",
"nil",
"{",
"eui",
":=",
"new",
"(",
"types",
".",
"AppEUI",
")",
"\n",
"... | // MetadataFromProto converts a protocol buffer metadata to a Metadata | [
"MetadataFromProto",
"converts",
"a",
"protocol",
"buffer",
"metadata",
"to",
"a",
"Metadata"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/discovery/announcement/announcement.go#L103-L125 |
23,031 | TheThingsNetwork/ttn | core/discovery/announcement/announcement.go | MetadataFromString | func MetadataFromString(str string) Metadata {
meta := strings.SplitAfterN(str, " ", 2)
key := strings.TrimSpace(meta[0])
value := meta[1]
switch key {
case "AppEUI":
var appEUI types.AppEUI
appEUI.UnmarshalText([]byte(value))
return AppEUIMetadata{appEUI}
case "AppID":
return AppIDMetadata{value}
case "... | go | func MetadataFromString(str string) Metadata {
meta := strings.SplitAfterN(str, " ", 2)
key := strings.TrimSpace(meta[0])
value := meta[1]
switch key {
case "AppEUI":
var appEUI types.AppEUI
appEUI.UnmarshalText([]byte(value))
return AppEUIMetadata{appEUI}
case "AppID":
return AppIDMetadata{value}
case "... | [
"func",
"MetadataFromString",
"(",
"str",
"string",
")",
"Metadata",
"{",
"meta",
":=",
"strings",
".",
"SplitAfterN",
"(",
"str",
",",
"\"",
"\"",
",",
"2",
")",
"\n",
"key",
":=",
"strings",
".",
"TrimSpace",
"(",
"meta",
"[",
"0",
"]",
")",
"\n",
... | // MetadataFromString converts a string to a Metadata | [
"MetadataFromString",
"converts",
"a",
"string",
"to",
"a",
"Metadata"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/discovery/announcement/announcement.go#L128-L149 |
23,032 | TheThingsNetwork/ttn | core/discovery/announcement/announcement.go | ToProto | func (a Announcement) ToProto() *pb.Announcement {
metadata := make([]*pb.Metadata, 0, len(a.Metadata))
for _, meta := range a.Metadata {
metadata = append(metadata, meta.ToProto())
}
return &pb.Announcement{
ID: a.ID,
ServiceName: a.ServiceName,
ServiceVersion: a.ServiceVersion,
Descriptio... | go | func (a Announcement) ToProto() *pb.Announcement {
metadata := make([]*pb.Metadata, 0, len(a.Metadata))
for _, meta := range a.Metadata {
metadata = append(metadata, meta.ToProto())
}
return &pb.Announcement{
ID: a.ID,
ServiceName: a.ServiceName,
ServiceVersion: a.ServiceVersion,
Descriptio... | [
"func",
"(",
"a",
"Announcement",
")",
"ToProto",
"(",
")",
"*",
"pb",
".",
"Announcement",
"{",
"metadata",
":=",
"make",
"(",
"[",
"]",
"*",
"pb",
".",
"Metadata",
",",
"0",
",",
"len",
"(",
"a",
".",
"Metadata",
")",
")",
"\n",
"for",
"_",
"... | // ToProto converts the Announcement to a protobuf Announcement | [
"ToProto",
"converts",
"the",
"Announcement",
"to",
"a",
"protobuf",
"Announcement"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/discovery/announcement/announcement.go#L210-L230 |
23,033 | TheThingsNetwork/ttn | utils/otaa/session_keys.go | CalculateSessionKeys | func CalculateSessionKeys(appKey types.AppKey, appNonce [3]byte, netID [3]byte, devNonce [2]byte) (appSKey types.AppSKey, nwkSKey types.NwkSKey, err error) {
buf := make([]byte, 16)
copy(buf[1:4], reverse(appNonce[:]))
copy(buf[4:7], reverse(netID[:]))
copy(buf[7:9], reverse(devNonce[:]))
block, _ := aes.NewCiph... | go | func CalculateSessionKeys(appKey types.AppKey, appNonce [3]byte, netID [3]byte, devNonce [2]byte) (appSKey types.AppSKey, nwkSKey types.NwkSKey, err error) {
buf := make([]byte, 16)
copy(buf[1:4], reverse(appNonce[:]))
copy(buf[4:7], reverse(netID[:]))
copy(buf[7:9], reverse(devNonce[:]))
block, _ := aes.NewCiph... | [
"func",
"CalculateSessionKeys",
"(",
"appKey",
"types",
".",
"AppKey",
",",
"appNonce",
"[",
"3",
"]",
"byte",
",",
"netID",
"[",
"3",
"]",
"byte",
",",
"devNonce",
"[",
"2",
"]",
"byte",
")",
"(",
"appSKey",
"types",
".",
"AppSKey",
",",
"nwkSKey",
... | // CalculateSessionKeys calculates the AppSKey and NwkSKey
// All arguments are MSB-first | [
"CalculateSessionKeys",
"calculates",
"the",
"AppSKey",
"and",
"NwkSKey",
"All",
"arguments",
"are",
"MSB",
"-",
"first"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/otaa/session_keys.go#L14-L29 |
23,034 | TheThingsNetwork/ttn | core/handler/convert_fields.go | ConvertFieldsUp | func (h *handler) ConvertFieldsUp(ctx ttnlog.Interface, _ *pb_broker.DeduplicatedUplinkMessage, appUp *types.UplinkMessage, dev *device.Device) error {
// Find Application
app, err := h.applications.Get(appUp.AppID)
if err != nil {
return nil // Do not process if application not found
}
var decoder PayloadDecod... | go | func (h *handler) ConvertFieldsUp(ctx ttnlog.Interface, _ *pb_broker.DeduplicatedUplinkMessage, appUp *types.UplinkMessage, dev *device.Device) error {
// Find Application
app, err := h.applications.Get(appUp.AppID)
if err != nil {
return nil // Do not process if application not found
}
var decoder PayloadDecod... | [
"func",
"(",
"h",
"*",
"handler",
")",
"ConvertFieldsUp",
"(",
"ctx",
"ttnlog",
".",
"Interface",
",",
"_",
"*",
"pb_broker",
".",
"DeduplicatedUplinkMessage",
",",
"appUp",
"*",
"types",
".",
"UplinkMessage",
",",
"dev",
"*",
"device",
".",
"Device",
")",... | // ConvertFieldsUp converts the payload to fields using the application's payload formatter | [
"ConvertFieldsUp",
"converts",
"the",
"payload",
"to",
"fields",
"using",
"the",
"application",
"s",
"payload",
"formatter"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/convert_fields.go#L34-L95 |
23,035 | TheThingsNetwork/ttn | core/handler/convert_fields.go | ConvertFieldsDown | func (h *handler) ConvertFieldsDown(ctx ttnlog.Interface, appDown *types.DownlinkMessage, ttnDown *pb_broker.DownlinkMessage, _ *device.Device) error {
if appDown.PayloadFields == nil || len(appDown.PayloadFields) == 0 {
return nil
}
if appDown.PayloadRaw != nil {
return errors.NewErrInvalidArgument("Downlink",... | go | func (h *handler) ConvertFieldsDown(ctx ttnlog.Interface, appDown *types.DownlinkMessage, ttnDown *pb_broker.DownlinkMessage, _ *device.Device) error {
if appDown.PayloadFields == nil || len(appDown.PayloadFields) == 0 {
return nil
}
if appDown.PayloadRaw != nil {
return errors.NewErrInvalidArgument("Downlink",... | [
"func",
"(",
"h",
"*",
"handler",
")",
"ConvertFieldsDown",
"(",
"ctx",
"ttnlog",
".",
"Interface",
",",
"appDown",
"*",
"types",
".",
"DownlinkMessage",
",",
"ttnDown",
"*",
"pb_broker",
".",
"DownlinkMessage",
",",
"_",
"*",
"device",
".",
"Device",
")",... | // ConvertFieldsDown converts the fields into a payload | [
"ConvertFieldsDown",
"converts",
"the",
"fields",
"into",
"a",
"payload"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/convert_fields.go#L98-L133 |
23,036 | TheThingsNetwork/ttn | mqtt/activations.go | PublishActivation | func (c *DefaultClient) PublishActivation(activation types.Activation) Token {
appID := activation.AppID
devID := activation.DevID
return c.PublishDeviceEvent(appID, devID, types.ActivationEvent, activation)
} | go | func (c *DefaultClient) PublishActivation(activation types.Activation) Token {
appID := activation.AppID
devID := activation.DevID
return c.PublishDeviceEvent(appID, devID, types.ActivationEvent, activation)
} | [
"func",
"(",
"c",
"*",
"DefaultClient",
")",
"PublishActivation",
"(",
"activation",
"types",
".",
"Activation",
")",
"Token",
"{",
"appID",
":=",
"activation",
".",
"AppID",
"\n",
"devID",
":=",
"activation",
".",
"DevID",
"\n",
"return",
"c",
".",
"Publi... | // PublishActivation publishes an activation | [
"PublishActivation",
"publishes",
"an",
"activation"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/mqtt/activations.go#L16-L20 |
23,037 | TheThingsNetwork/ttn | mqtt/activations.go | SubscribeDeviceActivations | func (c *DefaultClient) SubscribeDeviceActivations(appID string, devID string, handler ActivationHandler) Token {
return c.SubscribeDeviceEvents(appID, devID, types.ActivationEvent, func(_ Client, appID string, devID string, _ types.EventType, payload []byte) {
activation := types.Activation{}
if err := json.Unmar... | go | func (c *DefaultClient) SubscribeDeviceActivations(appID string, devID string, handler ActivationHandler) Token {
return c.SubscribeDeviceEvents(appID, devID, types.ActivationEvent, func(_ Client, appID string, devID string, _ types.EventType, payload []byte) {
activation := types.Activation{}
if err := json.Unmar... | [
"func",
"(",
"c",
"*",
"DefaultClient",
")",
"SubscribeDeviceActivations",
"(",
"appID",
"string",
",",
"devID",
"string",
",",
"handler",
"ActivationHandler",
")",
"Token",
"{",
"return",
"c",
".",
"SubscribeDeviceEvents",
"(",
"appID",
",",
"devID",
",",
"ty... | // SubscribeDeviceActivations subscribes to all activations for the given application and device | [
"SubscribeDeviceActivations",
"subscribes",
"to",
"all",
"activations",
"for",
"the",
"given",
"application",
"and",
"device"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/mqtt/activations.go#L23-L35 |
23,038 | TheThingsNetwork/ttn | mqtt/activations.go | SubscribeAppActivations | func (c *DefaultClient) SubscribeAppActivations(appID string, handler ActivationHandler) Token {
return c.SubscribeDeviceActivations(appID, "", handler)
} | go | func (c *DefaultClient) SubscribeAppActivations(appID string, handler ActivationHandler) Token {
return c.SubscribeDeviceActivations(appID, "", handler)
} | [
"func",
"(",
"c",
"*",
"DefaultClient",
")",
"SubscribeAppActivations",
"(",
"appID",
"string",
",",
"handler",
"ActivationHandler",
")",
"Token",
"{",
"return",
"c",
".",
"SubscribeDeviceActivations",
"(",
"appID",
",",
"\"",
"\"",
",",
"handler",
")",
"\n",
... | // SubscribeAppActivations subscribes to all activations for the given application | [
"SubscribeAppActivations",
"subscribes",
"to",
"all",
"activations",
"for",
"the",
"given",
"application"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/mqtt/activations.go#L38-L40 |
23,039 | TheThingsNetwork/ttn | mqtt/activations.go | UnsubscribeDeviceActivations | func (c *DefaultClient) UnsubscribeDeviceActivations(appID string, devID string) Token {
return c.UnsubscribeDeviceEvents(appID, devID, types.ActivationEvent)
} | go | func (c *DefaultClient) UnsubscribeDeviceActivations(appID string, devID string) Token {
return c.UnsubscribeDeviceEvents(appID, devID, types.ActivationEvent)
} | [
"func",
"(",
"c",
"*",
"DefaultClient",
")",
"UnsubscribeDeviceActivations",
"(",
"appID",
"string",
",",
"devID",
"string",
")",
"Token",
"{",
"return",
"c",
".",
"UnsubscribeDeviceEvents",
"(",
"appID",
",",
"devID",
",",
"types",
".",
"ActivationEvent",
")"... | // UnsubscribeDeviceActivations unsubscribes from the activations for the given application and device | [
"UnsubscribeDeviceActivations",
"unsubscribes",
"from",
"the",
"activations",
"for",
"the",
"given",
"application",
"and",
"device"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/mqtt/activations.go#L48-L50 |
23,040 | TheThingsNetwork/ttn | mqtt/activations.go | UnsubscribeAppActivations | func (c *DefaultClient) UnsubscribeAppActivations(appID string) Token {
return c.UnsubscribeDeviceEvents(appID, "", types.ActivationEvent)
} | go | func (c *DefaultClient) UnsubscribeAppActivations(appID string) Token {
return c.UnsubscribeDeviceEvents(appID, "", types.ActivationEvent)
} | [
"func",
"(",
"c",
"*",
"DefaultClient",
")",
"UnsubscribeAppActivations",
"(",
"appID",
"string",
")",
"Token",
"{",
"return",
"c",
".",
"UnsubscribeDeviceEvents",
"(",
"appID",
",",
"\"",
"\"",
",",
"types",
".",
"ActivationEvent",
")",
"\n",
"}"
] | // UnsubscribeAppActivations unsubscribes from the activations for the given application | [
"UnsubscribeAppActivations",
"unsubscribes",
"from",
"the",
"activations",
"for",
"the",
"given",
"application"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/mqtt/activations.go#L53-L55 |
23,041 | TheThingsNetwork/ttn | core/types/event.go | Data | func (e EventType) Data() interface{} {
switch e {
case UplinkErrorEvent:
return new(ErrorEventData)
case DownlinkScheduledEvent, DownlinkSentEvent, DownlinkErrorEvent, DownlinkAckEvent:
return new(DownlinkEventData)
case ActivationEvent, ActivationErrorEvent:
return new(ActivationEventData)
case CreateEvent... | go | func (e EventType) Data() interface{} {
switch e {
case UplinkErrorEvent:
return new(ErrorEventData)
case DownlinkScheduledEvent, DownlinkSentEvent, DownlinkErrorEvent, DownlinkAckEvent:
return new(DownlinkEventData)
case ActivationEvent, ActivationErrorEvent:
return new(ActivationEventData)
case CreateEvent... | [
"func",
"(",
"e",
"EventType",
")",
"Data",
"(",
")",
"interface",
"{",
"}",
"{",
"switch",
"e",
"{",
"case",
"UplinkErrorEvent",
":",
"return",
"new",
"(",
"ErrorEventData",
")",
"\n",
"case",
"DownlinkScheduledEvent",
",",
"DownlinkSentEvent",
",",
"Downli... | // Data type of the event payload, returns nil if no payload | [
"Data",
"type",
"of",
"the",
"event",
"payload",
"returns",
"nil",
"if",
"no",
"payload"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/types/event.go#L29-L41 |
23,042 | TheThingsNetwork/ttn | core/types/data_rate.go | ParseDataRate | func ParseDataRate(input string) (datr *DataRate, err error) {
re := regexp.MustCompile("SF(7|8|9|10|11|12)BW(125|250|500)")
matches := re.FindStringSubmatch(input)
if len(matches) != 3 {
return nil, errors.New("ttn/core: Invalid DataRate")
}
sf, _ := strconv.ParseUint(matches[1], 10, 64)
bw, _ := strconv.Pars... | go | func ParseDataRate(input string) (datr *DataRate, err error) {
re := regexp.MustCompile("SF(7|8|9|10|11|12)BW(125|250|500)")
matches := re.FindStringSubmatch(input)
if len(matches) != 3 {
return nil, errors.New("ttn/core: Invalid DataRate")
}
sf, _ := strconv.ParseUint(matches[1], 10, 64)
bw, _ := strconv.Pars... | [
"func",
"ParseDataRate",
"(",
"input",
"string",
")",
"(",
"datr",
"*",
"DataRate",
",",
"err",
"error",
")",
"{",
"re",
":=",
"regexp",
".",
"MustCompile",
"(",
"\"",
"\"",
")",
"\n",
"matches",
":=",
"re",
".",
"FindStringSubmatch",
"(",
"input",
")"... | // ParseDataRate parses a 32-bit hex-encoded string to a Devdatr | [
"ParseDataRate",
"parses",
"a",
"32",
"-",
"bit",
"hex",
"-",
"encoded",
"string",
"to",
"a",
"Devdatr"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/types/data_rate.go#L22-L36 |
23,043 | TheThingsNetwork/ttn | core/router/downlink.go | buildDownlinkOption | func (r *router) buildDownlinkOption(gatewayID string, band band.FrequencyPlan) *pb_broker.DownlinkOption {
dataRate, _ := types.ConvertDataRate(band.DataRates[band.RX2DataRate])
return &pb_broker.DownlinkOption{
GatewayID: gatewayID,
ProtocolConfiguration: pb_protocol.TxConfiguration{Protocol: &pb_protocol.TxCon... | go | func (r *router) buildDownlinkOption(gatewayID string, band band.FrequencyPlan) *pb_broker.DownlinkOption {
dataRate, _ := types.ConvertDataRate(band.DataRates[band.RX2DataRate])
return &pb_broker.DownlinkOption{
GatewayID: gatewayID,
ProtocolConfiguration: pb_protocol.TxConfiguration{Protocol: &pb_protocol.TxCon... | [
"func",
"(",
"r",
"*",
"router",
")",
"buildDownlinkOption",
"(",
"gatewayID",
"string",
",",
"band",
"band",
".",
"FrequencyPlan",
")",
"*",
"pb_broker",
".",
"DownlinkOption",
"{",
"dataRate",
",",
"_",
":=",
"types",
".",
"ConvertDataRate",
"(",
"band",
... | // buildDownlinkOption builds a DownlinkOption with default values | [
"buildDownlinkOption",
"builds",
"a",
"DownlinkOption",
"with",
"default",
"values"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/router/downlink.go#L110-L126 |
23,044 | TheThingsNetwork/ttn | core/handler/device/downlink_queue.go | Length | func (s *RedisDownlinkQueue) Length() (int, error) {
return s.queues.Length(s.key())
} | go | func (s *RedisDownlinkQueue) Length() (int, error) {
return s.queues.Length(s.key())
} | [
"func",
"(",
"s",
"*",
"RedisDownlinkQueue",
")",
"Length",
"(",
")",
"(",
"int",
",",
"error",
")",
"{",
"return",
"s",
".",
"queues",
".",
"Length",
"(",
"s",
".",
"key",
"(",
")",
")",
"\n",
"}"
] | // Length of the downlink queue | [
"Length",
"of",
"the",
"downlink",
"queue"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/device/downlink_queue.go#L35-L37 |
23,045 | TheThingsNetwork/ttn | core/handler/device/downlink_queue.go | Next | func (s *RedisDownlinkQueue) Next() (*types.DownlinkMessage, error) {
qd, err := s.queues.Next(s.key())
if err != nil {
return nil, err
}
if qd == "" {
return nil, nil
}
msg := new(types.DownlinkMessage)
if err := json.Unmarshal([]byte(qd), msg); err != nil {
return nil, err
}
return msg, nil
} | go | func (s *RedisDownlinkQueue) Next() (*types.DownlinkMessage, error) {
qd, err := s.queues.Next(s.key())
if err != nil {
return nil, err
}
if qd == "" {
return nil, nil
}
msg := new(types.DownlinkMessage)
if err := json.Unmarshal([]byte(qd), msg); err != nil {
return nil, err
}
return msg, nil
} | [
"func",
"(",
"s",
"*",
"RedisDownlinkQueue",
")",
"Next",
"(",
")",
"(",
"*",
"types",
".",
"DownlinkMessage",
",",
"error",
")",
"{",
"qd",
",",
"err",
":=",
"s",
".",
"queues",
".",
"Next",
"(",
"s",
".",
"key",
"(",
")",
")",
"\n",
"if",
"er... | // Next item in the downlink queue | [
"Next",
"item",
"in",
"the",
"downlink",
"queue"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/device/downlink_queue.go#L40-L53 |
23,046 | TheThingsNetwork/ttn | core/handler/device/downlink_queue.go | Replace | func (s *RedisDownlinkQueue) Replace(msg *types.DownlinkMessage) error {
if err := s.queues.Delete(s.key()); err != nil {
return err
}
return s.PushFirst(msg)
} | go | func (s *RedisDownlinkQueue) Replace(msg *types.DownlinkMessage) error {
if err := s.queues.Delete(s.key()); err != nil {
return err
}
return s.PushFirst(msg)
} | [
"func",
"(",
"s",
"*",
"RedisDownlinkQueue",
")",
"Replace",
"(",
"msg",
"*",
"types",
".",
"DownlinkMessage",
")",
"error",
"{",
"if",
"err",
":=",
"s",
".",
"queues",
".",
"Delete",
"(",
"s",
".",
"key",
"(",
")",
")",
";",
"err",
"!=",
"nil",
... | // Replace the downlink queue with msg | [
"Replace",
"the",
"downlink",
"queue",
"with",
"msg"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/device/downlink_queue.go#L56-L61 |
23,047 | TheThingsNetwork/ttn | core/handler/device/downlink_queue.go | PushFirst | func (s *RedisDownlinkQueue) PushFirst(msg *types.DownlinkMessage) error {
qd, err := json.Marshal(msg)
if err != nil {
return err
}
return s.queues.AddFront(s.key(), string(qd))
} | go | func (s *RedisDownlinkQueue) PushFirst(msg *types.DownlinkMessage) error {
qd, err := json.Marshal(msg)
if err != nil {
return err
}
return s.queues.AddFront(s.key(), string(qd))
} | [
"func",
"(",
"s",
"*",
"RedisDownlinkQueue",
")",
"PushFirst",
"(",
"msg",
"*",
"types",
".",
"DownlinkMessage",
")",
"error",
"{",
"qd",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"msg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",... | // PushFirst message to the downlink queue | [
"PushFirst",
"message",
"to",
"the",
"downlink",
"queue"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/device/downlink_queue.go#L64-L70 |
23,048 | TheThingsNetwork/ttn | core/handler/device/downlink_queue.go | PushLast | func (s *RedisDownlinkQueue) PushLast(msg *types.DownlinkMessage) error {
qd, err := json.Marshal(msg)
if err != nil {
return err
}
return s.queues.AddEnd(s.key(), string(qd))
} | go | func (s *RedisDownlinkQueue) PushLast(msg *types.DownlinkMessage) error {
qd, err := json.Marshal(msg)
if err != nil {
return err
}
return s.queues.AddEnd(s.key(), string(qd))
} | [
"func",
"(",
"s",
"*",
"RedisDownlinkQueue",
")",
"PushLast",
"(",
"msg",
"*",
"types",
".",
"DownlinkMessage",
")",
"error",
"{",
"qd",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"msg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
... | // PushLast message to the downlink queue | [
"PushLast",
"message",
"to",
"the",
"downlink",
"queue"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/device/downlink_queue.go#L73-L79 |
23,049 | TheThingsNetwork/ttn | core/handler/convert_fields_custom.go | decode | func (f *CustomUplinkFunctions) decode(payload []byte, port uint8) (map[string]interface{}, error) {
if f.Decoder == "" {
return nil, nil
}
env := map[string]interface{}{
"payload": payload,
"port": port,
}
code := fmt.Sprintf(`
%s;
Decoder(payload.slice(0), port);
`, f.Decoder)
value, err := func... | go | func (f *CustomUplinkFunctions) decode(payload []byte, port uint8) (map[string]interface{}, error) {
if f.Decoder == "" {
return nil, nil
}
env := map[string]interface{}{
"payload": payload,
"port": port,
}
code := fmt.Sprintf(`
%s;
Decoder(payload.slice(0), port);
`, f.Decoder)
value, err := func... | [
"func",
"(",
"f",
"*",
"CustomUplinkFunctions",
")",
"decode",
"(",
"payload",
"[",
"]",
"byte",
",",
"port",
"uint8",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
"f",
".",
"Decoder",
"==",
"\"",
"\"",
... | // decode decodes the payload using the Decoder function into a map | [
"decode",
"decodes",
"the",
"payload",
"using",
"the",
"Decoder",
"function",
"into",
"a",
"map"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/convert_fields_custom.go#L36-L60 |
23,050 | TheThingsNetwork/ttn | core/handler/convert_fields_custom.go | convert | func (f *CustomUplinkFunctions) convert(fields map[string]interface{}, port uint8) (map[string]interface{}, error) {
if f.Converter == "" {
return fields, nil
}
env := map[string]interface{}{
"fields": fields,
"port": port,
}
code := fmt.Sprintf(`
%s;
Converter(fields, port)
`, f.Converter)
value,... | go | func (f *CustomUplinkFunctions) convert(fields map[string]interface{}, port uint8) (map[string]interface{}, error) {
if f.Converter == "" {
return fields, nil
}
env := map[string]interface{}{
"fields": fields,
"port": port,
}
code := fmt.Sprintf(`
%s;
Converter(fields, port)
`, f.Converter)
value,... | [
"func",
"(",
"f",
"*",
"CustomUplinkFunctions",
")",
"convert",
"(",
"fields",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"port",
"uint8",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
"f",
".... | // convert converts the values in the specified map to a another map using the
// Converter function. If the Converter function is not set, this function
// returns the data as-is | [
"convert",
"converts",
"the",
"values",
"in",
"the",
"specified",
"map",
"to",
"a",
"another",
"map",
"using",
"the",
"Converter",
"function",
".",
"If",
"the",
"Converter",
"function",
"is",
"not",
"set",
"this",
"function",
"returns",
"the",
"data",
"as",
... | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/convert_fields_custom.go#L65-L91 |
23,051 | TheThingsNetwork/ttn | core/handler/convert_fields_custom.go | validate | func (f *CustomUplinkFunctions) validate(fields map[string]interface{}, port uint8) (bool, error) {
if f.Validator == "" {
return true, nil
}
env := map[string]interface{}{
"fields": fields,
"port": port,
}
code := fmt.Sprintf(`
%s;
Validator(fields, port)
`, f.Validator)
value, err := functions.Ru... | go | func (f *CustomUplinkFunctions) validate(fields map[string]interface{}, port uint8) (bool, error) {
if f.Validator == "" {
return true, nil
}
env := map[string]interface{}{
"fields": fields,
"port": port,
}
code := fmt.Sprintf(`
%s;
Validator(fields, port)
`, f.Validator)
value, err := functions.Ru... | [
"func",
"(",
"f",
"*",
"CustomUplinkFunctions",
")",
"validate",
"(",
"fields",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"port",
"uint8",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"f",
".",
"Validator",
"==",
"\"",
"\"",
"{",
"r... | // validate validates the values in the specified map using the Validator
// function. If the Validator function is not set, this function returns true | [
"validate",
"validates",
"the",
"values",
"in",
"the",
"specified",
"map",
"using",
"the",
"Validator",
"function",
".",
"If",
"the",
"Validator",
"function",
"is",
"not",
"set",
"this",
"function",
"returns",
"true"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/convert_fields_custom.go#L95-L119 |
23,052 | TheThingsNetwork/ttn | core/handler/convert_fields_custom.go | Decode | func (f *CustomUplinkFunctions) Decode(payload []byte, port uint8) (map[string]interface{}, bool, error) {
decoded, err := f.decode(payload, port)
if err != nil {
return nil, false, err
}
converted, err := f.convert(decoded, port)
if err != nil {
return nil, false, err
}
valid, err := f.validate(converted,... | go | func (f *CustomUplinkFunctions) Decode(payload []byte, port uint8) (map[string]interface{}, bool, error) {
decoded, err := f.decode(payload, port)
if err != nil {
return nil, false, err
}
converted, err := f.convert(decoded, port)
if err != nil {
return nil, false, err
}
valid, err := f.validate(converted,... | [
"func",
"(",
"f",
"*",
"CustomUplinkFunctions",
")",
"Decode",
"(",
"payload",
"[",
"]",
"byte",
",",
"port",
"uint8",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"bool",
",",
"error",
")",
"{",
"decoded",
",",
"err",
":=",
"f"... | // Decode decodes the specified payload, converts it and tests the validity | [
"Decode",
"decodes",
"the",
"specified",
"payload",
"converts",
"it",
"and",
"tests",
"the",
"validity"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/convert_fields_custom.go#L122-L135 |
23,053 | TheThingsNetwork/ttn | core/handler/convert_fields_custom.go | encode | func (f *CustomDownlinkFunctions) encode(payload map[string]interface{}, port uint8) ([]byte, error) {
if f.Encoder == "" {
return nil, errors.NewErrInvalidArgument("Downlink Payload", "fields supplied, but no Encoder function set")
}
env := map[string]interface{}{
"payload": payload,
"port": port,
}
cod... | go | func (f *CustomDownlinkFunctions) encode(payload map[string]interface{}, port uint8) ([]byte, error) {
if f.Encoder == "" {
return nil, errors.NewErrInvalidArgument("Downlink Payload", "fields supplied, but no Encoder function set")
}
env := map[string]interface{}{
"payload": payload,
"port": port,
}
cod... | [
"func",
"(",
"f",
"*",
"CustomDownlinkFunctions",
")",
"encode",
"(",
"payload",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"port",
"uint8",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"f",
".",
"Encoder",
"==",
"\"",
"\""... | // encode encodes the map into a byte slice using the encoder payload function
// If no encoder function is set, this function returns an array. | [
"encode",
"encodes",
"the",
"map",
"into",
"a",
"byte",
"slice",
"using",
"the",
"encoder",
"payload",
"function",
"If",
"no",
"encoder",
"function",
"is",
"set",
"this",
"function",
"returns",
"an",
"array",
"."
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/convert_fields_custom.go#L154-L229 |
23,054 | TheThingsNetwork/ttn | core/handler/convert_fields_custom.go | Encode | func (f *CustomDownlinkFunctions) Encode(payload map[string]interface{}, port uint8) ([]byte, bool, error) {
encoded, err := f.encode(payload, port)
if err != nil {
return nil, false, err
}
return encoded, true, nil
} | go | func (f *CustomDownlinkFunctions) Encode(payload map[string]interface{}, port uint8) ([]byte, bool, error) {
encoded, err := f.encode(payload, port)
if err != nil {
return nil, false, err
}
return encoded, true, nil
} | [
"func",
"(",
"f",
"*",
"CustomDownlinkFunctions",
")",
"Encode",
"(",
"payload",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"port",
"uint8",
")",
"(",
"[",
"]",
"byte",
",",
"bool",
",",
"error",
")",
"{",
"encoded",
",",
"err",
":=",
"... | // Encode encodes the specified field, converts it into a valid payload | [
"Encode",
"encodes",
"the",
"specified",
"field",
"converts",
"it",
"into",
"a",
"valid",
"payload"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/convert_fields_custom.go#L232-L239 |
23,055 | TheThingsNetwork/ttn | ttnctl/util/account.go | getOAuth | func getOAuth() *oauth.Config {
return oauth.OAuth(viper.GetString("auth-server"), &oauth.Client{
ID: "ttnctl",
Secret: "ttnctl",
ExtraHeaders: map[string]string{
"User-Agent": GetUserAgent(),
},
})
} | go | func getOAuth() *oauth.Config {
return oauth.OAuth(viper.GetString("auth-server"), &oauth.Client{
ID: "ttnctl",
Secret: "ttnctl",
ExtraHeaders: map[string]string{
"User-Agent": GetUserAgent(),
},
})
} | [
"func",
"getOAuth",
"(",
")",
"*",
"oauth",
".",
"Config",
"{",
"return",
"oauth",
".",
"OAuth",
"(",
"viper",
".",
"GetString",
"(",
"\"",
"\"",
")",
",",
"&",
"oauth",
".",
"Client",
"{",
"ID",
":",
"\"",
"\"",
",",
"Secret",
":",
"\"",
"\"",
... | // getOAuth gets the OAuth client | [
"getOAuth",
"gets",
"the",
"OAuth",
"client"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/account.go#L63-L71 |
23,056 | TheThingsNetwork/ttn | ttnctl/util/account.go | ForceRefreshToken | func ForceRefreshToken(ctx ttnlog.Interface) {
tokenSource := GetTokenSource(ctx).(*ttnctlTokenSource)
token, err := tokenSource.Token()
if err != nil {
ctx.WithError(err).Fatal("Could not get access token")
}
token.Expiry = time.Now().Add(-1 * time.Second)
tokenSource.source = oauth2.ReuseTokenSource(token, ge... | go | func ForceRefreshToken(ctx ttnlog.Interface) {
tokenSource := GetTokenSource(ctx).(*ttnctlTokenSource)
token, err := tokenSource.Token()
if err != nil {
ctx.WithError(err).Fatal("Could not get access token")
}
token.Expiry = time.Now().Add(-1 * time.Second)
tokenSource.source = oauth2.ReuseTokenSource(token, ge... | [
"func",
"ForceRefreshToken",
"(",
"ctx",
"ttnlog",
".",
"Interface",
")",
"{",
"tokenSource",
":=",
"GetTokenSource",
"(",
"ctx",
")",
".",
"(",
"*",
"ttnctlTokenSource",
")",
"\n",
"token",
",",
"err",
":=",
"tokenSource",
".",
"Token",
"(",
")",
"\n",
... | // ForceRefreshToken forces a refresh of the access token | [
"ForceRefreshToken",
"forces",
"a",
"refresh",
"of",
"the",
"access",
"token"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/account.go#L121-L130 |
23,057 | TheThingsNetwork/ttn | ttnctl/util/account.go | GetTokenSource | func GetTokenSource(ctx ttnlog.Interface) oauth2.TokenSource {
if tokenSource != nil {
return tokenSource
}
token := getStoredToken(ctx)
source := oauth2.ReuseTokenSource(token, getAccountServerTokenSource(token))
tokenSource = &ttnctlTokenSource{ctx, source}
return tokenSource
} | go | func GetTokenSource(ctx ttnlog.Interface) oauth2.TokenSource {
if tokenSource != nil {
return tokenSource
}
token := getStoredToken(ctx)
source := oauth2.ReuseTokenSource(token, getAccountServerTokenSource(token))
tokenSource = &ttnctlTokenSource{ctx, source}
return tokenSource
} | [
"func",
"GetTokenSource",
"(",
"ctx",
"ttnlog",
".",
"Interface",
")",
"oauth2",
".",
"TokenSource",
"{",
"if",
"tokenSource",
"!=",
"nil",
"{",
"return",
"tokenSource",
"\n",
"}",
"\n",
"token",
":=",
"getStoredToken",
"(",
"ctx",
")",
"\n",
"source",
":=... | // GetTokenSource builds a new oauth2.TokenSource that uses the ttnctl config to store the token | [
"GetTokenSource",
"builds",
"a",
"new",
"oauth2",
".",
"TokenSource",
"that",
"uses",
"the",
"ttnctl",
"config",
"to",
"store",
"the",
"token"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/account.go#L133-L141 |
23,058 | TheThingsNetwork/ttn | ttnctl/util/account.go | GetAccount | func GetAccount(ctx ttnlog.Interface) *account.Account {
token, err := GetTokenSource(ctx).Token()
if err != nil {
ctx.WithError(err).Fatal("Could not get access token")
}
server := viper.GetString("auth-server")
manager := GetTokenManager(token.AccessToken)
return account.NewWithManager(server, token.AccessT... | go | func GetAccount(ctx ttnlog.Interface) *account.Account {
token, err := GetTokenSource(ctx).Token()
if err != nil {
ctx.WithError(err).Fatal("Could not get access token")
}
server := viper.GetString("auth-server")
manager := GetTokenManager(token.AccessToken)
return account.NewWithManager(server, token.AccessT... | [
"func",
"GetAccount",
"(",
"ctx",
"ttnlog",
".",
"Interface",
")",
"*",
"account",
".",
"Account",
"{",
"token",
",",
"err",
":=",
"GetTokenSource",
"(",
"ctx",
")",
".",
"Token",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"ctx",
".",
"WithError"... | // GetAccount gets a new Account server client for ttnctl | [
"GetAccount",
"gets",
"a",
"new",
"Account",
"server",
"client",
"for",
"ttnctl"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/account.go#L149-L159 |
23,059 | TheThingsNetwork/ttn | ttnctl/util/account.go | Login | func Login(ctx ttnlog.Interface, code string) (*oauth2.Token, error) {
config := getOAuth()
token, err := config.Exchange(code)
if err != nil {
return nil, err
}
saveToken(ctx, token)
return token, nil
} | go | func Login(ctx ttnlog.Interface, code string) (*oauth2.Token, error) {
config := getOAuth()
token, err := config.Exchange(code)
if err != nil {
return nil, err
}
saveToken(ctx, token)
return token, nil
} | [
"func",
"Login",
"(",
"ctx",
"ttnlog",
".",
"Interface",
",",
"code",
"string",
")",
"(",
"*",
"oauth2",
".",
"Token",
",",
"error",
")",
"{",
"config",
":=",
"getOAuth",
"(",
")",
"\n",
"token",
",",
"err",
":=",
"config",
".",
"Exchange",
"(",
"c... | // Login does a login to the Account server with the given username and password | [
"Login",
"does",
"a",
"login",
"to",
"the",
"Account",
"server",
"with",
"the",
"given",
"username",
"and",
"password"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/account.go#L162-L170 |
23,060 | TheThingsNetwork/ttn | ttnctl/util/router.go | GetRouter | func GetRouter(ctx ttnlog.Interface) (*grpc.ClientConn, *routerclient.Client) {
ctx.Info("Discovering Router...")
dscConn, client := GetDiscovery(ctx)
defer dscConn.Close()
routerAnnouncement, err := client.Get(GetContext(ctx), &discovery.GetRequest{
ServiceName: "router",
ID: viper.GetString("router-i... | go | func GetRouter(ctx ttnlog.Interface) (*grpc.ClientConn, *routerclient.Client) {
ctx.Info("Discovering Router...")
dscConn, client := GetDiscovery(ctx)
defer dscConn.Close()
routerAnnouncement, err := client.Get(GetContext(ctx), &discovery.GetRequest{
ServiceName: "router",
ID: viper.GetString("router-i... | [
"func",
"GetRouter",
"(",
"ctx",
"ttnlog",
".",
"Interface",
")",
"(",
"*",
"grpc",
".",
"ClientConn",
",",
"*",
"routerclient",
".",
"Client",
")",
"{",
"ctx",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"dscConn",
",",
"client",
":=",
"GetDiscovery",
... | // GetRouter starts a connection with the router | [
"GetRouter",
"starts",
"a",
"connection",
"with",
"the",
"router"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/router.go#L17-L34 |
23,061 | TheThingsNetwork/ttn | ttnctl/util/router.go | GetRouterManager | func GetRouterManager(ctx ttnlog.Interface) (*grpc.ClientConn, router.RouterManagerClient) {
ctx.Info("Discovering Router...")
dscConn, client := GetDiscovery(ctx)
defer dscConn.Close()
routerAnnouncement, err := client.Get(GetContext(ctx), &discovery.GetRequest{
ServiceName: "router",
ID: viper.GetStr... | go | func GetRouterManager(ctx ttnlog.Interface) (*grpc.ClientConn, router.RouterManagerClient) {
ctx.Info("Discovering Router...")
dscConn, client := GetDiscovery(ctx)
defer dscConn.Close()
routerAnnouncement, err := client.Get(GetContext(ctx), &discovery.GetRequest{
ServiceName: "router",
ID: viper.GetStr... | [
"func",
"GetRouterManager",
"(",
"ctx",
"ttnlog",
".",
"Interface",
")",
"(",
"*",
"grpc",
".",
"ClientConn",
",",
"router",
".",
"RouterManagerClient",
")",
"{",
"ctx",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"dscConn",
",",
"client",
":=",
"GetDiscove... | // GetRouterManager starts a management connection with the router | [
"GetRouterManager",
"starts",
"a",
"management",
"connection",
"with",
"the",
"router"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/router.go#L37-L55 |
23,062 | TheThingsNetwork/ttn | utils/version/version.go | Selfupdate | func Selfupdate(ctx ttnlog.Interface, component string) {
if viper.GetString("gitBranch") == "unknown" {
ctx.Infof("You are not using an official %s build. Not proceeding with the update", component)
return
}
info, err := GetLatestInfo()
if err != nil {
ctx.WithError(err).Fatal("Could not get version informa... | go | func Selfupdate(ctx ttnlog.Interface, component string) {
if viper.GetString("gitBranch") == "unknown" {
ctx.Infof("You are not using an official %s build. Not proceeding with the update", component)
return
}
info, err := GetLatestInfo()
if err != nil {
ctx.WithError(err).Fatal("Could not get version informa... | [
"func",
"Selfupdate",
"(",
"ctx",
"ttnlog",
".",
"Interface",
",",
"component",
"string",
")",
"{",
"if",
"viper",
".",
"GetString",
"(",
"\"",
"\"",
")",
"==",
"\"",
"\"",
"{",
"ctx",
".",
"Infof",
"(",
"\"",
"\"",
",",
"component",
")",
"\n",
"re... | // Selfupdate runs a self-update for the current binary | [
"Selfupdate",
"runs",
"a",
"self",
"-",
"update",
"for",
"the",
"current",
"binary"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/version/version.go#L120-L175 |
23,063 | TheThingsNetwork/ttn | api/ratelimit/ratelimit.go | NewRegistry | func NewRegistry(rate int, per time.Duration) *Registry {
return &Registry{
rate: rate,
per: per,
entities: make(map[string]*ratelimit.Bucket),
}
} | go | func NewRegistry(rate int, per time.Duration) *Registry {
return &Registry{
rate: rate,
per: per,
entities: make(map[string]*ratelimit.Bucket),
}
} | [
"func",
"NewRegistry",
"(",
"rate",
"int",
",",
"per",
"time",
".",
"Duration",
")",
"*",
"Registry",
"{",
"return",
"&",
"Registry",
"{",
"rate",
":",
"rate",
",",
"per",
":",
"per",
",",
"entities",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*... | // NewRegistry returns a new Registry for rate limiting | [
"NewRegistry",
"returns",
"a",
"new",
"Registry",
"for",
"rate",
"limiting"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/api/ratelimit/ratelimit.go#L22-L28 |
23,064 | TheThingsNetwork/ttn | api/ratelimit/ratelimit.go | Wait | func (r *Registry) Wait(id string) time.Duration {
return r.getOrCreate(id, r.newFunc).Take(1)
} | go | func (r *Registry) Wait(id string) time.Duration {
return r.getOrCreate(id, r.newFunc).Take(1)
} | [
"func",
"(",
"r",
"*",
"Registry",
")",
"Wait",
"(",
"id",
"string",
")",
"time",
".",
"Duration",
"{",
"return",
"r",
".",
"getOrCreate",
"(",
"id",
",",
"r",
".",
"newFunc",
")",
".",
"Take",
"(",
"1",
")",
"\n",
"}"
] | // Wait returns the time to wait until available | [
"Wait",
"returns",
"the",
"time",
"to",
"wait",
"until",
"available"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/api/ratelimit/ratelimit.go#L54-L56 |
23,065 | TheThingsNetwork/ttn | mqtt/events.go | UnsubscribeAppEvents | func (c *DefaultClient) UnsubscribeAppEvents(appID string, eventType types.EventType) Token {
topic := ApplicationTopic{appID, AppEvents, string(eventType)}
return c.unsubscribe(topic.String())
} | go | func (c *DefaultClient) UnsubscribeAppEvents(appID string, eventType types.EventType) Token {
topic := ApplicationTopic{appID, AppEvents, string(eventType)}
return c.unsubscribe(topic.String())
} | [
"func",
"(",
"c",
"*",
"DefaultClient",
")",
"UnsubscribeAppEvents",
"(",
"appID",
"string",
",",
"eventType",
"types",
".",
"EventType",
")",
"Token",
"{",
"topic",
":=",
"ApplicationTopic",
"{",
"appID",
",",
"AppEvents",
",",
"string",
"(",
"eventType",
"... | // UnsubscribeAppEvents unsubscribes from the events that were subscribed to by SubscribeAppEvents | [
"UnsubscribeAppEvents",
"unsubscribes",
"from",
"the",
"events",
"that",
"were",
"subscribed",
"to",
"by",
"SubscribeAppEvents"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/mqtt/events.go#L72-L75 |
23,066 | TheThingsNetwork/ttn | mqtt/events.go | UnsubscribeDeviceEvents | func (c *DefaultClient) UnsubscribeDeviceEvents(appID string, devID string, eventType types.EventType) Token {
topic := DeviceTopic{appID, devID, DeviceEvents, string(eventType)}
return c.unsubscribe(topic.String())
} | go | func (c *DefaultClient) UnsubscribeDeviceEvents(appID string, devID string, eventType types.EventType) Token {
topic := DeviceTopic{appID, devID, DeviceEvents, string(eventType)}
return c.unsubscribe(topic.String())
} | [
"func",
"(",
"c",
"*",
"DefaultClient",
")",
"UnsubscribeDeviceEvents",
"(",
"appID",
"string",
",",
"devID",
"string",
",",
"eventType",
"types",
".",
"EventType",
")",
"Token",
"{",
"topic",
":=",
"DeviceTopic",
"{",
"appID",
",",
"devID",
",",
"DeviceEven... | // UnsubscribeDeviceEvents unsubscribes from the events that were subscribed to by SubscribeDeviceEvents | [
"UnsubscribeDeviceEvents",
"unsubscribes",
"from",
"the",
"events",
"that",
"were",
"subscribed",
"to",
"by",
"SubscribeDeviceEvents"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/mqtt/events.go#L78-L81 |
23,067 | TheThingsNetwork/ttn | core/handler/device/device.go | Clone | func (d *Device) Clone() *Device {
n := new(Device)
*n = *d
n.old = nil
if d.CurrentDownlink != nil {
n.CurrentDownlink = new(types.DownlinkMessage)
*n.CurrentDownlink = *d.CurrentDownlink
}
return n
} | go | func (d *Device) Clone() *Device {
n := new(Device)
*n = *d
n.old = nil
if d.CurrentDownlink != nil {
n.CurrentDownlink = new(types.DownlinkMessage)
*n.CurrentDownlink = *d.CurrentDownlink
}
return n
} | [
"func",
"(",
"d",
"*",
"Device",
")",
"Clone",
"(",
")",
"*",
"Device",
"{",
"n",
":=",
"new",
"(",
"Device",
")",
"\n",
"*",
"n",
"=",
"*",
"d",
"\n",
"n",
".",
"old",
"=",
"nil",
"\n",
"if",
"d",
".",
"CurrentDownlink",
"!=",
"nil",
"{",
... | // Clone the device | [
"Clone",
"the",
"device"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/device/device.go#L67-L76 |
23,068 | TheThingsNetwork/ttn | core/discovery/announcement/cache.go | NewCachedAnnouncementStore | func NewCachedAnnouncementStore(store Store, options CacheOptions) Store {
serviceCache := gcache.New(options.ServiceCacheSize).Expiration(options.ServiceCacheExpiration).LRU().
LoaderFunc(func(k interface{}) (interface{}, error) {
key := strings.Split(k.(string), ":")
return store.Get(key[0], key[1])
}).Bui... | go | func NewCachedAnnouncementStore(store Store, options CacheOptions) Store {
serviceCache := gcache.New(options.ServiceCacheSize).Expiration(options.ServiceCacheExpiration).LRU().
LoaderFunc(func(k interface{}) (interface{}, error) {
key := strings.Split(k.(string), ":")
return store.Get(key[0], key[1])
}).Bui... | [
"func",
"NewCachedAnnouncementStore",
"(",
"store",
"Store",
",",
"options",
"CacheOptions",
")",
"Store",
"{",
"serviceCache",
":=",
"gcache",
".",
"New",
"(",
"options",
".",
"ServiceCacheSize",
")",
".",
"Expiration",
"(",
"options",
".",
"ServiceCacheExpiratio... | // NewCachedAnnouncementStore returns a cache wrapper around the existing store | [
"NewCachedAnnouncementStore",
"returns",
"a",
"cache",
"wrapper",
"around",
"the",
"existing",
"store"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/discovery/announcement/cache.go#L43-L70 |
23,069 | TheThingsNetwork/ttn | core/storage/redis_kv_store.go | NewRedisKVStore | func NewRedisKVStore(client *redis.Client, prefix string) *RedisKVStore {
if !strings.HasSuffix(prefix, ":") {
prefix += ":"
}
return &RedisKVStore{
RedisStore: NewRedisStore(client, prefix),
}
} | go | func NewRedisKVStore(client *redis.Client, prefix string) *RedisKVStore {
if !strings.HasSuffix(prefix, ":") {
prefix += ":"
}
return &RedisKVStore{
RedisStore: NewRedisStore(client, prefix),
}
} | [
"func",
"NewRedisKVStore",
"(",
"client",
"*",
"redis",
".",
"Client",
",",
"prefix",
"string",
")",
"*",
"RedisKVStore",
"{",
"if",
"!",
"strings",
".",
"HasSuffix",
"(",
"prefix",
",",
"\"",
"\"",
")",
"{",
"prefix",
"+=",
"\"",
"\"",
"\n",
"}",
"\... | // NewRedisKVStore creates a new RedisKVStore | [
"NewRedisKVStore",
"creates",
"a",
"new",
"RedisKVStore"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/storage/redis_kv_store.go#L20-L27 |
23,070 | TheThingsNetwork/ttn | core/storage/redis_kv_store.go | List | func (s *RedisKVStore) List(selector string, options *ListOptions) (map[string]string, error) {
allKeys, err := s.Keys(selector, options)
if err != nil {
return nil, err
}
return s.GetAll(allKeys, options)
} | go | func (s *RedisKVStore) List(selector string, options *ListOptions) (map[string]string, error) {
allKeys, err := s.Keys(selector, options)
if err != nil {
return nil, err
}
return s.GetAll(allKeys, options)
} | [
"func",
"(",
"s",
"*",
"RedisKVStore",
")",
"List",
"(",
"selector",
"string",
",",
"options",
"*",
"ListOptions",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"allKeys",
",",
"err",
":=",
"s",
".",
"Keys",
"(",
"selector",
... | // List all results matching the selector, prepending the prefix to the selector if necessary | [
"List",
"all",
"results",
"matching",
"the",
"selector",
"prepending",
"the",
"prefix",
"to",
"the",
"selector",
"if",
"necessary"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/storage/redis_kv_store.go#L76-L82 |
23,071 | TheThingsNetwork/ttn | core/storage/redis_kv_store.go | Set | func (s *RedisKVStore) Set(key string, value string) error {
if !strings.HasPrefix(key, s.prefix) {
key = s.prefix + key
}
return s.client.Set(key, value, 0).Err()
} | go | func (s *RedisKVStore) Set(key string, value string) error {
if !strings.HasPrefix(key, s.prefix) {
key = s.prefix + key
}
return s.client.Set(key, value, 0).Err()
} | [
"func",
"(",
"s",
"*",
"RedisKVStore",
")",
"Set",
"(",
"key",
"string",
",",
"value",
"string",
")",
"error",
"{",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"key",
",",
"s",
".",
"prefix",
")",
"{",
"key",
"=",
"s",
".",
"prefix",
"+",
"key",... | // Set a record, prepending the prefix to the key if necessary | [
"Set",
"a",
"record",
"prepending",
"the",
"prefix",
"to",
"the",
"key",
"if",
"necessary"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/storage/redis_kv_store.go#L100-L105 |
23,072 | TheThingsNetwork/ttn | core/storage/redis_kv_store.go | Create | func (s *RedisKVStore) Create(key string, value string) error {
if !strings.HasPrefix(key, s.prefix) {
key = s.prefix + key
}
err := s.client.Watch(func(tx *redis.Tx) error {
exists, err := tx.Exists(key).Result()
if err != nil {
return err
}
if exists {
return errors.NewErrAlreadyExists(key)
}
_... | go | func (s *RedisKVStore) Create(key string, value string) error {
if !strings.HasPrefix(key, s.prefix) {
key = s.prefix + key
}
err := s.client.Watch(func(tx *redis.Tx) error {
exists, err := tx.Exists(key).Result()
if err != nil {
return err
}
if exists {
return errors.NewErrAlreadyExists(key)
}
_... | [
"func",
"(",
"s",
"*",
"RedisKVStore",
")",
"Create",
"(",
"key",
"string",
",",
"value",
"string",
")",
"error",
"{",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"key",
",",
"s",
".",
"prefix",
")",
"{",
"key",
"=",
"s",
".",
"prefix",
"+",
"ke... | // Create a new record, prepending the prefix to the key if necessary
// This function returns an error if the record already exists | [
"Create",
"a",
"new",
"record",
"prepending",
"the",
"prefix",
"to",
"the",
"key",
"if",
"necessary",
"This",
"function",
"returns",
"an",
"error",
"if",
"the",
"record",
"already",
"exists"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/storage/redis_kv_store.go#L109-L134 |
23,073 | TheThingsNetwork/ttn | utils/security/convert_keys.go | PublicPEM | func PublicPEM(key *ecdsa.PrivateKey) ([]byte, error) {
pubBytes, err := x509.MarshalPKIXPublicKey(key.Public())
if err != nil {
return nil, err
}
pubPEM := pem.EncodeToMemory(&pem.Block{
Type: "PUBLIC KEY",
Bytes: pubBytes,
})
return pubPEM, nil
} | go | func PublicPEM(key *ecdsa.PrivateKey) ([]byte, error) {
pubBytes, err := x509.MarshalPKIXPublicKey(key.Public())
if err != nil {
return nil, err
}
pubPEM := pem.EncodeToMemory(&pem.Block{
Type: "PUBLIC KEY",
Bytes: pubBytes,
})
return pubPEM, nil
} | [
"func",
"PublicPEM",
"(",
"key",
"*",
"ecdsa",
".",
"PrivateKey",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"pubBytes",
",",
"err",
":=",
"x509",
".",
"MarshalPKIXPublicKey",
"(",
"key",
".",
"Public",
"(",
")",
")",
"\n",
"if",
"err",
"!... | // PublicPEM returns the PEM-encoded public key | [
"PublicPEM",
"returns",
"the",
"PEM",
"-",
"encoded",
"public",
"key"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/security/convert_keys.go#L13-L23 |
23,074 | TheThingsNetwork/ttn | utils/security/convert_keys.go | PrivatePEM | func PrivatePEM(key *ecdsa.PrivateKey) ([]byte, error) {
privBytes, err := x509.MarshalECPrivateKey(key)
if err != nil {
return nil, err
}
privPEM := pem.EncodeToMemory(&pem.Block{
Type: "EC PRIVATE KEY",
Bytes: privBytes,
})
return privPEM, nil
} | go | func PrivatePEM(key *ecdsa.PrivateKey) ([]byte, error) {
privBytes, err := x509.MarshalECPrivateKey(key)
if err != nil {
return nil, err
}
privPEM := pem.EncodeToMemory(&pem.Block{
Type: "EC PRIVATE KEY",
Bytes: privBytes,
})
return privPEM, nil
} | [
"func",
"PrivatePEM",
"(",
"key",
"*",
"ecdsa",
".",
"PrivateKey",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"privBytes",
",",
"err",
":=",
"x509",
".",
"MarshalECPrivateKey",
"(",
"key",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // PrivatePEM returns the PEM-encoded private key | [
"PrivatePEM",
"returns",
"the",
"PEM",
"-",
"encoded",
"private",
"key"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/security/convert_keys.go#L26-L36 |
23,075 | TheThingsNetwork/ttn | amqp/subscriber.go | NewSubscriber | func (c *DefaultClient) NewSubscriber(exchange, name string, durable, autoDelete bool) Subscriber {
return &DefaultSubscriber{
DefaultChannelClient: DefaultChannelClient{
ctx: c.ctx,
client: c,
exchange: exchange,
name: "Subscriber",
},
name: name,
durable: durable,
autoDelete... | go | func (c *DefaultClient) NewSubscriber(exchange, name string, durable, autoDelete bool) Subscriber {
return &DefaultSubscriber{
DefaultChannelClient: DefaultChannelClient{
ctx: c.ctx,
client: c,
exchange: exchange,
name: "Subscriber",
},
name: name,
durable: durable,
autoDelete... | [
"func",
"(",
"c",
"*",
"DefaultClient",
")",
"NewSubscriber",
"(",
"exchange",
",",
"name",
"string",
",",
"durable",
",",
"autoDelete",
"bool",
")",
"Subscriber",
"{",
"return",
"&",
"DefaultSubscriber",
"{",
"DefaultChannelClient",
":",
"DefaultChannelClient",
... | // NewSubscriber returns a new topic subscriber on the specified exchange | [
"NewSubscriber",
"returns",
"a",
"new",
"topic",
"subscriber",
"on",
"the",
"specified",
"exchange"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/amqp/subscriber.go#L51-L63 |
23,076 | TheThingsNetwork/ttn | amqp/subscriber.go | QueueDeclare | func (s *DefaultSubscriber) QueueDeclare() (string, error) {
queue, err := s.channel.QueueDeclare(s.name, s.durable, s.autoDelete, false, false, nil)
if err != nil {
return "", fmt.Errorf("Failed to declare queue '%s' (%s)", s.name, err)
}
return queue.Name, nil
} | go | func (s *DefaultSubscriber) QueueDeclare() (string, error) {
queue, err := s.channel.QueueDeclare(s.name, s.durable, s.autoDelete, false, false, nil)
if err != nil {
return "", fmt.Errorf("Failed to declare queue '%s' (%s)", s.name, err)
}
return queue.Name, nil
} | [
"func",
"(",
"s",
"*",
"DefaultSubscriber",
")",
"QueueDeclare",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"queue",
",",
"err",
":=",
"s",
".",
"channel",
".",
"QueueDeclare",
"(",
"s",
".",
"name",
",",
"s",
".",
"durable",
",",
"s",
".",
... | // QueueDeclare declares the queue on the AMQP broker | [
"QueueDeclare",
"declares",
"the",
"queue",
"on",
"the",
"AMQP",
"broker"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/amqp/subscriber.go#L66-L72 |
23,077 | TheThingsNetwork/ttn | amqp/subscriber.go | QueueBind | func (s *DefaultSubscriber) QueueBind(name, key string) error {
err := s.channel.QueueBind(name, key, s.exchange, false, nil)
if err != nil {
return fmt.Errorf("Failed to bind queue %s with key %s on exchange '%s' (%s)", name, key, s.exchange, err)
}
return nil
} | go | func (s *DefaultSubscriber) QueueBind(name, key string) error {
err := s.channel.QueueBind(name, key, s.exchange, false, nil)
if err != nil {
return fmt.Errorf("Failed to bind queue %s with key %s on exchange '%s' (%s)", name, key, s.exchange, err)
}
return nil
} | [
"func",
"(",
"s",
"*",
"DefaultSubscriber",
")",
"QueueBind",
"(",
"name",
",",
"key",
"string",
")",
"error",
"{",
"err",
":=",
"s",
".",
"channel",
".",
"QueueBind",
"(",
"name",
",",
"key",
",",
"s",
".",
"exchange",
",",
"false",
",",
"nil",
")... | // QueueBind binds the routing key to the specified queue | [
"QueueBind",
"binds",
"the",
"routing",
"key",
"to",
"the",
"specified",
"queue"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/amqp/subscriber.go#L75-L81 |
23,078 | TheThingsNetwork/ttn | utils/toa/toa.go | ComputeFSK | func ComputeFSK(payloadSize uint, bitrate int) (time.Duration, error) {
tPkt := int64(time.Second) * (int64(payloadSize) + 5 + 3 + 1 + 2) * 8 / int64(bitrate)
return time.Duration(tPkt), nil
} | go | func ComputeFSK(payloadSize uint, bitrate int) (time.Duration, error) {
tPkt := int64(time.Second) * (int64(payloadSize) + 5 + 3 + 1 + 2) * 8 / int64(bitrate)
return time.Duration(tPkt), nil
} | [
"func",
"ComputeFSK",
"(",
"payloadSize",
"uint",
",",
"bitrate",
"int",
")",
"(",
"time",
".",
"Duration",
",",
"error",
")",
"{",
"tPkt",
":=",
"int64",
"(",
"time",
".",
"Second",
")",
"*",
"(",
"int64",
"(",
"payloadSize",
")",
"+",
"5",
"+",
"... | // ComputeFSK computes the time-on-air given a PHY payload size in bytes and a
// bitrate, Note that this function operates on the PHY payload size and does
// not add the LoRaWAN header. | [
"ComputeFSK",
"computes",
"the",
"time",
"-",
"on",
"-",
"air",
"given",
"a",
"PHY",
"payload",
"size",
"in",
"bytes",
"and",
"a",
"bitrate",
"Note",
"that",
"this",
"function",
"operates",
"on",
"the",
"PHY",
"payload",
"size",
"and",
"does",
"not",
"ad... | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/toa/toa.go#L60-L63 |
23,079 | TheThingsNetwork/ttn | utils/backoff/backoff.go | Backoff | func (bc Config) Backoff(retries int) time.Duration {
if retries == 0 {
return bc.BaseDelay
}
backoff, max := float64(bc.BaseDelay), float64(bc.MaxDelay)
for backoff < max && retries > 0 {
backoff *= bc.Factor
retries--
}
if backoff > max {
backoff = max
}
// Randomize backoff delays so that if a cluste... | go | func (bc Config) Backoff(retries int) time.Duration {
if retries == 0 {
return bc.BaseDelay
}
backoff, max := float64(bc.BaseDelay), float64(bc.MaxDelay)
for backoff < max && retries > 0 {
backoff *= bc.Factor
retries--
}
if backoff > max {
backoff = max
}
// Randomize backoff delays so that if a cluste... | [
"func",
"(",
"bc",
"Config",
")",
"Backoff",
"(",
"retries",
"int",
")",
"time",
".",
"Duration",
"{",
"if",
"retries",
"==",
"0",
"{",
"return",
"bc",
".",
"BaseDelay",
"\n",
"}",
"\n",
"backoff",
",",
"max",
":=",
"float64",
"(",
"bc",
".",
"Base... | // Backoff returns the delay for the current amount of retries | [
"Backoff",
"returns",
"the",
"delay",
"for",
"the",
"current",
"amount",
"of",
"retries"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/backoff/backoff.go#L36-L55 |
23,080 | TheThingsNetwork/ttn | mqtt/uplink.go | PublishUplink | func (c *DefaultClient) PublishUplink(dataUp types.UplinkMessage) Token {
topic := DeviceTopic{dataUp.AppID, dataUp.DevID, DeviceUplink, ""}
msg, err := json.Marshal(dataUp)
if err != nil {
return &simpleToken{fmt.Errorf("Unable to marshal the message payload: %s", err)}
}
return c.publish(topic.String(), msg)
} | go | func (c *DefaultClient) PublishUplink(dataUp types.UplinkMessage) Token {
topic := DeviceTopic{dataUp.AppID, dataUp.DevID, DeviceUplink, ""}
msg, err := json.Marshal(dataUp)
if err != nil {
return &simpleToken{fmt.Errorf("Unable to marshal the message payload: %s", err)}
}
return c.publish(topic.String(), msg)
} | [
"func",
"(",
"c",
"*",
"DefaultClient",
")",
"PublishUplink",
"(",
"dataUp",
"types",
".",
"UplinkMessage",
")",
"Token",
"{",
"topic",
":=",
"DeviceTopic",
"{",
"dataUp",
".",
"AppID",
",",
"dataUp",
".",
"DevID",
",",
"DeviceUplink",
",",
"\"",
"\"",
"... | // PublishUplink publishes an uplink message to the MQTT broker | [
"PublishUplink",
"publishes",
"an",
"uplink",
"message",
"to",
"the",
"MQTT",
"broker"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/mqtt/uplink.go#L18-L25 |
23,081 | TheThingsNetwork/ttn | mqtt/uplink.go | PublishUplinkFields | func (c *DefaultClient) PublishUplinkFields(appID string, devID string, fields map[string]interface{}) Token {
flattenedFields := make(map[string]interface{})
flatten("", "/", fields, flattenedFields)
tokens := make([]Token, 0, len(flattenedFields))
for field, value := range flattenedFields {
topic := DeviceTopic... | go | func (c *DefaultClient) PublishUplinkFields(appID string, devID string, fields map[string]interface{}) Token {
flattenedFields := make(map[string]interface{})
flatten("", "/", fields, flattenedFields)
tokens := make([]Token, 0, len(flattenedFields))
for field, value := range flattenedFields {
topic := DeviceTopic... | [
"func",
"(",
"c",
"*",
"DefaultClient",
")",
"PublishUplinkFields",
"(",
"appID",
"string",
",",
"devID",
"string",
",",
"fields",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"Token",
"{",
"flattenedFields",
":=",
"make",
"(",
"map",
"[",
"str... | // PublishUplinkFields publishes uplink fields to MQTT | [
"PublishUplinkFields",
"publishes",
"uplink",
"fields",
"to",
"MQTT"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/mqtt/uplink.go#L28-L50 |
23,082 | TheThingsNetwork/ttn | mqtt/uplink.go | UnsubscribeDeviceUplink | func (c *DefaultClient) UnsubscribeDeviceUplink(appID string, devID string) Token {
topic := DeviceTopic{appID, devID, DeviceUplink, ""}
return c.unsubscribe(topic.String())
} | go | func (c *DefaultClient) UnsubscribeDeviceUplink(appID string, devID string) Token {
topic := DeviceTopic{appID, devID, DeviceUplink, ""}
return c.unsubscribe(topic.String())
} | [
"func",
"(",
"c",
"*",
"DefaultClient",
")",
"UnsubscribeDeviceUplink",
"(",
"appID",
"string",
",",
"devID",
"string",
")",
"Token",
"{",
"topic",
":=",
"DeviceTopic",
"{",
"appID",
",",
"devID",
",",
"DeviceUplink",
",",
"\"",
"\"",
"}",
"\n",
"return",
... | // UnsubscribeDeviceUplink unsubscribes from the uplink messages for the given application and device | [
"UnsubscribeDeviceUplink",
"unsubscribes",
"from",
"the",
"uplink",
"messages",
"for",
"the",
"given",
"application",
"and",
"device"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/mqtt/uplink.go#L103-L106 |
23,083 | TheThingsNetwork/ttn | core/networkserver/device/store.go | NewRedisDeviceStore | func NewRedisDeviceStore(client *redis.Client, prefix string) Store {
if prefix == "" {
prefix = defaultRedisPrefix
}
store := storage.NewRedisMapStore(client, prefix+":"+redisDevicePrefix)
store.SetBase(Device{}, "")
for v, f := range migrate.DeviceMigrations(prefix) {
store.AddMigration(v, f)
}
frameStore ... | go | func NewRedisDeviceStore(client *redis.Client, prefix string) Store {
if prefix == "" {
prefix = defaultRedisPrefix
}
store := storage.NewRedisMapStore(client, prefix+":"+redisDevicePrefix)
store.SetBase(Device{}, "")
for v, f := range migrate.DeviceMigrations(prefix) {
store.AddMigration(v, f)
}
frameStore ... | [
"func",
"NewRedisDeviceStore",
"(",
"client",
"*",
"redis",
".",
"Client",
",",
"prefix",
"string",
")",
"Store",
"{",
"if",
"prefix",
"==",
"\"",
"\"",
"{",
"prefix",
"=",
"defaultRedisPrefix",
"\n",
"}",
"\n",
"store",
":=",
"storage",
".",
"NewRedisMapS... | // NewRedisDeviceStore creates a new Redis-based status store | [
"NewRedisDeviceStore",
"creates",
"a",
"new",
"Redis",
"-",
"based",
"status",
"store"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/networkserver/device/store.go#L36-L55 |
23,084 | TheThingsNetwork/ttn | core/networkserver/device/store.go | CountForAddress | func (s *RedisDeviceStore) CountForAddress(devAddr types.DevAddr) (int, error) {
return s.devAddrIndex.Count(devAddr.String())
} | go | func (s *RedisDeviceStore) CountForAddress(devAddr types.DevAddr) (int, error) {
return s.devAddrIndex.Count(devAddr.String())
} | [
"func",
"(",
"s",
"*",
"RedisDeviceStore",
")",
"CountForAddress",
"(",
"devAddr",
"types",
".",
"DevAddr",
")",
"(",
"int",
",",
"error",
")",
"{",
"return",
"s",
".",
"devAddrIndex",
".",
"Count",
"(",
"devAddr",
".",
"String",
"(",
")",
")",
"\n",
... | // CountForAddress counts all devices for a specific DevAddr | [
"CountForAddress",
"counts",
"all",
"devices",
"for",
"a",
"specific",
"DevAddr"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/networkserver/device/store.go#L96-L98 |
23,085 | TheThingsNetwork/ttn | core/networkserver/device/store.go | ListForAddress | func (s *RedisDeviceStore) ListForAddress(devAddr types.DevAddr) ([]*Device, error) {
deviceKeys, err := s.devAddrIndex.Get(devAddr.String())
if errors.GetErrType(err) == errors.NotFound {
return nil, nil
}
if err != nil {
return nil, err
}
devicesI, err := s.store.GetAll(deviceKeys, nil)
if err != nil {
r... | go | func (s *RedisDeviceStore) ListForAddress(devAddr types.DevAddr) ([]*Device, error) {
deviceKeys, err := s.devAddrIndex.Get(devAddr.String())
if errors.GetErrType(err) == errors.NotFound {
return nil, nil
}
if err != nil {
return nil, err
}
devicesI, err := s.store.GetAll(deviceKeys, nil)
if err != nil {
r... | [
"func",
"(",
"s",
"*",
"RedisDeviceStore",
")",
"ListForAddress",
"(",
"devAddr",
"types",
".",
"DevAddr",
")",
"(",
"[",
"]",
"*",
"Device",
",",
"error",
")",
"{",
"deviceKeys",
",",
"err",
":=",
"s",
".",
"devAddrIndex",
".",
"Get",
"(",
"devAddr",
... | // ListForAddress lists all devices for a specific DevAddr | [
"ListForAddress",
"lists",
"all",
"devices",
"for",
"a",
"specific",
"DevAddr"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/networkserver/device/store.go#L101-L120 |
23,086 | TheThingsNetwork/ttn | core/networkserver/device/store.go | Frames | func (s *RedisDeviceStore) Frames(appEUI types.AppEUI, devEUI types.DevEUI) (FrameHistory, error) {
return &RedisFrameHistory{
appEUI: appEUI,
devEUI: devEUI,
store: s.frameStore,
}, nil
} | go | func (s *RedisDeviceStore) Frames(appEUI types.AppEUI, devEUI types.DevEUI) (FrameHistory, error) {
return &RedisFrameHistory{
appEUI: appEUI,
devEUI: devEUI,
store: s.frameStore,
}, nil
} | [
"func",
"(",
"s",
"*",
"RedisDeviceStore",
")",
"Frames",
"(",
"appEUI",
"types",
".",
"AppEUI",
",",
"devEUI",
"types",
".",
"DevEUI",
")",
"(",
"FrameHistory",
",",
"error",
")",
"{",
"return",
"&",
"RedisFrameHistory",
"{",
"appEUI",
":",
"appEUI",
",... | // Frames history for a specific Device | [
"Frames",
"history",
"for",
"a",
"specific",
"Device"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/networkserver/device/store.go#L192-L198 |
23,087 | TheThingsNetwork/ttn | ttnctl/util/mqtt.go | GetMQTT | func GetMQTT(ctx ttnlog.Interface, accessKey string) mqtt.Client {
username, password, err := getMQTTCredentials(ctx, accessKey)
if err != nil {
ctx.WithError(err).Fatal("Failed to get MQTT credentials")
}
mqttProto := "tcp"
if strings.HasSuffix(viper.GetString("mqtt-address"), ":8883") {
mqttProto = "ssl"
... | go | func GetMQTT(ctx ttnlog.Interface, accessKey string) mqtt.Client {
username, password, err := getMQTTCredentials(ctx, accessKey)
if err != nil {
ctx.WithError(err).Fatal("Failed to get MQTT credentials")
}
mqttProto := "tcp"
if strings.HasSuffix(viper.GetString("mqtt-address"), ":8883") {
mqttProto = "ssl"
... | [
"func",
"GetMQTT",
"(",
"ctx",
"ttnlog",
".",
"Interface",
",",
"accessKey",
"string",
")",
"mqtt",
".",
"Client",
"{",
"username",
",",
"password",
",",
"err",
":=",
"getMQTTCredentials",
"(",
"ctx",
",",
"accessKey",
")",
"\n",
"if",
"err",
"!=",
"nil"... | // GetMQTT connects a new MQTT clients with the specified credentials | [
"GetMQTT",
"connects",
"a",
"new",
"MQTT",
"clients",
"with",
"the",
"specified",
"credentials"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/mqtt.go#L18-L42 |
23,088 | TheThingsNetwork/ttn | core/router/gateway/gateway.go | NewGateway | func NewGateway(ctx ttnlog.Interface, id string) *Gateway {
ctx = ctx.WithField("GatewayID", id)
gtw := &Gateway{
ID: id,
Status: NewStatusStore(),
Utilization: NewUtilization(),
Schedule: NewSchedule(ctx),
Ctx: ctx,
}
gtw.Schedule.(*schedule).gateway = gtw // FIXME: Issue #420
r... | go | func NewGateway(ctx ttnlog.Interface, id string) *Gateway {
ctx = ctx.WithField("GatewayID", id)
gtw := &Gateway{
ID: id,
Status: NewStatusStore(),
Utilization: NewUtilization(),
Schedule: NewSchedule(ctx),
Ctx: ctx,
}
gtw.Schedule.(*schedule).gateway = gtw // FIXME: Issue #420
r... | [
"func",
"NewGateway",
"(",
"ctx",
"ttnlog",
".",
"Interface",
",",
"id",
"string",
")",
"*",
"Gateway",
"{",
"ctx",
"=",
"ctx",
".",
"WithField",
"(",
"\"",
"\"",
",",
"id",
")",
"\n",
"gtw",
":=",
"&",
"Gateway",
"{",
"ID",
":",
"id",
",",
"Stat... | // NewGateway creates a new in-memory Gateway structure | [
"NewGateway",
"creates",
"a",
"new",
"in",
"-",
"memory",
"Gateway",
"structure"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/router/gateway/gateway.go#L19-L30 |
23,089 | TheThingsNetwork/ttn | utils/security/jwt.go | BuildJWT | func BuildJWT(subject string, ttl time.Duration, privateKey []byte) (token string, err error) {
claims := jwt.StandardClaims{
Issuer: subject,
Subject: subject,
IssuedAt: time.Now().Add(-20 * time.Second).Unix(),
NotBefore: time.Now().Add(-20 * time.Second).Unix(),
}
if ttl > 0 {
claims.ExpiresAt = t... | go | func BuildJWT(subject string, ttl time.Duration, privateKey []byte) (token string, err error) {
claims := jwt.StandardClaims{
Issuer: subject,
Subject: subject,
IssuedAt: time.Now().Add(-20 * time.Second).Unix(),
NotBefore: time.Now().Add(-20 * time.Second).Unix(),
}
if ttl > 0 {
claims.ExpiresAt = t... | [
"func",
"BuildJWT",
"(",
"subject",
"string",
",",
"ttl",
"time",
".",
"Duration",
",",
"privateKey",
"[",
"]",
"byte",
")",
"(",
"token",
"string",
",",
"err",
"error",
")",
"{",
"claims",
":=",
"jwt",
".",
"StandardClaims",
"{",
"Issuer",
":",
"subje... | // BuildJWT builds a JSON Web Token for the given subject and ttl, and signs it with the given private key | [
"BuildJWT",
"builds",
"a",
"JSON",
"Web",
"Token",
"for",
"the",
"given",
"subject",
"and",
"ttl",
"and",
"signs",
"it",
"with",
"the",
"given",
"private",
"key"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/security/jwt.go#L15-L36 |
23,090 | TheThingsNetwork/ttn | utils/security/jwt.go | ValidateJWT | func ValidateJWT(token string, publicKey []byte) (*jwt.StandardClaims, error) {
claims := &jwt.StandardClaims{}
_, err := jwt.ParseWithClaims(token, claims, func(token *jwt.Token) (interface{}, error) {
if _, ok := token.Method.(*jwt.SigningMethodECDSA); !ok {
return nil, fmt.Errorf("Unexpected JWT signing metho... | go | func ValidateJWT(token string, publicKey []byte) (*jwt.StandardClaims, error) {
claims := &jwt.StandardClaims{}
_, err := jwt.ParseWithClaims(token, claims, func(token *jwt.Token) (interface{}, error) {
if _, ok := token.Method.(*jwt.SigningMethodECDSA); !ok {
return nil, fmt.Errorf("Unexpected JWT signing metho... | [
"func",
"ValidateJWT",
"(",
"token",
"string",
",",
"publicKey",
"[",
"]",
"byte",
")",
"(",
"*",
"jwt",
".",
"StandardClaims",
",",
"error",
")",
"{",
"claims",
":=",
"&",
"jwt",
".",
"StandardClaims",
"{",
"}",
"\n",
"_",
",",
"err",
":=",
"jwt",
... | // ValidateJWT validates a JSON Web Token with the given public key | [
"ValidateJWT",
"validates",
"a",
"JSON",
"Web",
"Token",
"with",
"the",
"given",
"public",
"key"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/security/jwt.go#L39-L55 |
23,091 | TheThingsNetwork/ttn | utils/fcnt/fcnt.go | GetFull | func GetFull(full uint32, lsb uint16) uint32 {
if int(lsb)-int(full) > 0 {
return uint32(lsb)
}
if uint16(full%maxUint16) <= lsb {
return uint32(lsb) + (full/maxUint16)*maxUint16
}
return uint32(lsb) + ((full/maxUint16)+1)*maxUint16
} | go | func GetFull(full uint32, lsb uint16) uint32 {
if int(lsb)-int(full) > 0 {
return uint32(lsb)
}
if uint16(full%maxUint16) <= lsb {
return uint32(lsb) + (full/maxUint16)*maxUint16
}
return uint32(lsb) + ((full/maxUint16)+1)*maxUint16
} | [
"func",
"GetFull",
"(",
"full",
"uint32",
",",
"lsb",
"uint16",
")",
"uint32",
"{",
"if",
"int",
"(",
"lsb",
")",
"-",
"int",
"(",
"full",
")",
">",
"0",
"{",
"return",
"uint32",
"(",
"lsb",
")",
"\n",
"}",
"\n",
"if",
"uint16",
"(",
"full",
"%... | // GetFull calculates the full 32-bit frame counter | [
"GetFull",
"calculates",
"the",
"full",
"32",
"-",
"bit",
"frame",
"counter"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/fcnt/fcnt.go#L9-L17 |
23,092 | TheThingsNetwork/ttn | core/types/dev_addr.go | ParseDevAddr | func ParseDevAddr(input string) (addr DevAddr, err error) {
bytes, err := ParseHEX(input, 4)
if err != nil {
return
}
copy(addr[:], bytes)
return
} | go | func ParseDevAddr(input string) (addr DevAddr, err error) {
bytes, err := ParseHEX(input, 4)
if err != nil {
return
}
copy(addr[:], bytes)
return
} | [
"func",
"ParseDevAddr",
"(",
"input",
"string",
")",
"(",
"addr",
"DevAddr",
",",
"err",
"error",
")",
"{",
"bytes",
",",
"err",
":=",
"ParseHEX",
"(",
"input",
",",
"4",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"copy",
... | // ParseDevAddr parses a 32-bit hex-encoded string to a DevAddr | [
"ParseDevAddr",
"parses",
"a",
"32",
"-",
"bit",
"hex",
"-",
"encoded",
"string",
"to",
"a",
"DevAddr"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/types/dev_addr.go#L20-L27 |
23,093 | TheThingsNetwork/ttn | core/types/dev_addr.go | Bytes | func (prefix DevAddrPrefix) Bytes() (bytes []byte) {
bytes = append(bytes, byte(prefix.Length))
bytes = append(bytes, prefix.DevAddr.Bytes()...)
return bytes
} | go | func (prefix DevAddrPrefix) Bytes() (bytes []byte) {
bytes = append(bytes, byte(prefix.Length))
bytes = append(bytes, prefix.DevAddr.Bytes()...)
return bytes
} | [
"func",
"(",
"prefix",
"DevAddrPrefix",
")",
"Bytes",
"(",
")",
"(",
"bytes",
"[",
"]",
"byte",
")",
"{",
"bytes",
"=",
"append",
"(",
"bytes",
",",
"byte",
"(",
"prefix",
".",
"Length",
")",
")",
"\n",
"bytes",
"=",
"append",
"(",
"bytes",
",",
... | // Bytes returns the DevAddrPrefix as a byte slice | [
"Bytes",
"returns",
"the",
"DevAddrPrefix",
"as",
"a",
"byte",
"slice"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/types/dev_addr.go#L130-L134 |
23,094 | TheThingsNetwork/ttn | core/types/dev_addr.go | String | func (prefix DevAddrPrefix) String() string {
var addr string
if prefix.DevAddr.IsEmpty() {
addr = "00000000"
} else {
addr = prefix.DevAddr.String()
}
return fmt.Sprintf("%s/%d", addr, prefix.Length)
} | go | func (prefix DevAddrPrefix) String() string {
var addr string
if prefix.DevAddr.IsEmpty() {
addr = "00000000"
} else {
addr = prefix.DevAddr.String()
}
return fmt.Sprintf("%s/%d", addr, prefix.Length)
} | [
"func",
"(",
"prefix",
"DevAddrPrefix",
")",
"String",
"(",
")",
"string",
"{",
"var",
"addr",
"string",
"\n",
"if",
"prefix",
".",
"DevAddr",
".",
"IsEmpty",
"(",
")",
"{",
"addr",
"=",
"\"",
"\"",
"\n",
"}",
"else",
"{",
"addr",
"=",
"prefix",
".... | // String implements the fmt.Stringer interface | [
"String",
"implements",
"the",
"fmt",
".",
"Stringer",
"interface"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/types/dev_addr.go#L137-L145 |
23,095 | TheThingsNetwork/ttn | core/types/dev_addr.go | Mask | func (addr DevAddr) Mask(bits int) (masked DevAddr) {
return empty.WithPrefix(DevAddrPrefix{addr, bits})
} | go | func (addr DevAddr) Mask(bits int) (masked DevAddr) {
return empty.WithPrefix(DevAddrPrefix{addr, bits})
} | [
"func",
"(",
"addr",
"DevAddr",
")",
"Mask",
"(",
"bits",
"int",
")",
"(",
"masked",
"DevAddr",
")",
"{",
"return",
"empty",
".",
"WithPrefix",
"(",
"DevAddrPrefix",
"{",
"addr",
",",
"bits",
"}",
")",
"\n",
"}"
] | // Mask returns a copy of the DevAddr with only the first "bits" bits | [
"Mask",
"returns",
"a",
"copy",
"of",
"the",
"DevAddr",
"with",
"only",
"the",
"first",
"bits",
"bits"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/types/dev_addr.go#L202-L204 |
23,096 | TheThingsNetwork/ttn | core/types/dev_addr.go | WithPrefix | func (addr DevAddr) WithPrefix(prefix DevAddrPrefix) (prefixed DevAddr) {
k := uint(prefix.Length)
for i := 0; i < 4; i++ {
if k >= 8 {
prefixed[i] = prefix.DevAddr[i] & 0xff
k -= 8
continue
}
prefixed[i] = (prefix.DevAddr[i] & ^byte(0xff>>k)) | (addr[i] & byte(0xff>>k))
k = 0
}
return
} | go | func (addr DevAddr) WithPrefix(prefix DevAddrPrefix) (prefixed DevAddr) {
k := uint(prefix.Length)
for i := 0; i < 4; i++ {
if k >= 8 {
prefixed[i] = prefix.DevAddr[i] & 0xff
k -= 8
continue
}
prefixed[i] = (prefix.DevAddr[i] & ^byte(0xff>>k)) | (addr[i] & byte(0xff>>k))
k = 0
}
return
} | [
"func",
"(",
"addr",
"DevAddr",
")",
"WithPrefix",
"(",
"prefix",
"DevAddrPrefix",
")",
"(",
"prefixed",
"DevAddr",
")",
"{",
"k",
":=",
"uint",
"(",
"prefix",
".",
"Length",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"4",
";",
"i",
"++",
"... | // WithPrefix returns the DevAddr, but with the first length bits replaced by the Prefix | [
"WithPrefix",
"returns",
"the",
"DevAddr",
"but",
"with",
"the",
"first",
"length",
"bits",
"replaced",
"by",
"the",
"Prefix"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/types/dev_addr.go#L207-L219 |
23,097 | TheThingsNetwork/ttn | core/types/dev_addr.go | HasPrefix | func (addr DevAddr) HasPrefix(prefix DevAddrPrefix) bool {
return addr.Mask(prefix.Length) == prefix.DevAddr.Mask(prefix.Length)
} | go | func (addr DevAddr) HasPrefix(prefix DevAddrPrefix) bool {
return addr.Mask(prefix.Length) == prefix.DevAddr.Mask(prefix.Length)
} | [
"func",
"(",
"addr",
"DevAddr",
")",
"HasPrefix",
"(",
"prefix",
"DevAddrPrefix",
")",
"bool",
"{",
"return",
"addr",
".",
"Mask",
"(",
"prefix",
".",
"Length",
")",
"==",
"prefix",
".",
"DevAddr",
".",
"Mask",
"(",
"prefix",
".",
"Length",
")",
"\n",
... | // HasPrefix returns true if the DevAddr has a prefix of given length | [
"HasPrefix",
"returns",
"true",
"if",
"the",
"DevAddr",
"has",
"a",
"prefix",
"of",
"given",
"length"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/types/dev_addr.go#L222-L224 |
23,098 | minio/sio | reader-v1.go | encryptReaderV10 | func encryptReaderV10(src io.Reader, config *Config) (*encReaderV10, error) {
ae, err := newAuthEncV10(config)
if err != nil {
return nil, err
}
return &encReaderV10{
authEncV10: ae,
src: src,
buffer: make(packageV10, maxPackageSize),
payloadSize: config.PayloadSize,
}, nil
} | go | func encryptReaderV10(src io.Reader, config *Config) (*encReaderV10, error) {
ae, err := newAuthEncV10(config)
if err != nil {
return nil, err
}
return &encReaderV10{
authEncV10: ae,
src: src,
buffer: make(packageV10, maxPackageSize),
payloadSize: config.PayloadSize,
}, nil
} | [
"func",
"encryptReaderV10",
"(",
"src",
"io",
".",
"Reader",
",",
"config",
"*",
"Config",
")",
"(",
"*",
"encReaderV10",
",",
"error",
")",
"{",
"ae",
",",
"err",
":=",
"newAuthEncV10",
"(",
"config",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"retur... | // encryptReaderV10 returns an io.Reader wrapping the given io.Reader.
// The returned io.Reader encrypts everything it reads using DARE 1.0. | [
"encryptReaderV10",
"returns",
"an",
"io",
".",
"Reader",
"wrapping",
"the",
"given",
"io",
".",
"Reader",
".",
"The",
"returned",
"io",
".",
"Reader",
"encrypts",
"everything",
"it",
"reads",
"using",
"DARE",
"1",
".",
"0",
"."
] | 035b4ef8c449ba2ba21ec143c91964e76a1fb68c | https://github.com/minio/sio/blob/035b4ef8c449ba2ba21ec143c91964e76a1fb68c/reader-v1.go#L30-L41 |
23,099 | minio/sio | reader-v1.go | decryptReaderV10 | func decryptReaderV10(src io.Reader, config *Config) (*decReaderV10, error) {
ad, err := newAuthDecV10(config)
if err != nil {
return nil, err
}
return &decReaderV10{
authDecV10: ad,
src: src,
buffer: make(packageV10, maxPackageSize),
}, nil
} | go | func decryptReaderV10(src io.Reader, config *Config) (*decReaderV10, error) {
ad, err := newAuthDecV10(config)
if err != nil {
return nil, err
}
return &decReaderV10{
authDecV10: ad,
src: src,
buffer: make(packageV10, maxPackageSize),
}, nil
} | [
"func",
"decryptReaderV10",
"(",
"src",
"io",
".",
"Reader",
",",
"config",
"*",
"Config",
")",
"(",
"*",
"decReaderV10",
",",
"error",
")",
"{",
"ad",
",",
"err",
":=",
"newAuthDecV10",
"(",
"config",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"retur... | // decryptReaderV10 returns an io.Reader wrapping the given io.Reader.
// The returned io.Reader decrypts everything it reads using DARE 1.0. | [
"decryptReaderV10",
"returns",
"an",
"io",
".",
"Reader",
"wrapping",
"the",
"given",
"io",
".",
"Reader",
".",
"The",
"returned",
"io",
".",
"Reader",
"decrypts",
"everything",
"it",
"reads",
"using",
"DARE",
"1",
".",
"0",
"."
] | 035b4ef8c449ba2ba21ec143c91964e76a1fb68c | https://github.com/minio/sio/blob/035b4ef8c449ba2ba21ec143c91964e76a1fb68c/reader-v1.go#L91-L101 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.