Skip to content

Commit

Permalink
Updates for MainNet (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zensey authored Nov 15, 2021
1 parent 5bd2154 commit 7372233
Show file tree
Hide file tree
Showing 23 changed files with 650 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
git clone https://github.com/mysteriumnetwork/myst-launcher
pushd myst-launcher
git fetch --all --tags
git checkout tags/1.0.18
git checkout tags/1.0.19
popd
popd
Expand Down
4 changes: 2 additions & 2 deletions gobridge/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ go 1.16
require (
github.com/Microsoft/go-winio v0.5.0 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/containerd/containerd v1.5.5 // indirect
github.com/docker/docker v20.10.8+incompatible // indirect
github.com/containerd/containerd v1.5.7 // indirect
github.com/docker/docker v20.10.10+incompatible
github.com/gorilla/mux v1.8.0 // indirect
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/mysteriumnetwork/myst-launcher v0.0.0
Expand Down
10 changes: 10 additions & 0 deletions gobridge/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ github.com/Microsoft/hcsshim v0.8.14/go.mod h1:NtVKoYxQuTLx6gEq0L96c9Ju4JbRJ4nY2
github.com/Microsoft/hcsshim v0.8.15/go.mod h1:x38A4YbHbdxJtc0sF6oIz+RG0npwSCAvn69iY6URG00=
github.com/Microsoft/hcsshim v0.8.16/go.mod h1:o5/SZqmR7x9JNKsW3pu+nqHm0MF8vbA+VxGOoXdC600=
github.com/Microsoft/hcsshim v0.8.18/go.mod h1:+w2gRZ5ReXQhFOrvSQeNfhrYB/dg3oDwTOcER2fw4I4=
github.com/Microsoft/hcsshim v0.8.21/go.mod h1:+w2gRZ5ReXQhFOrvSQeNfhrYB/dg3oDwTOcER2fw4I4=
github.com/Microsoft/hcsshim/test v0.0.0-20201218223536-d3e5debf77da/go.mod h1:5hlzMzRKMLyo42nCZ9oml8AdTlq/0cvIaBv6tK1RehU=
github.com/Microsoft/hcsshim/test v0.0.0-20210227013316-43a75bb4edd3/go.mod h1:mw7qgWloBUl75W/gVH3cQszUg1+gUITj7D6NY7ywVnY=
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
Expand All @@ -82,7 +83,10 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB
github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA=
github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
github.com/blang/semver v3.1.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
github.com/bshuster-repo/logrus-logstash-hook v0.4.1/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk=
github.com/buger/jsonparser v0.0.0-20180808090653-f4dd9f5a6b44/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s=
Expand Down Expand Up @@ -144,6 +148,8 @@ github.com/containerd/containerd v1.5.1/go.mod h1:0DOxVqwDy2iZvrZp2JUx/E+hS0UNTV
github.com/containerd/containerd v1.5.3/go.mod h1:sx18RgvW6ABJ4iYUw7Q5x7bgFOAB9B6G7+yO0XBc4zw=
github.com/containerd/containerd v1.5.5 h1:q1gxsZsGZ8ddVe98yO6pR21b5xQSMiR61lD0W96pgQo=
github.com/containerd/containerd v1.5.5/go.mod h1:oSTh0QpT1w6jYcGmbiSbxv9OSQYaa88mPyWIuU79zyo=
github.com/containerd/containerd v1.5.7 h1:rQyoYtj4KddB3bxG6SAqd4+08gePNyJjRqvOIfV3rkM=
github.com/containerd/containerd v1.5.7/go.mod h1:gyvv6+ugqY25TiXxcZC3L5yOeYgEw0QMhscqVp1AR9c=
github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
github.com/containerd/continuity v0.0.0-20190815185530-f2a389ac0a02/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
github.com/containerd/continuity v0.0.0-20191127005431-f65d91d395eb/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
Expand Down Expand Up @@ -232,6 +238,8 @@ github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4Kfc
github.com/docker/docker v20.10.7+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v20.10.8+incompatible h1:RVqD337BgQicVCzYrrlhLDWhq6OAD2PJDUg2LsEUvKM=
github.com/docker/docker v20.10.8+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v20.10.10+incompatible h1:GKkP0T7U4ks6X3lmmHKC2QDprnpRJor2Z5a8m62R9ZM=
github.com/docker/docker v20.10.10+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-events v0.0.0-20170721190031-9461782956ad/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA=
Expand Down Expand Up @@ -382,6 +390,7 @@ github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJ
github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/imdario/mergo v0.3.10/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/j-keck/arping v0.0.0-20160618110441-2cf9dc699c56/go.mod h1:ymszkNOg6tORTn+6F6j+Jc8TOr5osrynvN6ivFWZ2GA=
github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
Expand Down Expand Up @@ -482,6 +491,7 @@ github.com/opencontainers/runc v1.0.0-rc8.0.20190926000215-3e425f80a8c9/go.mod h
github.com/opencontainers/runc v1.0.0-rc9/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
github.com/opencontainers/runc v1.0.0-rc93/go.mod h1:3NOsor4w32B2tC0Zbl8Knk4Wg84SM2ImC1fxBuqJ/H0=
github.com/opencontainers/runc v1.0.1/go.mod h1:aTaHFFwQXuA71CiyxOdFFIorAoemI04suvGRQFzWTD0=
github.com/opencontainers/runc v1.0.2/go.mod h1:aTaHFFwQXuA71CiyxOdFFIorAoemI04suvGRQFzWTD0=
github.com/opencontainers/runtime-spec v0.1.2-0.20190507144316-5b71a03e2700/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opencontainers/runtime-spec v1.0.1/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opencontainers/runtime-spec v1.0.2-0.20190207185410-29686dbc5559/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
Expand Down
44 changes: 32 additions & 12 deletions gobridge/gobridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ import (

var (
manager *myst.Manager
mon *myst.DockerMonitor
mod *model.UIModel

ap *app.AppState
ui model.Gui_
)

const (
gitHubOrg = "mysteriumnetwork"
gitHubRepo = "myst-launcher-osx"
)

func init() {
fmt.Println("gobridge init>")
}
Expand All @@ -49,19 +53,20 @@ func copyFile(sourceFile, destinationFile string) {

//export GoInit
func GoInit(resPath *C.char, prodVer *C.char) {
mod = model.NewUIModel()
mod.Config.ProductVersion = C.GoString(prodVer)
mod = model.NewUIModel()
mod.SetProductVersion(C.GoString(prodVer))
// set product repo

targetDir := os.Getenv("HOME") + "/Library/LaunchAgents/"
os.MkdirAll(targetDir, 0755)
fileName := "com.mysterium.launcher.plist"
resourcePath := C.GoString(resPath)
resourcePath := C.GoString(resPath)
copyFile(resourcePath+"/"+fileName, targetDir+fileName)
}
}

//export GoStart
func GoStart() {
fmt.Println("GoStart >")
fmt.Println("GoStart >")
ap = app.NewApp()
sendConfig()

Expand All @@ -71,6 +76,9 @@ func GoStart() {
mod.UIBus.Subscribe("log", func(p []byte) {
C.macSendLog(C.CString(string(p)))
})
mod.UIBus.Subscribe("launcher-update", func() {
C.macSendOpenDialogue(C.int(1))
})
log.SetOutput(ap)

mod.UIBus.Subscribe("model-change", sendState)
Expand All @@ -82,23 +90,29 @@ func GoStart() {

ap.WaitGroup.Add(1)
go ap.SuperviseDockerNode()
go ap.CheckLauncherUpdates(gitHubOrg, gitHubRepo)
}

func sendState() {
var st C.NSState

st.imageName = C.CString(mod.ImgVer.ImageName)
st.imageName = C.CString(mod.Config.GetFullImageName())
st.currentVersion = C.CString(mod.ImgVer.VersionCurrent)
st.latestVersion = C.CString(mod.ImgVer.VersionLatest)
st.hasUpdate = C.bool(mod.ImgVer.HasUpdate)
st.dockerRunning = C.int(mod.StateDocker)
st.containerRunning = C.int(mod.StateContainer)
st.networkCaption = C.CString(mod.Config.GetNetworkCaption())

// instllation state
st.checkVirt = C.int(mod.CheckVirt)
st.checkDocker = C.int(mod.CheckDocker)
st.downloadFiles = C.int(mod.DownloadFiles)
st.installDocker = C.int(mod.InstallDocker)
st.downloadFiles = C.int(mod.DownloadFiles)
st.installDocker = C.int(mod.InstallDocker)

st.launcherHasUpdate = C.bool(mod.LauncherHasUpdate)
st.productVersionLatestUrl = C.CString(mod.ProductVersionLatestUrl)
st.launcherVersionLatest = C.CString(mod.ProductVersionLatest)

C.macSendState(&st)
}
Expand All @@ -111,6 +125,7 @@ func sendConfig() {
cf.portRangeEnd = C.int(mod.Config.PortRangeEnd)
cf.autoUpgrade = C.bool(mod.Config.AutoUpgrade)
cf.enabled = C.bool(mod.Config.Enabled)
cf.network = C.CString(mod.Config.Network)

C.macSendConfig(&cf)
}
Expand All @@ -137,11 +152,11 @@ func GoOnAppExit() {

//export GoTriggerUpgrade
func GoTriggerUpgrade() {
ap.TriggerAction("upgrade")
ap.TriggerAction("upgrade")
}

//export GoSetState
func GoSetState(s *C.SetStateArgs) {
func GoSetState(s *C.NSConfig) {

if mod.Config.AutoUpgrade != bool(s.autoUpgrade) {
mod.Config.AutoUpgrade = bool(s.autoUpgrade)
Expand All @@ -158,7 +173,7 @@ func GoSetState(s *C.SetStateArgs) {
}

//export GoSetNetworkConfig
func GoSetNetworkConfig(s *C.SetStateArgs) {
func GoSetNetworkConfig(s *C.NSConfig) {

mod.Config.EnablePortForwarding = bool(s.enablePortForwarding)
mod.Config.PortRangeBegin = int(s.portRangeBegin)
Expand All @@ -167,6 +182,11 @@ func GoSetNetworkConfig(s *C.SetStateArgs) {
ap.TriggerAction("restart")
}

//export GoUpdateToMainnet
func GoUpdateToMainnet() {
mod.UpdateToMainnet()
sendConfig()
}

// required by runtime
func main() {}
5 changes: 3 additions & 2 deletions gobridge/gobridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ extern void GoSetModalResult(int rc);
extern void GoDialogueComplete();
extern void GoOnAppExit();
extern void GoTriggerUpgrade();
extern void GoSetState(SetStateArgs* s);
extern void GoSetNetworkConfig(SetStateArgs* s);
extern void GoSetState(NSConfig* s);
extern void GoSetNetworkConfig(NSConfig* s);
extern void GoUpdateToMainnet();

#ifdef __cplusplus
}
Expand Down
14 changes: 11 additions & 3 deletions gobridge/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@ typedef struct _NSState {
bool hasUpdate;
int dockerRunning;
int containerRunning;
char *networkCaption;

// install steps
int checkVirt;
int checkDocker;
int downloadFiles;
int installDocker;

// launcher
bool launcherHasUpdate;
char *productVersionLatestUrl;
char *launcherVersionLatest;
} NSState;

typedef struct _NSConfig {
Expand All @@ -22,23 +28,24 @@ typedef struct _NSConfig {
bool enablePortForwarding;
int portRangeBegin;
int portRangeEnd;
char *network;
} NSConfig;

typedef struct _NSModal {
char *title;
char *msg;
int modal_type;
int modal_type;
} NSModal;


/*
typedef struct _SetStateArgs {
bool enablePortForwarding;
int portRangeBegin;
int portRangeEnd;
bool autoUpgrade;
bool enabled;
} SetStateArgs;

*/


///
Expand All @@ -47,6 +54,7 @@ void macSendConfig(NSConfig *s);
void macSendModal(NSModal *s);
void macSendMode(int s);
void macSendLog(char *s);
void macSendOpenDialogue(int id_);

///
typedef enum {
Expand Down
18 changes: 17 additions & 1 deletion gobridge/interface.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ void macSendState(NSState *s) {
@"hasUpdate": @(s->hasUpdate),
@"dockerRunning": @(s->dockerRunning),
@"containerRunning": @(s->containerRunning),

@"networkCaption": @(s->networkCaption),

// instllation state
@"checkVirt": @(s->checkVirt),
@"checkDocker": @(s->checkDocker),
@"downloadFiles": @(s->downloadFiles),
@"installDocker": @(s->installDocker),

@"launcherHasUpdate": @(s->launcherHasUpdate),
@"productVersionLatestUrl": @(s->productVersionLatestUrl),
@"launcherVersionLatest": @(s->launcherVersionLatest),
};

// free strings
Expand All @@ -35,6 +40,7 @@ void macSendConfig(NSConfig *s) {
@"portRangeBegin": @(s->portRangeBegin),
@"portRangeEnd": @(s->portRangeEnd),
@"autoUpgrade": @(s->autoUpgrade),
@"network": @(s->network),
};

dispatch_async(dispatch_get_main_queue(),^{
Expand Down Expand Up @@ -84,3 +90,13 @@ void macSendLog(char *s) {
});
return;
}

void macSendOpenDialogue(int id_) {
id dict = @{
@"id": @(id_),
};
dispatch_async(dispatch_get_main_queue(),^{
[[NSNotificationCenter defaultCenter] postNotificationName:@"dialogue" object:nil userInfo:dict];
});
return;
}
16 changes: 10 additions & 6 deletions gobridge/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import "C"
import "fmt"

type UiProxy struct {
result chan int
result chan int
waitClick chan int
}

Expand All @@ -23,10 +23,10 @@ func newUiProxy() *UiProxy {
return g
}

func (g *UiProxy) PopupMain() {}
func (g *UiProxy) ShowMain() {}
func (g *UiProxy) PopupMain() {}
func (g *UiProxy) ShowMain() {}
func (g *UiProxy) ShowNotificationInstalled() {}
func (g *UiProxy) ShowNotificationUpgrade() {}
func (g *UiProxy) ShowNotificationUpgrade() {}

func (g *UiProxy) ConfirmModal(title, message string) int {
var m C.NSModal
Expand Down Expand Up @@ -69,9 +69,14 @@ func (g *UiProxy) CloseUI() {
// g.bus.Publish("exit")
}

func (g *UiProxy) OpenDialogue(id int) {
C.macSendOpenDialogue(C.int(id))
g.WaitDialogueComplete()
}

// returns false, if dialogue was terminated
func (g *UiProxy) WaitDialogueComplete() bool {
fmt.Println("WaitDialogueComplete >>>")
fmt.Println("WaitDialogueComplete")
_, ok := <-g.waitClick
return ok
}
Expand All @@ -87,4 +92,3 @@ func (g *UiProxy) DialogueComplete() {
default:
}
}

Loading

0 comments on commit 7372233

Please sign in to comment.