From 929332abc3cf9b13172f29c2ef9d82b9090e378a Mon Sep 17 00:00:00 2001 From: Nikita Kryuchkov Date: Thu, 5 Sep 2019 00:25:53 +0300 Subject: [PATCH 1/4] Fix issues in implementation of command execution on visor from hypervisor --- cmd/skywire-cli/commands/node/app.go | 2 +- go.sum | 1 + pkg/hypervisor/hypervisor.go | 2 +- vendor/github.com/skycoin/dmsg/client.go | 2 +- vendor/golang.org/x/sys/windows/syscall_windows.go | 13 +++++++++++-- vendor/golang.org/x/sys/windows/zsyscall_windows.go | 6 ++++++ vendor/modules.txt | 2 +- 7 files changed, 22 insertions(+), 6 deletions(-) diff --git a/cmd/skywire-cli/commands/node/app.go b/cmd/skywire-cli/commands/node/app.go index f7afa616ac..baa1553bbb 100644 --- a/cmd/skywire-cli/commands/node/app.go +++ b/cmd/skywire-cli/commands/node/app.go @@ -92,6 +92,6 @@ var execCmd = &cobra.Command{ Run: func(_ *cobra.Command, args []string) { out, err := rpcClient().Exec(strings.Join(args, " ")) internal.Catch(err) - fmt.Println(string(out)) + fmt.Print(string(out)) }, } diff --git a/go.sum b/go.sum index 1e5468a790..37962e0f0a 100644 --- a/go.sum +++ b/go.sum @@ -143,6 +143,7 @@ golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa h1:KIDDMLT1O0Nr7TSxp8xM5tJcd golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190825160603-fb81701db80f h1:LCxigP8q3fPRGNVYndYsyHnF0zRrvcoVwZMfb8iQZe4= golang.org/x/sys v0.0.0-20190825160603-fb81701db80f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= diff --git a/pkg/hypervisor/hypervisor.go b/pkg/hypervisor/hypervisor.go index b88ebdf25e..74a55701cc 100644 --- a/pkg/hypervisor/hypervisor.go +++ b/pkg/hypervisor/hypervisor.go @@ -129,7 +129,7 @@ func (m *Node) ServeHTTP(w http.ResponseWriter, req *http.Request) { } r.Get("/user", m.users.UserInfo()) r.Post("/change-password", m.users.ChangePassword()) - r.Post("/exec", m.exec()) + r.Post("/exec/{pk}", m.exec()) r.Get("/nodes", m.getNodes()) r.Get("/nodes/{pk}", m.getNode()) r.Get("/nodes/{pk}/apps", m.getApps()) diff --git a/vendor/github.com/skycoin/dmsg/client.go b/vendor/github.com/skycoin/dmsg/client.go index 2e7d898a2b..587d03bcb3 100644 --- a/vendor/github.com/skycoin/dmsg/client.go +++ b/vendor/github.com/skycoin/dmsg/client.go @@ -158,7 +158,7 @@ func (c *Client) findServerEntries(ctx context.Context) ([]*disc.Entry, error) { return nil, fmt.Errorf("dms_servers are not available: %s", err) default: retry := time.Second - c.log.WithError(err).Warnf("no dms_servers found: trying again in %d second...", retry) + c.log.WithError(err).Warnf("no dms_servers found: trying again in %v...", retry) time.Sleep(retry) continue } diff --git a/vendor/golang.org/x/sys/windows/syscall_windows.go b/vendor/golang.org/x/sys/windows/syscall_windows.go index b23050924f..452d44126d 100644 --- a/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -296,6 +296,7 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys coCreateGuid(pguid *GUID) (ret error) = ole32.CoCreateGuid //sys CoTaskMemFree(address unsafe.Pointer) = ole32.CoTaskMemFree //sys rtlGetVersion(info *OsVersionInfoEx) (ret error) = ntdll.RtlGetVersion +//sys rtlGetNtVersionNumbers(majorVersion *uint32, minorVersion *uint32, buildNumber *uint32) = ntdll.RtlGetNtVersionNumbers // syscall interface implementation for other packages @@ -1306,8 +1307,8 @@ func (t Token) KnownFolderPath(folderID *KNOWNFOLDERID, flags uint32) (string, e return UTF16ToString((*[(1 << 30) - 1]uint16)(unsafe.Pointer(p))[:]), nil } -// RtlGetVersion returns the true version of the underlying operating system, ignoring -// any manifesting or compatibility layers on top of the win32 layer. +// RtlGetVersion returns the version of the underlying operating system, ignoring +// manifest semantics but is affected by the application compatibility layer. func RtlGetVersion() *OsVersionInfoEx { info := &OsVersionInfoEx{} info.osVersionInfoSize = uint32(unsafe.Sizeof(*info)) @@ -1318,3 +1319,11 @@ func RtlGetVersion() *OsVersionInfoEx { _ = rtlGetVersion(info) return info } + +// RtlGetNtVersionNumbers returns the version of the underlying operating system, +// ignoring manifest semantics and the application compatibility layer. +func RtlGetNtVersionNumbers() (majorVersion, minorVersion, buildNumber uint32) { + rtlGetNtVersionNumbers(&majorVersion, &minorVersion, &buildNumber) + buildNumber &= 0xffff + return +} diff --git a/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/vendor/golang.org/x/sys/windows/zsyscall_windows.go index d461bed98a..e5d62f3bf5 100644 --- a/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ b/vendor/golang.org/x/sys/windows/zsyscall_windows.go @@ -234,6 +234,7 @@ var ( procCoCreateGuid = modole32.NewProc("CoCreateGuid") procCoTaskMemFree = modole32.NewProc("CoTaskMemFree") procRtlGetVersion = modntdll.NewProc("RtlGetVersion") + procRtlGetNtVersionNumbers = modntdll.NewProc("RtlGetNtVersionNumbers") procWSAStartup = modws2_32.NewProc("WSAStartup") procWSACleanup = modws2_32.NewProc("WSACleanup") procWSAIoctl = modws2_32.NewProc("WSAIoctl") @@ -2530,6 +2531,11 @@ func rtlGetVersion(info *OsVersionInfoEx) (ret error) { return } +func rtlGetNtVersionNumbers(majorVersion *uint32, minorVersion *uint32, buildNumber *uint32) { + syscall.Syscall(procRtlGetNtVersionNumbers.Addr(), 3, uintptr(unsafe.Pointer(majorVersion)), uintptr(unsafe.Pointer(minorVersion)), uintptr(unsafe.Pointer(buildNumber))) + return +} + func WSAStartup(verreq uint32, data *WSAData) (sockerr error) { r0, _, _ := syscall.Syscall(procWSAStartup.Addr(), 2, uintptr(verreq), uintptr(unsafe.Pointer(data)), 0) if r0 != 0 { diff --git a/vendor/modules.txt b/vendor/modules.txt index 7e0106c0c3..f680012fe7 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -98,7 +98,7 @@ golang.org/x/net/nettest golang.org/x/net/context golang.org/x/net/proxy golang.org/x/net/internal/socks -# golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a +# golang.org/x/sys v0.0.0-20190825160603-fb81701db80f golang.org/x/sys/unix golang.org/x/sys/windows golang.org/x/sys/windows/svc/eventlog From f1781588a54fe0e73b6134c28cd65f0cbaa74852 Mon Sep 17 00:00:00 2001 From: Nikita Kryuchkov Date: Thu, 5 Sep 2019 00:52:52 +0300 Subject: [PATCH 2/4] Fix the broken linter in the Milestone 1 branch --- pkg/visor/rpc_client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/visor/rpc_client.go b/pkg/visor/rpc_client.go index f90e831f1f..8fda4a4f27 100644 --- a/pkg/visor/rpc_client.go +++ b/pkg/visor/rpc_client.go @@ -3,7 +3,6 @@ package visor import ( "encoding/binary" "fmt" - "github.com/skycoin/skywire/pkg/router" "math/rand" "net/rpc" "sync" @@ -13,6 +12,7 @@ import ( "github.com/skycoin/dmsg/cipher" "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire/pkg/router" "github.com/skycoin/skywire/pkg/routing" "github.com/skycoin/skywire/pkg/transport" ) From 4ab9c5b44baf1ec9e7352aa155ed148461e8cd81 Mon Sep 17 00:00:00 2001 From: ivcosla Date: Thu, 5 Sep 2019 12:11:47 +0200 Subject: [PATCH 3/4] proper mux lock --- pkg/hypervisor/hypervisor.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/hypervisor/hypervisor.go b/pkg/hypervisor/hypervisor.go index 74a55701cc..f0228bda16 100644 --- a/pkg/hypervisor/hypervisor.go +++ b/pkg/hypervisor/hypervisor.go @@ -66,12 +66,12 @@ func (m *Node) ServeRPC(lis net.Listener) error { return err } addr := conn.RemoteAddr().(*noise.Addr) - m.mu.RLock() + m.mu.Lock() m.nodes[addr.PK] = appNodeConn{ Addr: addr, Client: visor.NewRPCClient(rpc.NewClient(conn), visor.RPCPrefix), } - m.mu.RUnlock() + m.mu.Unlock() } } From d4966bc52a0959cdab288ba35def22c94e5f7d1c Mon Sep 17 00:00:00 2001 From: ivcosla Date: Thu, 5 Sep 2019 12:24:13 +0200 Subject: [PATCH 4/4] updated vendor, commented replace and referenced dmsg@mainnet-milestone1 --- go.mod | 4 ++-- go.sum | 2 ++ vendor/modules.txt | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e5038b4c0c..8680954332 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/prometheus/client_golang v1.0.0 github.com/prometheus/common v0.4.1 github.com/sirupsen/logrus v1.4.2 - github.com/skycoin/dmsg v0.0.0-20190816104216-d18ee6aa05cb + github.com/skycoin/dmsg v0.0.0-20190904181013-b781e3cbebc6 github.com/skycoin/skycoin v0.26.0 github.com/spf13/cobra v0.0.5 github.com/stretchr/testify v1.3.0 @@ -28,4 +28,4 @@ require ( ) // Uncomment for tests with alternate branches of 'dmsg' -replace github.com/skycoin/dmsg => ../dmsg +// replace github.com/skycoin/dmsg => ../dmsg diff --git a/go.sum b/go.sum index 37962e0f0a..89fb5f0f75 100644 --- a/go.sum +++ b/go.sum @@ -93,6 +93,8 @@ github.com/skycoin/dmsg v0.0.0-20190805065636-70f4c32a994f h1:WWjaxOXoj6oYelm67M github.com/skycoin/dmsg v0.0.0-20190805065636-70f4c32a994f/go.mod h1:obZYZp8eKR7Xqz+KNhJdUE6Gvp6rEXbDO8YTlW2YXgU= github.com/skycoin/dmsg v0.0.0-20190816104216-d18ee6aa05cb h1:kpNxP3mOjrVyyLBOtOxBgpxUOCBBI/RhdO9Vto5+OHk= github.com/skycoin/dmsg v0.0.0-20190816104216-d18ee6aa05cb/go.mod h1:obZYZp8eKR7Xqz+KNhJdUE6Gvp6rEXbDO8YTlW2YXgU= +github.com/skycoin/dmsg v0.0.0-20190904181013-b781e3cbebc6 h1:YwSyQXUyG/EFp3xCGMkOldgQNpw8XLfmocQND4/Y3aw= +github.com/skycoin/dmsg v0.0.0-20190904181013-b781e3cbebc6/go.mod h1:obZYZp8eKR7Xqz+KNhJdUE6Gvp6rEXbDO8YTlW2YXgU= github.com/skycoin/skycoin v0.26.0 h1:xDxe2r8AclMntZ550Y/vUQgwgLtwrf9Wu5UYiYcN5/o= github.com/skycoin/skycoin v0.26.0/go.mod h1:78nHjQzd8KG0jJJVL/j0xMmrihXi70ti63fh8vXScJw= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= diff --git a/vendor/modules.txt b/vendor/modules.txt index f680012fe7..a4eb7bba9d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -62,7 +62,7 @@ github.com/prometheus/procfs/internal/fs # github.com/sirupsen/logrus v1.4.2 github.com/sirupsen/logrus github.com/sirupsen/logrus/hooks/syslog -# github.com/skycoin/dmsg v0.0.0-20190816104216-d18ee6aa05cb => ../dmsg +# github.com/skycoin/dmsg v0.0.0-20190904181013-b781e3cbebc6 github.com/skycoin/dmsg/cipher github.com/skycoin/dmsg github.com/skycoin/dmsg/disc