Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reward on Windows #1892

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cmd/skywire-cli/commands/rewards/services.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !windows
// +build !windows

// Package clirewards cmd/skywire-cli/commands/rewards/services.go
package clirewards

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ require (
github.com/skycoin/dmsg v1.3.29-0.20241019182716-022283c93835
github.com/skycoin/skycoin v0.28.0
github.com/skycoin/skycoin-service-discovery v1.3.29-0.20241019190420-233c2d68bce0
github.com/skycoin/skywire-services v1.3.29-0.20241019183828-0d760251ca55
github.com/skycoin/skywire-services v1.3.28
github.com/skycoin/skywire-utilities v1.3.25
github.com/skycoin/systray v1.10.0
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8
Expand All @@ -51,7 +51,7 @@ require (
golang.org/x/sync v0.8.0
golang.org/x/sys v0.26.0
golang.org/x/term v0.25.0
golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173
golang.zx2c4.com/wireguard v0.0.0-20230223181233-21636207a675
gopkg.in/telebot.v3 v3.3.8
)

Expand Down
12 changes: 4 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,6 @@ github.com/gomarkdown/markdown v0.0.0-20240930133441-72d49d9543d8 h1:4txT5G2kqVA
github.com/gomarkdown/markdown v0.0.0-20240930133441-72d49d9543d8/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4=
github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA=
github.com/google/flatbuffers v1.12.1/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
github.com/google/flatbuffers v24.3.25+incompatible h1:CX395cjN9Kke9mmalRoL3d81AtFUxJM+yDthflgJGkI=
github.com/google/flatbuffers v24.3.25+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
Expand Down Expand Up @@ -660,8 +658,8 @@ github.com/skycoin/skycoin v0.28.0 h1:0TN2tsU8CbCnGANKKxMr4jcG8RuBa8hWREeYtjDDtl
github.com/skycoin/skycoin v0.28.0/go.mod h1:E9RvlMn8iQGX/upaIQvkHHcw/180JBqAQbRIzkLrkSQ=
github.com/skycoin/skycoin-service-discovery v1.3.29-0.20241019190420-233c2d68bce0 h1:2F9JSOHefkyTLsREj8bMMXk1z13fJhnVa0R/XCxbUwM=
github.com/skycoin/skycoin-service-discovery v1.3.29-0.20241019190420-233c2d68bce0/go.mod h1:3/WomvXyOLcjEMV4GiLv8b+bueohWa9ceoNwtQSB9KI=
github.com/skycoin/skywire-services v1.3.29-0.20241019183828-0d760251ca55 h1:BqMp8eU21Wg7CCs7IxL8/gGqfGtmta93W/NFfEsYBiY=
github.com/skycoin/skywire-services v1.3.29-0.20241019183828-0d760251ca55/go.mod h1:Q3s3Ea+tcT3M4zkMT89ywk5NmLCdXZWHRsPhNBEo7Zw=
github.com/skycoin/skywire-services v1.3.28 h1:Q6Cxcmf3Mn30ACYlODyaHJ6PjxRjPFxuPChbZSbWriU=
github.com/skycoin/skywire-services v1.3.28/go.mod h1:UsOT9WeQXTe2dXPpZUneqp7JWsMTjrWodB3OQH6nOoQ=
github.com/skycoin/skywire-utilities v1.3.25 h1:mk8dUonFdhVopFF3d9wbOyXXoiuAO+mN1y+ve6SzgX4=
github.com/skycoin/skywire-utilities v1.3.25/go.mod h1:yFKWpL1bDRPKU3uK+cTF4PnYUMe+eyIj5N2bk4sF5Cw=
github.com/skycoin/systray v1.10.0 h1:fQZJHMylpVvfmOOTLvUssfyHVDoC8Idx6Ba2BlLEuGg=
Expand Down Expand Up @@ -1118,8 +1116,8 @@ golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8=
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 h1:B82qJJgjvYKsXS9jeunTOisW56dUokqW/FOteYJJ/yg=
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2/go.mod h1:deeaetjYA+DHMHg+sMSMI58GrEteJUUzzw7en6TJQcI=
golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 h1:/jFs0duh4rdb8uIfPMv78iAJGcPKDeqAFnaLBropIC4=
golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173/go.mod h1:tkCQ4FQXmpAgYVh++1cq16/dH4QJtmvpRv19DWGAHSA=
golang.zx2c4.com/wireguard v0.0.0-20230223181233-21636207a675 h1:/J/RVnr7ng4fWPRH3xa4WtBJ1Jp+Auu4YNLmGiPv5QU=
golang.zx2c4.com/wireguard v0.0.0-20230223181233-21636207a675/go.mod h1:whfbyDBt09xhCYQWtO2+3UVjlaq6/9hDZrjg2ZE6SyA=
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
Expand Down Expand Up @@ -1322,8 +1320,6 @@ gorm.io/driver/postgres v1.5.9 h1:DkegyItji119OlcaLjqN11kHoUgZ/j13E0jkJZgD6A8=
gorm.io/driver/postgres v1.5.9/go.mod h1:DX3GReXH+3FPWGrrgffdvCk3DQ1dwDPdmbenSkweRGI=
gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=
gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
gvisor.dev/gvisor v0.0.0-20230927004350-cbd86285d259 h1:TbRPT0HtzFP3Cno1zZo7yPzEEnfu8EjLfl6IU9VfqkQ=
gvisor.dev/gvisor v0.0.0-20230927004350-cbd86285d259/go.mod h1:AVgIgHMwK63XvmAzWG9vLQ41YnVHN0du0tEC46fI7yY=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
7 changes: 0 additions & 7 deletions pkg/visor/visorconfig/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"os"
"os/exec"
"os/user"
"path/filepath"
"strings"

Expand Down Expand Up @@ -221,12 +220,6 @@ func Config() skyenv.PkgConfig {
return UserConfig()
}

// IsRoot checks for root permissions
func IsRoot() bool {
userLvl, _ := user.Current() //nolint
return userLvl.Username == "root"
}

var (
// VisorConfigFile will contain the path to the visor's config or `stdin` to denote that the config was read from STDIN
VisorConfigFile string
Expand Down
7 changes: 7 additions & 0 deletions pkg/visor/visorconfig/values_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package visorconfig

import (
"os/user"
"runtime"

"github.com/google/uuid"
Expand Down Expand Up @@ -63,3 +64,9 @@ func SystemSurvey() (Survey, error) {
}
return s, nil
}

// IsRoot checks for root permissions
func IsRoot() bool {
userLvl, _ := user.Current() //nolint
return userLvl.Username == "root"
}
7 changes: 7 additions & 0 deletions pkg/visor/visorconfig/values_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package visorconfig

import (
"os/user"
"runtime"
"strings"
"time"
Expand Down Expand Up @@ -84,3 +85,9 @@ func SystemSurvey() (Survey, error) {
}
return s, nil
}

// IsRoot checks for root permissions
func IsRoot() bool {
userLvl, _ := user.Current() //nolint
return userLvl.Username == "root"
}
58 changes: 58 additions & 0 deletions pkg/visor/visorconfig/values_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
package visorconfig

import (
"log"
"net"
"runtime"

"golang.org/x/sys/windows"

"github.com/google/uuid"
"github.com/jaypipes/ghw"

Expand All @@ -32,6 +36,7 @@ type Survey struct {
SkycoinAddress string `json:"skycoin_address,omitempty"`
GOOS string `json:"go_os,omitempty"`
GOARCH string `json:"go_arch,omitempty"`
SYSINFO []NetworkDevice `json:"zcalusic_sysinfo,omitempty"`
IPAddr string `json:"ip_address,omitempty"`
Disks *ghw.BlockInfo `json:"ghw_blockinfo,omitempty"`
Product *ghw.ProductInfo `json:"ghw_productinfo,omitempty"`
Expand Down Expand Up @@ -68,6 +73,7 @@ func SystemSurvey() (Survey, error) {
// IPAddr: ipAddr,
GOOS: runtime.GOOS,
GOARCH: runtime.GOARCH,
SYSINFO: getMacAddr(),
UUID: uuid.New(),
Disks: disks,
Product: product,
Expand All @@ -76,3 +82,55 @@ func SystemSurvey() (Survey, error) {
}
return s, nil
}

type NetworkDevice struct {
Name string `json:"name,omitempty"`
Driver string `json:"driver,omitempty"`
MACAddress string `json:"macaddress,omitempty"`
Port string `json:"port,omitempty"`
Speed uint `json:"speed,omitempty"` // device max supported speed in Mbps
}

func getMacAddr() []NetworkDevice {
si := make([]NetworkDevice, 1)
ifas, err := net.Interfaces()
if err != nil {
return nil
}

for _, ifa := range ifas {
si[0].MACAddress = ifa.HardwareAddr.String()
if si[0].MACAddress != "" {
return si
}
}
return nil
}

// IsRoot checks for root permissions
func IsRoot() bool {
var sid *windows.SID

err := windows.AllocateAndInitializeSid(
&windows.SECURITY_NT_AUTHORITY,
2,
windows.SECURITY_BUILTIN_DOMAIN_RID,
windows.DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0,
&sid)
if err != nil {
log.Fatalf("SID Error: %s", err)
return false
}
defer windows.FreeSid(sid)

token := windows.Token(0)

member, err := token.IsMember(sid)
if err != nil {
log.Fatalf("Token Membership Error: %s", err)
return false
}

return member
}
Loading
Loading