From ff5af6936d4e38dafef52fa44a07033b6a53490f Mon Sep 17 00:00:00 2001 From: Sergiusz Bazanski Date: Wed, 29 Aug 2018 19:20:46 +0100 Subject: [PATCH 1/6] Initial commit --- .gitignore | 2 + COPYING | 13 +++ cli.go | 243 ++++++++++++++++++++++++++++++++++++++++++++++ main.go | 131 +++++++++++++++++++++++++ proto/generate.go | 3 + proxy.proto | 15 +++ 6 files changed, 407 insertions(+) create mode 100644 .gitignore create mode 100644 COPYING create mode 100644 cli.go create mode 100644 main.go create mode 100644 proto/generate.go create mode 100644 proxy.proto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b1a1261 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*swp +proto/*pb.go diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..314a889 --- /dev/null +++ b/COPYING @@ -0,0 +1,13 @@ +Copyright (C) 2018 Serge Bazanski + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/cli.go b/cli.go new file mode 100644 index 0000000..b9642cf --- /dev/null +++ b/cli.go @@ -0,0 +1,243 @@ +package main + +import ( + "context" + "fmt" + "strings" + + "github.com/golang/glog" + "github.com/ziutek/telnet" + "golang.org/x/net/trace" +) + +type cliClient struct { + conn *telnet.Conn + + username string + password string + + loggedIn bool + promptHostname string +} + +func newCliClient(c *telnet.Conn, username, password string) *cliClient { + return &cliClient{ + conn: c, + username: username, + password: password, + } +} + +func (c *cliClient) readUntil(ctx context.Context, delims ...string) (string, error) { + chStr := make(chan string, 1) + chErr := make(chan error, 1) + go func() { + s, err := c.conn.ReadUntil(delims...) + if err != nil { + chErr <- err + return + } + chStr <- string(s) + }() + + select { + case <-ctx.Done(): + return "", fmt.Errorf("context done") + case err := <-chErr: + c.trace(ctx, "readUntil failed: %v", err) + return "", err + case s := <-chStr: + c.trace(ctx, "readUntil <- %q", s) + return s, nil + + } +} + +func (c *cliClient) readString(ctx context.Context, delim byte) (string, error) { + chStr := make(chan string, 1) + chErr := make(chan error, 1) + go func() { + s, err := c.conn.ReadString(delim) + if err != nil { + chErr <- err + return + } + chStr <- s + }() + + select { + case <-ctx.Done(): + return "", fmt.Errorf("context done") + case err := <-chErr: + c.trace(ctx, "readString failed: %v", err) + return "", err + case s := <-chStr: + c.trace(ctx, "readString <- %q", s) + return s, nil + + } +} + +func (c *cliClient) writeLine(ctx context.Context, s string) error { + n, err := c.conn.Write([]byte(s + "\n")) + if got, want := n, len(s)+1; got != want { + err = fmt.Errorf("wrote %d bytes out of %d", got, want) + } + if err != nil { + c.trace(ctx, "writeLine failed: %v", err) + return err + } + c.trace(ctx, "writeLine -> %q", s) + return nil +} + +func (c *cliClient) trace(ctx context.Context, f string, parts ...interface{}) { + tr, ok := trace.FromContext(ctx) + if !ok { + fmted := fmt.Sprintf(f, parts...) + glog.Infof("[no trace] %s", fmted) + return + } + tr.LazyPrintf(f, parts...) +} + +func (c *cliClient) logIn(ctx context.Context) error { + if c.loggedIn { + return nil + } + + // Provide username. + prompt, err := c.readString(ctx, ':') + if err != nil { + return fmt.Errorf("could not read username prompt: %v", err) + } + if !strings.HasSuffix(prompt, "User:") { + return fmt.Errorf("invalid username prompt: %v", err) + } + if err := c.writeLine(ctx, c.username); err != nil { + return fmt.Errorf("could not write username: %v") + } + + // Provide password. + prompt, err = c.readString(ctx, ':') + if err != nil { + return fmt.Errorf("could not read password prompt: %v", err) + } + if !strings.HasSuffix(prompt, "Password:") { + return fmt.Errorf("invalid password prompt: %v", err) + } + if err := c.writeLine(ctx, c.password); err != nil { + return fmt.Errorf("could not write password: %v") + } + + // Get unprivileged prompt. + prompt, err = c.readString(ctx, '>') + if err != nil { + return fmt.Errorf("could not read unprivileged prompt: %v", err) + } + + parts := strings.Split(prompt, "\r\n") + c.promptHostname = strings.TrimSuffix(parts[len(parts)-1], ">") + + // Enable privileged mode. + + if err := c.writeLine(ctx, "enable"); err != nil { + return fmt.Errorf("could not write enable: %v") + } + + // Provide password (again) + prompt, err = c.readString(ctx, ':') + if err != nil { + return fmt.Errorf("could not read password prompt: %v", err) + } + if !strings.HasSuffix(prompt, "Password:") { + return fmt.Errorf("invalid password prompt: %v", err) + } + if err := c.writeLine(ctx, c.password); err != nil { + return fmt.Errorf("could not write password: %v") + } + + // Get privileged prompt. + prompt, err = c.readString(ctx, '#') + if err != nil { + return fmt.Errorf("could not read privileged prompt: %v", err) + } + + if !strings.HasSuffix(prompt, c.promptHostname+"#") { + return fmt.Errorf("unexpected privileged prompt: %v", prompt) + } + + // Disable pager. + if err := c.writeLine(ctx, "terminal length 0"); err != nil { + return fmt.Errorf("could not diable pager: %v", err) + } + prompt, err = c.readString(ctx, '#') + if err != nil { + return fmt.Errorf("could not disable pager: %v", err) + } + if !strings.HasSuffix(prompt, c.promptHostname+"#") { + return fmt.Errorf("unexpected privileged prompt: %v", prompt) + } + + // Success! + c.loggedIn = true + c.trace(ctx, "logged into %v", c.promptHostname) + return nil +} + +func (c *cliClient) runCommand(ctx context.Context, command string) ([]string, string, error) { + if err := c.logIn(ctx); err != nil { + return nil, "", fmt.Errorf("could not log in: %v", err) + } + + // First, synchronize to prompt. + attempts := 3 + for { + c.writeLine(ctx, "") + line, err := c.readString(ctx, '\n') + if err != nil { + return nil, "", fmt.Errorf("while synchronizing to prompt: %v", err) + } + line = strings.Trim(line, "\r\n") + if strings.HasSuffix(line, c.promptHostname+"#") { + break + } + + attempts -= 1 + if attempts == 0 { + return nil, "", fmt.Errorf("could not find prompt, last result %q", line) + } + } + + // Send comand. + c.writeLine(ctx, command) + + // First, read until prompt again. + if _, err := c.readUntil(ctx, c.promptHostname+"#"); err != nil { + return nil, "", fmt.Errorf("could not get command hostname echo: %v", err) + } + + loopback, err := c.readUntil(ctx, "\r\n") + if err != nil { + return nil, "", fmt.Errorf("could not get command loopback: %v", err) + } + loopback = strings.Trim(loopback, "\r\n") + c.trace(ctx, "effective command: %q", loopback) + + // Read until we have a standalone prompt with no newline afterwards. + data, err := c.readUntil(ctx, c.promptHostname+"#") + if err != nil { + return nil, "", fmt.Errorf("could not get command results: %v", err) + } + + lines := []string{} + for _, line := range strings.Split(data, "\r\n") { + if line == c.promptHostname+"#" { + break + } + lines = append(lines, line) + } + c.trace(ctx, "command %q returned lines: %v", command, lines) + + return lines, loopback, nil +} diff --git a/main.go b/main.go new file mode 100644 index 0000000..8f26e0b --- /dev/null +++ b/main.go @@ -0,0 +1,131 @@ +package main + +import ( + "context" + "flag" + "net" + "net/http" + + "code.hackerspace.pl/q3k/hspki" + "github.com/golang/glog" + "github.com/q3k/statusz" + "github.com/ziutek/telnet" + "golang.org/x/net/trace" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/reflection" + "google.golang.org/grpc/status" + + pb "code.hackerspace.pl/q3k/m6220-proxy/proto" +) + +var ( + flagListenAddress string + flagDebugAddress string + flagSwitchAddress string + flagSwitchUsername string + flagSwitchPassword string +) + +func init() { + flag.Set("logtostderr", "true") +} + +type service struct { + connectionSemaphore chan int +} + +func (s *service) connect() (*cliClient, error) { + s.connectionSemaphore <- 1 + conn, err := telnet.Dial("tcp", flagSwitchAddress) + if err != nil { + <-s.connectionSemaphore + return nil, err + } + + cli := newCliClient(conn, flagSwitchUsername, flagSwitchPassword) + return cli, nil +} + +func (s *service) disconnect() { + <-s.connectionSemaphore +} + +func (s *service) RunCommand(ctx context.Context, req *pb.RunCommandRequest) (*pb.RunCommandResponse, error) { + if req.Command == "" { + return nil, status.Error(codes.InvalidArgument, "command cannot be null") + } + + cli, err := s.connect() + if err != nil { + return nil, status.Error(codes.Unavailable, "could not connect to backend") + } + defer s.disconnect() + + lines, effective, err := cli.runCommand(ctx, req.Command) + if err != nil { + return nil, err + } + res := &pb.RunCommandResponse{ + EffectiveCommand: effective, + Lines: lines, + } + return res, nil +} + +func main() { + flag.StringVar(&flagListenAddress, "listen_address", "127.0.0.1:42000", "Address to listen on for gRPC") + flag.StringVar(&flagDebugAddress, "debug_address", "127.0.0.1:42001", "Address to listen on for Debug HTTP") + flag.StringVar(&flagSwitchAddress, "switch_address", "127.0.0.1:23", "Telnet address of M6220") + flag.StringVar(&flagSwitchUsername, "switch_username", "admin", "Switch login username") + flag.StringVar(&flagSwitchPassword, "switch_password", "admin", "Switch login password") + flag.Parse() + + s := &service{ + connectionSemaphore: make(chan int, 1), + } + + grpc.EnableTracing = true + grpcLis, err := net.Listen("tcp", flagListenAddress) + if err != nil { + glog.Exitf("Could not listen on %v: %v", flagListenAddress, err) + } + grpcSrv := grpc.NewServer(hspki.WithServerHSPKI()...) + pb.RegisterM6220ProxyServer(grpcSrv, s) + reflection.Register(grpcSrv) + + glog.Infof("Starting gRPC on %v", flagListenAddress) + go func() { + if err := grpcSrv.Serve(grpcLis); err != nil { + glog.Exitf("Could not start gRPC: %v", err) + } + }() + + if flagDebugAddress != "" { + glog.Infof("Starting debug on %v", flagDebugAddress) + httpMux := http.NewServeMux() + httpMux.HandleFunc("/debug/status", statusz.StatusHandler) + httpMux.HandleFunc("/debug/requests", trace.Traces) + httpMux.HandleFunc("/", statusz.StatusHandler) + + httpLis, err := net.Listen("tcp", flagDebugAddress) + if err != nil { + glog.Exitf("Could not listen on %v: %v", flagDebugAddress, err) + } + httpSrv := &http.Server{ + Addr: flagDebugAddress, + Handler: httpMux, + } + + go func() { + if err := httpSrv.Serve(httpLis); err != nil { + glog.Exitf("Could not start HTTP server: %v", err) + } + }() + + } + + glog.Infof("Running!") + + select {} +} diff --git a/proto/generate.go b/proto/generate.go new file mode 100644 index 0000000..fc6193d --- /dev/null +++ b/proto/generate.go @@ -0,0 +1,3 @@ +//go:generate protoc -I.. ../proxy.proto --go_out=plugins=grpc:. + +package proto diff --git a/proxy.proto b/proxy.proto new file mode 100644 index 0000000..d35a2c3 --- /dev/null +++ b/proxy.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package proto; + +message RunCommandRequest { + string command = 1; +}; + +message RunCommandResponse { + string effective_command = 1; + repeated string lines = 2; +}; + +service M6220Proxy { + rpc RunCommand(RunCommandRequest) returns (RunCommandResponse); +}; From c1515cb4a62d020b0cd7cdd8535f6b615e108e14 Mon Sep 17 00:00:00 2001 From: Serge Bazanski Date: Thu, 4 Oct 2018 10:36:29 +0100 Subject: [PATCH 2/6] implement basic SwitchControl rpc --- main.go | 189 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 188 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 8f26e0b..a1ea7ca 100644 --- a/main.go +++ b/main.go @@ -3,8 +3,12 @@ package main import ( "context" "flag" + "fmt" "net" "net/http" + "reflect" + "strconv" + "strings" "code.hackerspace.pl/q3k/hspki" "github.com/golang/glog" @@ -17,6 +21,7 @@ import ( "google.golang.org/grpc/status" pb "code.hackerspace.pl/q3k/m6220-proxy/proto" + tpb "code.hackerspace.pl/q3k/topo/proto/control" ) var ( @@ -58,7 +63,7 @@ func (s *service) RunCommand(ctx context.Context, req *pb.RunCommandRequest) (*p cli, err := s.connect() if err != nil { - return nil, status.Error(codes.Unavailable, "could not connect to backend") + return nil, status.Error(codes.Unavailable, "could not connect to switch") } defer s.disconnect() @@ -73,6 +78,187 @@ func (s *service) RunCommand(ctx context.Context, req *pb.RunCommandRequest) (*p return res, nil } +func (s *service) parseInterfaceStatus(res *tpb.GetPortsResponse, lines []string) error { + if len(lines) < 4 { + return fmt.Errorf("need at least 4 lines of output, got %d", len(lines)) + } + if lines[0] != "" { + return fmt.Errorf("expected first line to be empty, is %q", lines[0]) + } + header1parts := strings.Fields(lines[1]) + if want := []string{"Port", "Description", "Duplex", "Speed", "Neg", "Link", "Flow", "Control"}; !reflect.DeepEqual(want, header1parts) { + return fmt.Errorf("expected header1 to be %v, got %v", want, header1parts) + } + + header2parts := strings.Fields(lines[2]) + if want := []string{"State", "Status"}; !reflect.DeepEqual(want, header2parts) { + return fmt.Errorf("expected header2 to be %v, got %v", want, header2parts) + } + + if lines[3][0] != '-' { + return fmt.Errorf("expected header3 to start with -, got %q", lines[3]) + } + + for _, line := range lines[4:] { + parts := strings.Fields(line) + if len(parts) < 6 { + break + } + portName := parts[0] + if strings.HasPrefix(portName, "Gi") && strings.HasPrefix(portName, "Ti") { + break + } + + speedStr := parts[len(parts)-4] + stateStr := parts[len(parts)-2] + + port := &tpb.SwitchPort{ + Name: portName, + } + if speedStr == "100" { + port.Speed = tpb.SwitchPort_SPEED_100M + } else if speedStr == "1000" { + port.Speed = tpb.SwitchPort_SPEED_1G + } else if speedStr == "10000" { + port.Speed = tpb.SwitchPort_SPEED_10G + } + if stateStr == "Up" { + port.LinkState = tpb.SwitchPort_LINKSTATE_UP + } else if stateStr == "Down" { + port.LinkState = tpb.SwitchPort_LINKSTATE_DOWN + } + + res.Ports = append(res.Ports, port) + } + + return nil +} + +func (s *service) parseInterfaceConfig(port *tpb.SwitchPort, lines []string) error { + glog.Infof("%+v", port) + for _, line := range lines { + glog.Infof("%s: %q", port.Name, line) + parts := strings.Fields(line) + if len(parts) < 1 { + continue + } + + if len(parts) >= 2 && parts[0] == "switchport" { + if parts[1] == "mode" { + if port.PortMode != tpb.SwitchPort_PORTMODE_INVALID { + return fmt.Errorf("redefinition of switchport mode") + } + if parts[2] == "access" { + port.PortMode = tpb.SwitchPort_PORTMODE_SWITCHPORT_UNTAGGED + } else if parts[2] == "trunk" { + port.PortMode = tpb.SwitchPort_PORTMODE_SWITCHPORT_TAGGED + } else if parts[2] == "general" { + port.PortMode = tpb.SwitchPort_PORTMODE_SWITCHPORT_GENERIC + } else { + port.PortMode = tpb.SwitchPort_PORTMODE_MANGLED + } + } + + if parts[1] == "access" { + if port.PortMode == tpb.SwitchPort_PORTMODE_INVALID { + port.PortMode = tpb.SwitchPort_PORTMODE_SWITCHPORT_UNTAGGED + } + if len(parts) > 3 && parts[2] == "vlan" { + vlan, err := strconv.Atoi(parts[3]) + if err != nil { + return fmt.Errorf("invalid vlan: %q", parts[3]) + } + port.VlanNative = int32(vlan) + } + } + + if parts[1] == "trunk" { + if len(parts) >= 5 && parts[2] == "allowed" && parts[3] == "vlan" { + vlans := strings.Split(parts[4], ",") + for _, vlan := range vlans { + vlanNum, err := strconv.Atoi(vlan) + if err != nil { + return fmt.Errorf("invalid vlan: %q", parts[3]) + } + port.VlanTagged = append(port.VlanTagged, int32(vlanNum)) + } + } + } + } else if len(parts) >= 2 && parts[0] == "mtu" { + mtu, err := strconv.Atoi(parts[1]) + if err != nil { + return fmt.Errorf("invalid mtu: %q", parts[3]) + } + port.Mtu = int32(mtu) + } else if len(parts) >= 2 && parts[0] == "spanning-tree" && parts[1] == "portfast" { + port.SpanningTreeMode = tpb.SwitchPort_SPANNING_TREE_MODE_PORTFAST + } + } + + // no mode -> access + if port.PortMode == tpb.SwitchPort_PORTMODE_INVALID { + port.PortMode = tpb.SwitchPort_PORTMODE_SWITCHPORT_UNTAGGED + } + + // apply defaults + if port.Mtu == 0 { + port.Mtu = 1500 + } + if port.SpanningTreeMode == tpb.SwitchPort_SPANNING_TREE_MODE_INVALID { + port.SpanningTreeMode = tpb.SwitchPort_SPANNING_TREE_MODE_AUTO_PORTFAST + } + + // sanitize + if port.PortMode == tpb.SwitchPort_PORTMODE_SWITCHPORT_UNTAGGED { + port.VlanTagged = []int32{} + port.Prefixes = []string{} + if port.VlanNative == 0 { + port.VlanNative = 1 + } + } else if port.PortMode == tpb.SwitchPort_PORTMODE_SWITCHPORT_TAGGED { + port.VlanNative = 0 + port.Prefixes = []string{} + } else if port.PortMode == tpb.SwitchPort_PORTMODE_SWITCHPORT_GENERIC { + port.Prefixes = []string{} + if port.VlanNative == 0 { + port.VlanNative = 1 + } + } + return nil +} + +func (s *service) GetPorts(ctx context.Context, req *tpb.GetPortsRequest) (*tpb.GetPortsResponse, error) { + cli, err := s.connect() + if err != nil { + return nil, status.Error(codes.Unavailable, "could not connect to switch") + } + defer s.disconnect() + res := &tpb.GetPortsResponse{} + + statusLines, _, err := cli.runCommand(ctx, "show interface status") + if err != nil { + return nil, status.Error(codes.Unavailable, "could not get interface status from switch") + } + + err = s.parseInterfaceStatus(res, statusLines) + if err != nil { + return nil, status.Errorf(codes.Unavailable, "could not parse interface status from switch: %v", err) + } + + for _, port := range res.Ports { + configLines, _, err := cli.runCommand(ctx, "show run interface "+port.Name) + if err != nil { + return nil, status.Error(codes.Unavailable, "could not get interface config from switch") + } + err = s.parseInterfaceConfig(port, configLines) + if err != nil { + return nil, status.Errorf(codes.Unavailable, "could not parse interface config from switch: %v", err) + } + } + + return res, nil +} + func main() { flag.StringVar(&flagListenAddress, "listen_address", "127.0.0.1:42000", "Address to listen on for gRPC") flag.StringVar(&flagDebugAddress, "debug_address", "127.0.0.1:42001", "Address to listen on for Debug HTTP") @@ -92,6 +278,7 @@ func main() { } grpcSrv := grpc.NewServer(hspki.WithServerHSPKI()...) pb.RegisterM6220ProxyServer(grpcSrv, s) + tpb.RegisterSwitchControlServer(grpcSrv, s) reflection.Register(grpcSrv) glog.Infof("Starting gRPC on %v", flagListenAddress) From c681a753b70098ef89d023ba768a920a3017a264 Mon Sep 17 00:00:00 2001 From: Serge Bazanski Date: Fri, 5 Oct 2018 14:32:42 -0700 Subject: [PATCH 3/6] godepify --- .gitignore | 3 +- Gopkg.lock | 202 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Gopkg.toml | 3 + 3 files changed, 207 insertions(+), 1 deletion(-) create mode 100644 Gopkg.lock create mode 100644 Gopkg.toml diff --git a/.gitignore b/.gitignore index b1a1261..273f940 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *swp -proto/*pb.go +m6220-proxy +vendor diff --git a/Gopkg.lock b/Gopkg.lock new file mode 100644 index 0000000..021cdaf --- /dev/null +++ b/Gopkg.lock @@ -0,0 +1,202 @@ +# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. + + +[[projects]] + branch = "master" + digest = "1:4c2ac02d97eb43f0363a194c63b27916957ad3a03158b803341821420c2a4ff5" + name = "code.hackerspace.pl/q3k/hspki" + packages = ["."] + pruneopts = "" + revision = "52478b5627a4c1eb0f73651133912ca4f15943de" + +[[projects]] + branch = "master" + digest = "1:14b1158c5d9600d72f8ac88acd9c68a90e9f2fc021a9fc7f3be1274eb0b4ed5f" + name = "code.hackerspace.pl/q3k/topo" + packages = ["proto/control"] + pruneopts = "" + revision = "4b6f33ae2139635b13d2cef2c1767e983a8b46b9" + +[[projects]] + digest = "1:f82b8ac36058904227087141017bb82f4b0fc58272990a4cdae3e2d6d222644e" + name = "github.com/StackExchange/wmi" + packages = ["."] + pruneopts = "" + revision = "5d049714c4a64225c3c79a7cf7d02f7fb5b96338" + version = "1.0.0" + +[[projects]] + digest = "1:96c4a6ff4206086347bfe28e96e092642882128f45ecb8dc8f15f3e6f6703af0" + name = "github.com/go-ole/go-ole" + packages = [ + ".", + "oleutil", + ] + pruneopts = "" + revision = "a41e3c4b706f6ae8dfbff342b06e40fa4d2d0506" + version = "v1.2.1" + +[[projects]] + branch = "master" + digest = "1:107b233e45174dbab5b1324201d092ea9448e58243ab9f039e4c0f332e121e3a" + name = "github.com/golang/glog" + packages = ["."] + pruneopts = "" + revision = "23def4e6c14b4da8ac2ed8007337bc5eb5007998" + +[[projects]] + digest = "1:3dd078fda7500c341bc26cfbc6c6a34614f295a2457149fc1045cab767cbcf18" + name = "github.com/golang/protobuf" + packages = [ + "proto", + "protoc-gen-go/descriptor", + "ptypes", + "ptypes/any", + "ptypes/duration", + "ptypes/timestamp", + ] + pruneopts = "" + revision = "aa810b61a9c79d51363740d207bb46cf8e620ed5" + version = "v1.2.0" + +[[projects]] + branch = "master" + digest = "1:a7cc4447e0c2432f217fd2bed937c100ec475272a7a9306477170c2934297357" + name = "github.com/q3k/statusz" + packages = ["."] + pruneopts = "" + revision = "924f04ea71149b75f5b10f426cc4c39d6d90f6f2" + +[[projects]] + branch = "master" + digest = "1:de915fe805e4705ebc785cc3e758992c11156800e2c65781cf7db4c0a7ab2d41" + name = "github.com/shirou/gopsutil" + packages = [ + "internal/common", + "load", + ] + pruneopts = "" + revision = "a11c78ba2c13c5b1ee59c53296ba35f92f0ce658" + +[[projects]] + branch = "master" + digest = "1:d5a3dc85da58a5d8eb013bed68d82c351cd0cd8237ead400a73c25597e31730e" + name = "github.com/ziutek/telnet" + packages = ["."] + pruneopts = "" + revision = "c3b780dc415b28894076b4ec975ea3ea69e3980f" + +[[projects]] + branch = "master" + digest = "1:3a3c1b660248c0ec25f00cfb9c6526bd5b0ede4c8bfa2ed56a3f5e7e9d0a19cd" + name = "golang.org/x/net" + packages = [ + "context", + "http/httpguts", + "http2", + "http2/hpack", + "idna", + "internal/timeseries", + "trace", + ] + pruneopts = "" + revision = "146acd28ed5894421fb5aac80ca93bc1b1f46f87" + +[[projects]] + branch = "master" + digest = "1:a4bda6e065eb3ccf1e6adeaa863cb416e0ae6b43e613f20a8931d52d19dc20e2" + name = "golang.org/x/sys" + packages = [ + "unix", + "windows", + ] + pruneopts = "" + revision = "4497e2df6f9e69048a54498c7affbbec3294ad47" + +[[projects]] + digest = "1:5acd3512b047305d49e8763eef7ba423901e85d5dd2fd1e71778a0ea8de10bd4" + name = "golang.org/x/text" + packages = [ + "collate", + "collate/build", + "internal/colltab", + "internal/gen", + "internal/tag", + "internal/triegen", + "internal/ucd", + "language", + "secure/bidirule", + "transform", + "unicode/bidi", + "unicode/cldr", + "unicode/norm", + "unicode/rangetable", + ] + pruneopts = "" + revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0" + version = "v0.3.0" + +[[projects]] + branch = "master" + digest = "1:1b3b4ec811695907c4a3cb92e4f32834a4a42459bff7e02068b6b2b5344803cd" + name = "google.golang.org/genproto" + packages = ["googleapis/rpc/status"] + pruneopts = "" + revision = "af9cb2a35e7f169ec875002c1829c9b315cddc04" + +[[projects]] + digest = "1:15656947b87a6a240e61dcfae9e71a55a8d5677f240d12ab48f02cdbabf1e309" + name = "google.golang.org/grpc" + packages = [ + ".", + "balancer", + "balancer/base", + "balancer/roundrobin", + "codes", + "connectivity", + "credentials", + "encoding", + "encoding/proto", + "grpclog", + "internal", + "internal/backoff", + "internal/channelz", + "internal/envconfig", + "internal/grpcrand", + "internal/transport", + "keepalive", + "metadata", + "naming", + "peer", + "reflection", + "reflection/grpc_reflection_v1alpha", + "resolver", + "resolver/dns", + "resolver/passthrough", + "stats", + "status", + "tap", + ] + pruneopts = "" + revision = "8dea3dc473e90c8179e519d91302d0597c0ca1d1" + version = "v1.15.0" + +[solve-meta] + analyzer-name = "dep" + analyzer-version = 1 + input-imports = [ + "code.hackerspace.pl/q3k/hspki", + "code.hackerspace.pl/q3k/topo/proto/control", + "github.com/golang/glog", + "github.com/golang/protobuf/proto", + "github.com/q3k/statusz", + "github.com/ziutek/telnet", + "golang.org/x/net/context", + "golang.org/x/net/trace", + "google.golang.org/grpc", + "google.golang.org/grpc/codes", + "google.golang.org/grpc/reflection", + "google.golang.org/grpc/status", + ] + solver-name = "gps-cdcl" + solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml new file mode 100644 index 0000000..2d09d86 --- /dev/null +++ b/Gopkg.toml @@ -0,0 +1,3 @@ +[[constraint]] + name = "code.hackerspace.pl/q3k/topo" + branch = "master" From 62123e80681faa57c9430e167c58b505a56e2f5a Mon Sep 17 00:00:00 2001 From: Serge Bazanski Date: Fri, 5 Oct 2018 14:32:59 -0700 Subject: [PATCH 4/6] commit proto stubs --- proto/proxy.pb.go | 203 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 203 insertions(+) create mode 100644 proto/proxy.pb.go diff --git a/proto/proxy.pb.go b/proto/proxy.pb.go new file mode 100644 index 0000000..148b878 --- /dev/null +++ b/proto/proxy.pb.go @@ -0,0 +1,203 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: proxy.proto + +package proto + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + context "golang.org/x/net/context" + grpc "google.golang.org/grpc" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package + +type RunCommandRequest struct { + Command string `protobuf:"bytes,1,opt,name=command,proto3" json:"command,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *RunCommandRequest) Reset() { *m = RunCommandRequest{} } +func (m *RunCommandRequest) String() string { return proto.CompactTextString(m) } +func (*RunCommandRequest) ProtoMessage() {} +func (*RunCommandRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_700b50b08ed8dbaf, []int{0} +} + +func (m *RunCommandRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_RunCommandRequest.Unmarshal(m, b) +} +func (m *RunCommandRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_RunCommandRequest.Marshal(b, m, deterministic) +} +func (m *RunCommandRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_RunCommandRequest.Merge(m, src) +} +func (m *RunCommandRequest) XXX_Size() int { + return xxx_messageInfo_RunCommandRequest.Size(m) +} +func (m *RunCommandRequest) XXX_DiscardUnknown() { + xxx_messageInfo_RunCommandRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_RunCommandRequest proto.InternalMessageInfo + +func (m *RunCommandRequest) GetCommand() string { + if m != nil { + return m.Command + } + return "" +} + +type RunCommandResponse struct { + EffectiveCommand string `protobuf:"bytes,1,opt,name=effective_command,json=effectiveCommand,proto3" json:"effective_command,omitempty"` + Lines []string `protobuf:"bytes,2,rep,name=lines,proto3" json:"lines,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *RunCommandResponse) Reset() { *m = RunCommandResponse{} } +func (m *RunCommandResponse) String() string { return proto.CompactTextString(m) } +func (*RunCommandResponse) ProtoMessage() {} +func (*RunCommandResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_700b50b08ed8dbaf, []int{1} +} + +func (m *RunCommandResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_RunCommandResponse.Unmarshal(m, b) +} +func (m *RunCommandResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_RunCommandResponse.Marshal(b, m, deterministic) +} +func (m *RunCommandResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_RunCommandResponse.Merge(m, src) +} +func (m *RunCommandResponse) XXX_Size() int { + return xxx_messageInfo_RunCommandResponse.Size(m) +} +func (m *RunCommandResponse) XXX_DiscardUnknown() { + xxx_messageInfo_RunCommandResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_RunCommandResponse proto.InternalMessageInfo + +func (m *RunCommandResponse) GetEffectiveCommand() string { + if m != nil { + return m.EffectiveCommand + } + return "" +} + +func (m *RunCommandResponse) GetLines() []string { + if m != nil { + return m.Lines + } + return nil +} + +func init() { + proto.RegisterType((*RunCommandRequest)(nil), "proto.RunCommandRequest") + proto.RegisterType((*RunCommandResponse)(nil), "proto.RunCommandResponse") +} + +func init() { proto.RegisterFile("proxy.proto", fileDescriptor_700b50b08ed8dbaf) } + +var fileDescriptor_700b50b08ed8dbaf = []byte{ + // 165 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2e, 0x28, 0xca, 0xaf, + 0xa8, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x05, 0x53, 0x4a, 0xba, 0x5c, 0x82, 0x41, + 0xa5, 0x79, 0xce, 0xf9, 0xb9, 0xb9, 0x89, 0x79, 0x29, 0x41, 0xa9, 0x85, 0xa5, 0xa9, 0xc5, 0x25, + 0x42, 0x12, 0x5c, 0xec, 0xc9, 0x10, 0x11, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x18, 0x57, + 0x29, 0x9c, 0x4b, 0x08, 0x59, 0x79, 0x71, 0x41, 0x7e, 0x5e, 0x71, 0xaa, 0x90, 0x36, 0x97, 0x60, + 0x6a, 0x5a, 0x5a, 0x6a, 0x72, 0x49, 0x66, 0x59, 0x6a, 0x3c, 0xaa, 0x4e, 0x01, 0xb8, 0x04, 0x54, + 0x93, 0x90, 0x08, 0x17, 0x6b, 0x4e, 0x66, 0x5e, 0x6a, 0xb1, 0x04, 0x93, 0x02, 0xb3, 0x06, 0x67, + 0x10, 0x84, 0x63, 0xe4, 0xcf, 0xc5, 0xe5, 0x6b, 0x66, 0x64, 0x64, 0x10, 0x00, 0x72, 0xa2, 0x90, + 0x23, 0x17, 0x17, 0xc2, 0x1a, 0x21, 0x09, 0x88, 0x93, 0xf5, 0x30, 0x1c, 0x2a, 0x25, 0x89, 0x45, + 0x06, 0xe2, 0xa6, 0x24, 0x36, 0xb0, 0x8c, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x39, 0x6d, 0xab, + 0xdd, 0xf5, 0x00, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// M6220ProxyClient is the client API for M6220Proxy service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type M6220ProxyClient interface { + RunCommand(ctx context.Context, in *RunCommandRequest, opts ...grpc.CallOption) (*RunCommandResponse, error) +} + +type m6220ProxyClient struct { + cc *grpc.ClientConn +} + +func NewM6220ProxyClient(cc *grpc.ClientConn) M6220ProxyClient { + return &m6220ProxyClient{cc} +} + +func (c *m6220ProxyClient) RunCommand(ctx context.Context, in *RunCommandRequest, opts ...grpc.CallOption) (*RunCommandResponse, error) { + out := new(RunCommandResponse) + err := c.cc.Invoke(ctx, "/proto.M6220Proxy/RunCommand", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// M6220ProxyServer is the server API for M6220Proxy service. +type M6220ProxyServer interface { + RunCommand(context.Context, *RunCommandRequest) (*RunCommandResponse, error) +} + +func RegisterM6220ProxyServer(s *grpc.Server, srv M6220ProxyServer) { + s.RegisterService(&_M6220Proxy_serviceDesc, srv) +} + +func _M6220Proxy_RunCommand_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RunCommandRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(M6220ProxyServer).RunCommand(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.M6220Proxy/RunCommand", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(M6220ProxyServer).RunCommand(ctx, req.(*RunCommandRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _M6220Proxy_serviceDesc = grpc.ServiceDesc{ + ServiceName: "proto.M6220Proxy", + HandlerType: (*M6220ProxyServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "RunCommand", + Handler: _M6220Proxy_RunCommand_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "proxy.proto", +} From 0f04bfa084253c3d936b027e4f845f42a32f7fc3 Mon Sep 17 00:00:00 2001 From: Serge Bazanski Date: Sun, 14 Oct 2018 08:47:38 -0700 Subject: [PATCH 5/6] mirkoify --- Gopkg.lock | 12 ++++++++--- main.go | 61 +++++++++--------------------------------------------- 2 files changed, 19 insertions(+), 54 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 021cdaf..fa9266d 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -9,6 +9,14 @@ pruneopts = "" revision = "52478b5627a4c1eb0f73651133912ca4f15943de" +[[projects]] + branch = "master" + digest = "1:3f0ca72ea4d996a5b6016e0375b747c7bbd43dcaf3406ec6a61d349a16376cf1" + name = "code.hackerspace.pl/q3k/mirko" + packages = ["."] + pruneopts = "" + revision = "aa81aa205ff6b570606c2f71542d35d426eabb7d" + [[projects]] branch = "master" digest = "1:14b1158c5d9600d72f8ac88acd9c68a90e9f2fc021a9fc7f3be1274eb0b4ed5f" @@ -185,17 +193,15 @@ analyzer-name = "dep" analyzer-version = 1 input-imports = [ - "code.hackerspace.pl/q3k/hspki", + "code.hackerspace.pl/q3k/mirko", "code.hackerspace.pl/q3k/topo/proto/control", "github.com/golang/glog", "github.com/golang/protobuf/proto", - "github.com/q3k/statusz", "github.com/ziutek/telnet", "golang.org/x/net/context", "golang.org/x/net/trace", "google.golang.org/grpc", "google.golang.org/grpc/codes", - "google.golang.org/grpc/reflection", "google.golang.org/grpc/status", ] solver-name = "gps-cdcl" diff --git a/main.go b/main.go index a1ea7ca..ed3520a 100644 --- a/main.go +++ b/main.go @@ -4,20 +4,14 @@ import ( "context" "flag" "fmt" - "net" - "net/http" "reflect" "strconv" "strings" - "code.hackerspace.pl/q3k/hspki" + "code.hackerspace.pl/q3k/mirko" "github.com/golang/glog" - "github.com/q3k/statusz" "github.com/ziutek/telnet" - "golang.org/x/net/trace" - "google.golang.org/grpc" "google.golang.org/grpc/codes" - "google.golang.org/grpc/reflection" "google.golang.org/grpc/status" pb "code.hackerspace.pl/q3k/m6220-proxy/proto" @@ -25,8 +19,6 @@ import ( ) var ( - flagListenAddress string - flagDebugAddress string flagSwitchAddress string flagSwitchUsername string flagSwitchPassword string @@ -260,8 +252,6 @@ func (s *service) GetPorts(ctx context.Context, req *tpb.GetPortsRequest) (*tpb. } func main() { - flag.StringVar(&flagListenAddress, "listen_address", "127.0.0.1:42000", "Address to listen on for gRPC") - flag.StringVar(&flagDebugAddress, "debug_address", "127.0.0.1:42001", "Address to listen on for Debug HTTP") flag.StringVar(&flagSwitchAddress, "switch_address", "127.0.0.1:23", "Telnet address of M6220") flag.StringVar(&flagSwitchUsername, "switch_username", "admin", "Switch login username") flag.StringVar(&flagSwitchPassword, "switch_password", "admin", "Switch login password") @@ -271,48 +261,17 @@ func main() { connectionSemaphore: make(chan int, 1), } - grpc.EnableTracing = true - grpcLis, err := net.Listen("tcp", flagListenAddress) - if err != nil { - glog.Exitf("Could not listen on %v: %v", flagListenAddress, err) - } - grpcSrv := grpc.NewServer(hspki.WithServerHSPKI()...) - pb.RegisterM6220ProxyServer(grpcSrv, s) - tpb.RegisterSwitchControlServer(grpcSrv, s) - reflection.Register(grpcSrv) - - glog.Infof("Starting gRPC on %v", flagListenAddress) - go func() { - if err := grpcSrv.Serve(grpcLis); err != nil { - glog.Exitf("Could not start gRPC: %v", err) - } - }() - - if flagDebugAddress != "" { - glog.Infof("Starting debug on %v", flagDebugAddress) - httpMux := http.NewServeMux() - httpMux.HandleFunc("/debug/status", statusz.StatusHandler) - httpMux.HandleFunc("/debug/requests", trace.Traces) - httpMux.HandleFunc("/", statusz.StatusHandler) - - httpLis, err := net.Listen("tcp", flagDebugAddress) - if err != nil { - glog.Exitf("Could not listen on %v: %v", flagDebugAddress, err) - } - httpSrv := &http.Server{ - Addr: flagDebugAddress, - Handler: httpMux, - } - - go func() { - if err := httpSrv.Serve(httpLis); err != nil { - glog.Exitf("Could not start HTTP server: %v", err) - } - }() - + m := mirko.New() + if err := m.Listen(); err != nil { + glog.Exitf("Listen(): %v", err) } - glog.Infof("Running!") + pb.RegisterM6220ProxyServer(m.GRPC(), s) + tpb.RegisterSwitchControlServer(m.GRPC(), s) + + if err := m.Serve(); err != nil { + glog.Exitf("Serve(): %v", err) + } select {} } From 134e0ee9d9a9b934513b246f21fc79559816b23c Mon Sep 17 00:00:00 2001 From: Serge Bazanski Date: Thu, 25 Oct 2018 12:26:25 +0100 Subject: [PATCH 6/6] monorepoization: move everything into m6220-proxy/ --- COPYING | 13 -- Gopkg.lock | 208 ----------------------- Gopkg.toml | 3 - cli.go => m6220-proxy/cli.go | 0 main.go => m6220-proxy/main.go | 0 {proto => m6220-proxy/proto}/generate.go | 0 {proto => m6220-proxy/proto}/proxy.pb.go | 0 proxy.proto => m6220-proxy/proxy.proto | 0 8 files changed, 224 deletions(-) delete mode 100644 COPYING delete mode 100644 Gopkg.lock delete mode 100644 Gopkg.toml rename cli.go => m6220-proxy/cli.go (100%) rename main.go => m6220-proxy/main.go (100%) rename {proto => m6220-proxy/proto}/generate.go (100%) rename {proto => m6220-proxy/proto}/proxy.pb.go (100%) rename proxy.proto => m6220-proxy/proxy.proto (100%) diff --git a/COPYING b/COPYING deleted file mode 100644 index 314a889..0000000 --- a/COPYING +++ /dev/null @@ -1,13 +0,0 @@ -Copyright (C) 2018 Serge Bazanski - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/Gopkg.lock b/Gopkg.lock deleted file mode 100644 index fa9266d..0000000 --- a/Gopkg.lock +++ /dev/null @@ -1,208 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - branch = "master" - digest = "1:4c2ac02d97eb43f0363a194c63b27916957ad3a03158b803341821420c2a4ff5" - name = "code.hackerspace.pl/q3k/hspki" - packages = ["."] - pruneopts = "" - revision = "52478b5627a4c1eb0f73651133912ca4f15943de" - -[[projects]] - branch = "master" - digest = "1:3f0ca72ea4d996a5b6016e0375b747c7bbd43dcaf3406ec6a61d349a16376cf1" - name = "code.hackerspace.pl/q3k/mirko" - packages = ["."] - pruneopts = "" - revision = "aa81aa205ff6b570606c2f71542d35d426eabb7d" - -[[projects]] - branch = "master" - digest = "1:14b1158c5d9600d72f8ac88acd9c68a90e9f2fc021a9fc7f3be1274eb0b4ed5f" - name = "code.hackerspace.pl/q3k/topo" - packages = ["proto/control"] - pruneopts = "" - revision = "4b6f33ae2139635b13d2cef2c1767e983a8b46b9" - -[[projects]] - digest = "1:f82b8ac36058904227087141017bb82f4b0fc58272990a4cdae3e2d6d222644e" - name = "github.com/StackExchange/wmi" - packages = ["."] - pruneopts = "" - revision = "5d049714c4a64225c3c79a7cf7d02f7fb5b96338" - version = "1.0.0" - -[[projects]] - digest = "1:96c4a6ff4206086347bfe28e96e092642882128f45ecb8dc8f15f3e6f6703af0" - name = "github.com/go-ole/go-ole" - packages = [ - ".", - "oleutil", - ] - pruneopts = "" - revision = "a41e3c4b706f6ae8dfbff342b06e40fa4d2d0506" - version = "v1.2.1" - -[[projects]] - branch = "master" - digest = "1:107b233e45174dbab5b1324201d092ea9448e58243ab9f039e4c0f332e121e3a" - name = "github.com/golang/glog" - packages = ["."] - pruneopts = "" - revision = "23def4e6c14b4da8ac2ed8007337bc5eb5007998" - -[[projects]] - digest = "1:3dd078fda7500c341bc26cfbc6c6a34614f295a2457149fc1045cab767cbcf18" - name = "github.com/golang/protobuf" - packages = [ - "proto", - "protoc-gen-go/descriptor", - "ptypes", - "ptypes/any", - "ptypes/duration", - "ptypes/timestamp", - ] - pruneopts = "" - revision = "aa810b61a9c79d51363740d207bb46cf8e620ed5" - version = "v1.2.0" - -[[projects]] - branch = "master" - digest = "1:a7cc4447e0c2432f217fd2bed937c100ec475272a7a9306477170c2934297357" - name = "github.com/q3k/statusz" - packages = ["."] - pruneopts = "" - revision = "924f04ea71149b75f5b10f426cc4c39d6d90f6f2" - -[[projects]] - branch = "master" - digest = "1:de915fe805e4705ebc785cc3e758992c11156800e2c65781cf7db4c0a7ab2d41" - name = "github.com/shirou/gopsutil" - packages = [ - "internal/common", - "load", - ] - pruneopts = "" - revision = "a11c78ba2c13c5b1ee59c53296ba35f92f0ce658" - -[[projects]] - branch = "master" - digest = "1:d5a3dc85da58a5d8eb013bed68d82c351cd0cd8237ead400a73c25597e31730e" - name = "github.com/ziutek/telnet" - packages = ["."] - pruneopts = "" - revision = "c3b780dc415b28894076b4ec975ea3ea69e3980f" - -[[projects]] - branch = "master" - digest = "1:3a3c1b660248c0ec25f00cfb9c6526bd5b0ede4c8bfa2ed56a3f5e7e9d0a19cd" - name = "golang.org/x/net" - packages = [ - "context", - "http/httpguts", - "http2", - "http2/hpack", - "idna", - "internal/timeseries", - "trace", - ] - pruneopts = "" - revision = "146acd28ed5894421fb5aac80ca93bc1b1f46f87" - -[[projects]] - branch = "master" - digest = "1:a4bda6e065eb3ccf1e6adeaa863cb416e0ae6b43e613f20a8931d52d19dc20e2" - name = "golang.org/x/sys" - packages = [ - "unix", - "windows", - ] - pruneopts = "" - revision = "4497e2df6f9e69048a54498c7affbbec3294ad47" - -[[projects]] - digest = "1:5acd3512b047305d49e8763eef7ba423901e85d5dd2fd1e71778a0ea8de10bd4" - name = "golang.org/x/text" - packages = [ - "collate", - "collate/build", - "internal/colltab", - "internal/gen", - "internal/tag", - "internal/triegen", - "internal/ucd", - "language", - "secure/bidirule", - "transform", - "unicode/bidi", - "unicode/cldr", - "unicode/norm", - "unicode/rangetable", - ] - pruneopts = "" - revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0" - version = "v0.3.0" - -[[projects]] - branch = "master" - digest = "1:1b3b4ec811695907c4a3cb92e4f32834a4a42459bff7e02068b6b2b5344803cd" - name = "google.golang.org/genproto" - packages = ["googleapis/rpc/status"] - pruneopts = "" - revision = "af9cb2a35e7f169ec875002c1829c9b315cddc04" - -[[projects]] - digest = "1:15656947b87a6a240e61dcfae9e71a55a8d5677f240d12ab48f02cdbabf1e309" - name = "google.golang.org/grpc" - packages = [ - ".", - "balancer", - "balancer/base", - "balancer/roundrobin", - "codes", - "connectivity", - "credentials", - "encoding", - "encoding/proto", - "grpclog", - "internal", - "internal/backoff", - "internal/channelz", - "internal/envconfig", - "internal/grpcrand", - "internal/transport", - "keepalive", - "metadata", - "naming", - "peer", - "reflection", - "reflection/grpc_reflection_v1alpha", - "resolver", - "resolver/dns", - "resolver/passthrough", - "stats", - "status", - "tap", - ] - pruneopts = "" - revision = "8dea3dc473e90c8179e519d91302d0597c0ca1d1" - version = "v1.15.0" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - input-imports = [ - "code.hackerspace.pl/q3k/mirko", - "code.hackerspace.pl/q3k/topo/proto/control", - "github.com/golang/glog", - "github.com/golang/protobuf/proto", - "github.com/ziutek/telnet", - "golang.org/x/net/context", - "golang.org/x/net/trace", - "google.golang.org/grpc", - "google.golang.org/grpc/codes", - "google.golang.org/grpc/status", - ] - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml deleted file mode 100644 index 2d09d86..0000000 --- a/Gopkg.toml +++ /dev/null @@ -1,3 +0,0 @@ -[[constraint]] - name = "code.hackerspace.pl/q3k/topo" - branch = "master" diff --git a/cli.go b/m6220-proxy/cli.go similarity index 100% rename from cli.go rename to m6220-proxy/cli.go diff --git a/main.go b/m6220-proxy/main.go similarity index 100% rename from main.go rename to m6220-proxy/main.go diff --git a/proto/generate.go b/m6220-proxy/proto/generate.go similarity index 100% rename from proto/generate.go rename to m6220-proxy/proto/generate.go diff --git a/proto/proxy.pb.go b/m6220-proxy/proto/proxy.pb.go similarity index 100% rename from proto/proxy.pb.go rename to m6220-proxy/proto/proxy.pb.go diff --git a/proxy.proto b/m6220-proxy/proxy.proto similarity index 100% rename from proxy.proto rename to m6220-proxy/proxy.proto