Skip to content
Snippets Groups Projects

Path traversal demo

Merged Ghost User requested to merge path-traversal-demo into 67-overhaul-architecture
Files
11
cmd/gnmi/gnmi.go 0 → 100644
+ 49
0
package main
import (
"code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi"
"code.fbi.h-da.de/cocsn/gosdn/nucleus"
"code.fbi.h-da.de/cocsn/yang-models/generated/openconfig"
"context"
"fmt"
"github.com/google/uuid"
log "github.com/sirupsen/logrus"
)
func main() {
log.SetLevel(log.DebugLevel)
sbi := &nucleus.OpenConfig{}
device := nucleus.Device{
Device: &openconfig.Device{},
SBI: sbi,
Config: nucleus.DeviceConfig{
Uuid: uuid.New(),
Address: "[fdfd::ce05]:6030",
Username: "admin",
Password: "arista",
},
}
pnd := nucleus.NewPND("openconfig", sbi)
if err := pnd.AddDevice(device); err != nil {
log.Fatal(err)
}
cfg := &gnmi.Config{
Addr: device.Config.Address,
Password: device.Config.Password,
Username: device.Config.Username,
}
ctx := gnmi.NewContext(context.Background(), cfg)
ctx = context.WithValue(ctx, "config", cfg)
paths := []string{"/interfaces/interface[name=*]/name"}
req, err := gnmi.NewGetRequest(gnmi.SplitPaths(paths), "")
resp, err := nucleus.GetWithRequest(ctx, req)
if err != nil {
log.Fatal(err)
}
if err := device.Add(resp); err != nil {
panic(err)
}
fmt.Println(device.Config)
}
Loading