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 listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
145,000 | TheThingsNetwork/ttn | core/handler/device/converter.go | ToPb | func (d Device) ToPb() *pb_handler.Device {
return &pb_handler.Device{
AppID: d.AppID,
DevID: d.DevID,
Description: d.Description,
Device: &pb_handler.Device_LoRaWANDevice{LoRaWANDevice: d.ToLoRaWANPb()},
Latitude: d.Latitude,
Longitude: d.Longitude,
Altitude: d.Altitude,
Attri... | go | func (d Device) ToPb() *pb_handler.Device {
return &pb_handler.Device{
AppID: d.AppID,
DevID: d.DevID,
Description: d.Description,
Device: &pb_handler.Device_LoRaWANDevice{LoRaWANDevice: d.ToLoRaWANPb()},
Latitude: d.Latitude,
Longitude: d.Longitude,
Altitude: d.Altitude,
Attri... | [
"func",
"(",
"d",
"Device",
")",
"ToPb",
"(",
")",
"*",
"pb_handler",
".",
"Device",
"{",
"return",
"&",
"pb_handler",
".",
"Device",
"{",
"AppID",
":",
"d",
".",
"AppID",
",",
"DevID",
":",
"d",
".",
"DevID",
",",
"Description",
":",
"d",
".",
"... | // ToPb converts a device struct to its protocol buffer | [
"ToPb",
"converts",
"a",
"device",
"struct",
"to",
"its",
"protocol",
"buffer"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/device/converter.go#L13-L24 |
145,001 | TheThingsNetwork/ttn | core/handler/device/converter.go | ToLoRaWANPb | func (d Device) ToLoRaWANPb() *pb_lorawan.Device {
pbDev := &pb_lorawan.Device{
AppID: d.AppID,
AppEUI: d.AppEUI,
DevID: d.DevID,
DevEUI: d.DevEUI,
DevAddr: &d.DevAddr,
NwkSKey: &d.NwkSKey,
AppSKey: &d... | go | func (d Device) ToLoRaWANPb() *pb_lorawan.Device {
pbDev := &pb_lorawan.Device{
AppID: d.AppID,
AppEUI: d.AppEUI,
DevID: d.DevID,
DevEUI: d.DevEUI,
DevAddr: &d.DevAddr,
NwkSKey: &d.NwkSKey,
AppSKey: &d... | [
"func",
"(",
"d",
"Device",
")",
"ToLoRaWANPb",
"(",
")",
"*",
"pb_lorawan",
".",
"Device",
"{",
"pbDev",
":=",
"&",
"pb_lorawan",
".",
"Device",
"{",
"AppID",
":",
"d",
".",
"AppID",
",",
"AppEUI",
":",
"d",
".",
"AppEUI",
",",
"DevID",
":",
"d",
... | // ToLoRaWANPb converts a device struct to a LoRaWAN protocol buffer | [
"ToLoRaWANPb",
"converts",
"a",
"device",
"struct",
"to",
"a",
"LoRaWAN",
"protocol",
"buffer"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/device/converter.go#L27-L48 |
145,002 | TheThingsNetwork/ttn | core/handler/device/converter.go | FromPb | func FromPb(in *pb_handler.Device) *Device {
d := new(Device)
d.FromPb(in)
return d
} | go | func FromPb(in *pb_handler.Device) *Device {
d := new(Device)
d.FromPb(in)
return d
} | [
"func",
"FromPb",
"(",
"in",
"*",
"pb_handler",
".",
"Device",
")",
"*",
"Device",
"{",
"d",
":=",
"new",
"(",
"Device",
")",
"\n",
"d",
".",
"FromPb",
"(",
"in",
")",
"\n",
"return",
"d",
"\n",
"}"
] | // FromPb returns a new device from the given proto | [
"FromPb",
"returns",
"a",
"new",
"device",
"from",
"the",
"given",
"proto"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/device/converter.go#L51-L55 |
145,003 | TheThingsNetwork/ttn | core/handler/device/converter.go | FromPb | func (d *Device) FromPb(in *pb_handler.Device) {
d.AppID = in.AppID
d.DevID = in.DevID
d.Description = in.Description
d.Latitude = in.Latitude
d.Longitude = in.Longitude
d.Altitude = in.Altitude
d.Attributes = in.Attributes
d.FromLoRaWANPb(in.GetLoRaWANDevice())
} | go | func (d *Device) FromPb(in *pb_handler.Device) {
d.AppID = in.AppID
d.DevID = in.DevID
d.Description = in.Description
d.Latitude = in.Latitude
d.Longitude = in.Longitude
d.Altitude = in.Altitude
d.Attributes = in.Attributes
d.FromLoRaWANPb(in.GetLoRaWANDevice())
} | [
"func",
"(",
"d",
"*",
"Device",
")",
"FromPb",
"(",
"in",
"*",
"pb_handler",
".",
"Device",
")",
"{",
"d",
".",
"AppID",
"=",
"in",
".",
"AppID",
"\n",
"d",
".",
"DevID",
"=",
"in",
".",
"DevID",
"\n",
"d",
".",
"Description",
"=",
"in",
".",
... | // FromPb fills Device fields from a device proto | [
"FromPb",
"fills",
"Device",
"fields",
"from",
"a",
"device",
"proto"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/device/converter.go#L58-L67 |
145,004 | TheThingsNetwork/ttn | core/handler/device/converter.go | FromLoRaWANPb | func (d *Device) FromLoRaWANPb(lorawan *pb_lorawan.Device) {
if lorawan == nil {
return
}
d.AppEUI = lorawan.AppEUI
d.DevEUI = lorawan.DevEUI
if lorawan.DevAddr != nil {
d.DevAddr = *lorawan.DevAddr
}
if lorawan.AppKey != nil {
d.AppKey = *lorawan.AppKey
}
if lorawan.AppSKey != nil {
d.AppSKey = *loraw... | go | func (d *Device) FromLoRaWANPb(lorawan *pb_lorawan.Device) {
if lorawan == nil {
return
}
d.AppEUI = lorawan.AppEUI
d.DevEUI = lorawan.DevEUI
if lorawan.DevAddr != nil {
d.DevAddr = *lorawan.DevAddr
}
if lorawan.AppKey != nil {
d.AppKey = *lorawan.AppKey
}
if lorawan.AppSKey != nil {
d.AppSKey = *loraw... | [
"func",
"(",
"d",
"*",
"Device",
")",
"FromLoRaWANPb",
"(",
"lorawan",
"*",
"pb_lorawan",
".",
"Device",
")",
"{",
"if",
"lorawan",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"d",
".",
"AppEUI",
"=",
"lorawan",
".",
"AppEUI",
"\n",
"d",
".",
"Dev... | // FromLoRaWANPb fills Device fields from a lorawan device proto | [
"FromLoRaWANPb",
"fills",
"Device",
"fields",
"from",
"a",
"lorawan",
"device",
"proto"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/device/converter.go#L70-L106 |
145,005 | TheThingsNetwork/ttn | ttnctl/util/cli_input.go | ReadInput | func ReadInput(reader *bufio.Reader) (string, error) {
input, err := reader.ReadString('\n')
if err != nil {
return "", err
}
return strings.TrimRight(input, "\n"), nil
} | go | func ReadInput(reader *bufio.Reader) (string, error) {
input, err := reader.ReadString('\n')
if err != nil {
return "", err
}
return strings.TrimRight(input, "\n"), nil
} | [
"func",
"ReadInput",
"(",
"reader",
"*",
"bufio",
".",
"Reader",
")",
"(",
"string",
",",
"error",
")",
"{",
"input",
",",
"err",
":=",
"reader",
".",
"ReadString",
"(",
"'\\n'",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
... | // ReadInput allows to read an input line from the user | [
"ReadInput",
"allows",
"to",
"read",
"an",
"input",
"line",
"from",
"the",
"user"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/cli_input.go#L106-L112 |
145,006 | TheThingsNetwork/ttn | utils/security/load_keys.go | LoadKeypair | func LoadKeypair(location string) (*ecdsa.PrivateKey, error) {
priv, err := ioutil.ReadFile(filepath.Clean(location + "/server.key"))
if err != nil {
return nil, err
}
privBlock, _ := pem.Decode(priv)
if privBlock == nil {
return nil, errors.New("No private key data found")
}
privKey, err := x509.ParseECPriv... | go | func LoadKeypair(location string) (*ecdsa.PrivateKey, error) {
priv, err := ioutil.ReadFile(filepath.Clean(location + "/server.key"))
if err != nil {
return nil, err
}
privBlock, _ := pem.Decode(priv)
if privBlock == nil {
return nil, errors.New("No private key data found")
}
privKey, err := x509.ParseECPriv... | [
"func",
"LoadKeypair",
"(",
"location",
"string",
")",
"(",
"*",
"ecdsa",
".",
"PrivateKey",
",",
"error",
")",
"{",
"priv",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"filepath",
".",
"Clean",
"(",
"location",
"+",
"\"",
"\"",
")",
")",
"\n",... | // LoadKeypair loads the keypair in the given location | [
"LoadKeypair",
"loads",
"the",
"keypair",
"in",
"the",
"given",
"location"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/security/load_keys.go#L16-L30 |
145,007 | TheThingsNetwork/ttn | utils/security/load_keys.go | LoadCert | func LoadCert(location string) (cert []byte, err error) {
cert, err = ioutil.ReadFile(filepath.Clean(location + "/server.cert"))
if err != nil {
return
}
return
} | go | func LoadCert(location string) (cert []byte, err error) {
cert, err = ioutil.ReadFile(filepath.Clean(location + "/server.cert"))
if err != nil {
return
}
return
} | [
"func",
"LoadCert",
"(",
"location",
"string",
")",
"(",
"cert",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"cert",
",",
"err",
"=",
"ioutil",
".",
"ReadFile",
"(",
"filepath",
".",
"Clean",
"(",
"location",
"+",
"\"",
"\"",
")",
")",
"\n",
... | // LoadCert loads the certificate in the given location | [
"LoadCert",
"loads",
"the",
"certificate",
"in",
"the",
"given",
"location"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/security/load_keys.go#L33-L39 |
145,008 | TheThingsNetwork/ttn | core/handler/cayennelpp/encoder.go | Encode | func (e *Encoder) Encode(fields map[string]interface{}, fPort uint8) ([]byte, bool, error) {
encoder := protocol.NewEncoder()
for name, value := range fields {
key, channel, err := parseName(name)
if err != nil {
continue
}
switch key {
case valueKey:
if val, ok := value.(float64); ok {
encoder.Ad... | go | func (e *Encoder) Encode(fields map[string]interface{}, fPort uint8) ([]byte, bool, error) {
encoder := protocol.NewEncoder()
for name, value := range fields {
key, channel, err := parseName(name)
if err != nil {
continue
}
switch key {
case valueKey:
if val, ok := value.(float64); ok {
encoder.Ad... | [
"func",
"(",
"e",
"*",
"Encoder",
")",
"Encode",
"(",
"fields",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"fPort",
"uint8",
")",
"(",
"[",
"]",
"byte",
",",
"bool",
",",
"error",
")",
"{",
"encoder",
":=",
"protocol",
".",
"NewEncoder"... | // Encode encodes the fields to CayenneLPP | [
"Encode",
"encodes",
"the",
"fields",
"to",
"CayenneLPP"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/cayennelpp/encoder.go#L16-L31 |
145,009 | TheThingsNetwork/ttn | core/types/json_time.go | BuildTime | func BuildTime(unixNano int64) JSONTime {
if unixNano == 0 {
return JSONTime{}
}
return JSONTime(time.Unix(0, 0).Add(time.Duration(unixNano)).UTC())
} | go | func BuildTime(unixNano int64) JSONTime {
if unixNano == 0 {
return JSONTime{}
}
return JSONTime(time.Unix(0, 0).Add(time.Duration(unixNano)).UTC())
} | [
"func",
"BuildTime",
"(",
"unixNano",
"int64",
")",
"JSONTime",
"{",
"if",
"unixNano",
"==",
"0",
"{",
"return",
"JSONTime",
"{",
"}",
"\n",
"}",
"\n",
"return",
"JSONTime",
"(",
"time",
".",
"Unix",
"(",
"0",
",",
"0",
")",
".",
"Add",
"(",
"time"... | // BuildTime builds a new JSONTime | [
"BuildTime",
"builds",
"a",
"new",
"JSONTime"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/types/json_time.go#L35-L40 |
145,010 | TheThingsNetwork/ttn | core/router/gateway/schedule.go | NewSchedule | func NewSchedule(ctx ttnlog.Interface) Schedule {
s := &schedule{
ctx: ctx,
items: make(map[string]*scheduledItem),
downlinkSubscriptions: make(map[string]chan *router_pb.DownlinkMessage),
}
go func() {
for {
<-time.After(10 * time.Second)
s.RLock()
numItems := len(... | go | func NewSchedule(ctx ttnlog.Interface) Schedule {
s := &schedule{
ctx: ctx,
items: make(map[string]*scheduledItem),
downlinkSubscriptions: make(map[string]chan *router_pb.DownlinkMessage),
}
go func() {
for {
<-time.After(10 * time.Second)
s.RLock()
numItems := len(... | [
"func",
"NewSchedule",
"(",
"ctx",
"ttnlog",
".",
"Interface",
")",
"Schedule",
"{",
"s",
":=",
"&",
"schedule",
"{",
"ctx",
":",
"ctx",
",",
"items",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"scheduledItem",
")",
",",
"downlinkSubscriptions",
... | // NewSchedule creates a new Schedule | [
"NewSchedule",
"creates",
"a",
"new",
"Schedule"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/router/gateway/schedule.go#L39-L64 |
145,011 | TheThingsNetwork/ttn | core/router/gateway/schedule.go | getConflicts | func (s *schedule) getConflicts(timestamp uint32, length uint32) (conflicts uint) {
s.RLock()
defer s.RUnlock()
for _, item := range s.items {
scheduledFrom := uint64(item.timestamp) % uintmax
scheduledTo := scheduledFrom + uint64(item.length)
from := uint64(timestamp)
to := from + uint64(length)
if sched... | go | func (s *schedule) getConflicts(timestamp uint32, length uint32) (conflicts uint) {
s.RLock()
defer s.RUnlock()
for _, item := range s.items {
scheduledFrom := uint64(item.timestamp) % uintmax
scheduledTo := scheduledFrom + uint64(item.length)
from := uint64(timestamp)
to := from + uint64(length)
if sched... | [
"func",
"(",
"s",
"*",
"schedule",
")",
"getConflicts",
"(",
"timestamp",
"uint32",
",",
"length",
"uint32",
")",
"(",
"conflicts",
"uint",
")",
"{",
"s",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"RUnlock",
"(",
")",
"\n",
"for",
"_",
",",
... | // getConflicts walks over the schedule and returns the number of conflicts.
// Both timestamp and length are in microseconds | [
"getConflicts",
"walks",
"over",
"the",
"schedule",
"and",
"returns",
"the",
"number",
"of",
"conflicts",
".",
"Both",
"timestamp",
"and",
"length",
"are",
"in",
"microseconds"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/router/gateway/schedule.go#L104-L128 |
145,012 | TheThingsNetwork/ttn | utils/docs/generate.go | Generate | func Generate(cmd *cobra.Command) string {
buf := new(bytes.Buffer)
cmds := genCmdList(cmd)
sort.Sort(byName(cmds))
for _, cmd := range cmds {
if len(strings.Split(cmd.CommandPath(), " ")) == 1 {
fmt.Fprint(buf, "**Options**\n\n")
printOptions(buf, cmd)
fmt.Fprintln(buf)
continue
}
depth := len(... | go | func Generate(cmd *cobra.Command) string {
buf := new(bytes.Buffer)
cmds := genCmdList(cmd)
sort.Sort(byName(cmds))
for _, cmd := range cmds {
if len(strings.Split(cmd.CommandPath(), " ")) == 1 {
fmt.Fprint(buf, "**Options**\n\n")
printOptions(buf, cmd)
fmt.Fprintln(buf)
continue
}
depth := len(... | [
"func",
"Generate",
"(",
"cmd",
"*",
"cobra",
".",
"Command",
")",
"string",
"{",
"buf",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n\n",
"cmds",
":=",
"genCmdList",
"(",
"cmd",
")",
"\n",
"sort",
".",
"Sort",
"(",
"byName",
"(",
"cmds",
")",... | // Generate prints API docs for a command | [
"Generate",
"prints",
"API",
"docs",
"for",
"a",
"command"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/docs/generate.go#L23-L58 |
145,013 | TheThingsNetwork/ttn | amqp/downlink.go | PublishDownlink | func (c *DefaultPublisher) PublishDownlink(dataDown types.DownlinkMessage) error {
key := DeviceKey{dataDown.AppID, dataDown.DevID, DeviceDownlink, ""}
msg, err := json.Marshal(dataDown)
if err != nil {
return fmt.Errorf("Unable to marshal the message payload: %s", err)
}
return c.publish(key.String(), msg, time... | go | func (c *DefaultPublisher) PublishDownlink(dataDown types.DownlinkMessage) error {
key := DeviceKey{dataDown.AppID, dataDown.DevID, DeviceDownlink, ""}
msg, err := json.Marshal(dataDown)
if err != nil {
return fmt.Errorf("Unable to marshal the message payload: %s", err)
}
return c.publish(key.String(), msg, time... | [
"func",
"(",
"c",
"*",
"DefaultPublisher",
")",
"PublishDownlink",
"(",
"dataDown",
"types",
".",
"DownlinkMessage",
")",
"error",
"{",
"key",
":=",
"DeviceKey",
"{",
"dataDown",
".",
"AppID",
",",
"dataDown",
".",
"DevID",
",",
"DeviceDownlink",
",",
"\"",
... | // PublishDownlink publishes a downlink message to the AMQP broker | [
"PublishDownlink",
"publishes",
"a",
"downlink",
"message",
"to",
"the",
"AMQP",
"broker"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/amqp/downlink.go#L18-L25 |
145,014 | TheThingsNetwork/ttn | core/component/auth.go | InitAuth | func (c *Component) InitAuth() error {
inits := []func() error{
c.initAuthServers,
c.initKeyPair,
c.initRoots,
c.initBgCtx,
}
if c.Config.UseTLS {
inits = append(inits, c.initTLS)
}
for _, init := range inits {
if err := init(); err != nil {
return err
}
}
return nil
} | go | func (c *Component) InitAuth() error {
inits := []func() error{
c.initAuthServers,
c.initKeyPair,
c.initRoots,
c.initBgCtx,
}
if c.Config.UseTLS {
inits = append(inits, c.initTLS)
}
for _, init := range inits {
if err := init(); err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"c",
"*",
"Component",
")",
"InitAuth",
"(",
")",
"error",
"{",
"inits",
":=",
"[",
"]",
"func",
"(",
")",
"error",
"{",
"c",
".",
"initAuthServers",
",",
"c",
".",
"initKeyPair",
",",
"c",
".",
"initRoots",
",",
"c",
".",
"initBgCtx",... | // InitAuth initializes Auth functionality | [
"InitAuth",
"initializes",
"Auth",
"functionality"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/component/auth.go#L33-L51 |
145,015 | TheThingsNetwork/ttn | core/component/auth.go | UpdateTokenKey | func (c *Component) UpdateTokenKey() error {
if c.TokenKeyProvider == nil {
return errors.NewErrInternal("No public key provider configured for token validation")
}
// Set up Auth Server Token Validation
err := c.TokenKeyProvider.Update()
if err != nil {
c.Ctx.Warnf("ttn: Failed to refresh public keys for tok... | go | func (c *Component) UpdateTokenKey() error {
if c.TokenKeyProvider == nil {
return errors.NewErrInternal("No public key provider configured for token validation")
}
// Set up Auth Server Token Validation
err := c.TokenKeyProvider.Update()
if err != nil {
c.Ctx.Warnf("ttn: Failed to refresh public keys for tok... | [
"func",
"(",
"c",
"*",
"Component",
")",
"UpdateTokenKey",
"(",
")",
"error",
"{",
"if",
"c",
".",
"TokenKeyProvider",
"==",
"nil",
"{",
"return",
"errors",
".",
"NewErrInternal",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// Set up Auth Server Token Validati... | // UpdateTokenKey updates the OAuth Bearer token key | [
"UpdateTokenKey",
"updates",
"the",
"OAuth",
"Bearer",
"token",
"key"
] | fc5709a55c20e1712047e5cb5a8d571aa62eefbb | https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/component/auth.go#L107-L121 |
145,016 | 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 |
145,017 | 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 |
145,018 | 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 |
145,019 | 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 |
145,020 | 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 |
145,021 | 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 |
145,022 | 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 |
145,023 | 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 |
145,024 | 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 |
145,025 | 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 |
145,026 | 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 |
145,027 | 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 |
145,028 | 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 |
145,029 | 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 |
145,030 | 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 |
145,031 | 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 |
145,032 | 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 |
145,033 | 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 |
145,034 | 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 |
145,035 | 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 |
145,036 | 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 |
145,037 | 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 |
145,038 | 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 |
145,039 | 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 |
145,040 | 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 |
145,041 | 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 |
145,042 | 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 |
145,043 | 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 |
145,044 | 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 |
145,045 | 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 |
145,046 | 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 |
145,047 | 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 |
145,048 | 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 |
145,049 | 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 |
145,050 | 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 |
145,051 | 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 |
145,052 | 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 |
145,053 | 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 |
145,054 | 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 |
145,055 | 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 |
145,056 | 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 |
145,057 | 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 |
145,058 | 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 |
145,059 | 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 |
145,060 | 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 |
145,061 | 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 |
145,062 | 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 |
145,063 | 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 |
145,064 | 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 |
145,065 | 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 |
145,066 | 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 |
145,067 | 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 |
145,068 | 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 |
145,069 | 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 |
145,070 | 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 |
145,071 | 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 |
145,072 | 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 |
145,073 | 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 |
145,074 | 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 |
145,075 | 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 |
145,076 | 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 |
145,077 | 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 |
145,078 | 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 |
145,079 | 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 |
145,080 | 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 |
145,081 | 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 |
145,082 | 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 |
145,083 | 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 |
145,084 | 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 |
145,085 | 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 |
145,086 | 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 |
145,087 | 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 |
145,088 | 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 |
145,089 | 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 |
145,090 | 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 |
145,091 | 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 |
145,092 | 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 |
145,093 | 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 |
145,094 | 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 |
145,095 | 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 |
145,096 | 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 |
145,097 | 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 |
145,098 | 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 |
145,099 | 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 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.