Skip to content

Commit

Permalink
Merge pull request #20 from mysteriumnetwork/native-node
Browse files Browse the repository at this point in the history
Add support of native provider mode
  • Loading branch information
Zensey authored Nov 9, 2022
2 parents f460849 + 65d8a9a commit 93f5db8
Show file tree
Hide file tree
Showing 17 changed files with 206 additions and 113 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ jobs:
with:
go-version: 1.17


- name: "Build"
run: |
pushd ..
git clone https://github.com/mysteriumnetwork/myst-launcher
pushd myst-launcher
git fetch --all --tags
git checkout tags/1.0.30
git checkout tags/1.0.36-mac
popd
popd
Expand Down Expand Up @@ -94,6 +93,7 @@ jobs:
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
prerelease: true
files: |
mysterium_launcher_macos.dmg
env:
Expand Down
7 changes: 6 additions & 1 deletion gobridge/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ module github.com/mysteriumnetwork/fff

go 1.16

require github.com/mysteriumnetwork/myst-launcher v0.0.0
require (
code.cloudfoundry.org/archiver v0.0.0-20220328120804-99329f9bbb8b // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/mysteriumnetwork/myst-launcher v0.0.0
github.com/sirupsen/logrus v1.8.1 // indirect
)

replace github.com/mysteriumnetwork/myst-launcher => ../../myst-launcher
51 changes: 51 additions & 0 deletions gobridge/go.sum

Large diffs are not rendered by default.

27 changes: 15 additions & 12 deletions gobridge/gobridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/mysteriumnetwork/myst-launcher/app"
"github.com/mysteriumnetwork/myst-launcher/model"
"github.com/mysteriumnetwork/myst-launcher/myst"
"github.com/mysteriumnetwork/myst-launcher/utils"
)

var (
Expand Down Expand Up @@ -53,9 +54,10 @@ func copyFile(sourceFile, destinationFile string) {

//export GoInit
func GoInit(resPath *C.char, prodVer *C.char) {
utils.SetProductVersion(C.GoString(prodVer))

mod = model.NewUIModel()
mod.SetProductVersion(C.GoString(prodVer))
// set product repo

targetDir := os.Getenv("HOME") + "/Library/LaunchAgents/"
os.MkdirAll(targetDir, 0755)
Expand Down Expand Up @@ -89,9 +91,7 @@ func GoStart() {
ap.SetModel(mod)
ap.SetUI(ui)

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

}

Expand Down Expand Up @@ -128,6 +128,7 @@ func sendConfig() {
cf.autoUpgrade = C.bool(mod.Config.AutoUpgrade)
cf.enabled = C.bool(mod.Config.Enabled)
cf.network = C.CString(mod.Config.Network)
cf.backend = C.CString(mod.Config.Backend)

C.macSendConfig(&cf)
}
Expand All @@ -146,10 +147,8 @@ func GoDialogueComplete() {

//export GoOnAppExit
func GoOnAppExit() {
ap.TriggerAction("stop")

// wait for SuperviseDockerNode to finish its work
ap.WaitGroup.Wait()
ap.StopAppController()
}

//export GoTriggerUpgrade
Expand All @@ -166,12 +165,16 @@ func GoSetState(s *C.NSConfig) {
}

if mod.Config.Enabled != bool(s.enabled) {
if bool(s.enabled) {
ap.TriggerAction("enable")
} else {
ap.TriggerAction("disable")
}
mod.TriggerNodeEnableAction()
}

if mod.Config.Backend != C.GoString(s.backend) {
mod.Config.Backend = C.GoString(s.backend)
mod.Config.Save()

mod.Bus2.Publish("backend")
}
sendConfig()
}

//export GoSetNetworkConfig
Expand Down
1 change: 1 addition & 0 deletions gobridge/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ typedef struct _NSConfig {
int portRangeBegin;
int portRangeEnd;
char *network;
char *backend;
} NSConfig;

typedef struct _NSModal {
Expand Down
4 changes: 3 additions & 1 deletion gobridge/interface.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ void macSendConfig(NSConfig *s) {
@"portRangeEnd": @(s->portRangeEnd),
@"autoUpgrade": @(s->autoUpgrade),
@"network": @(s->network),
@"backend": @(s->backend),
};

free(s->backend);

dispatch_async(dispatch_get_main_queue(),^{
[[NSNotificationCenter defaultCenter] postNotificationName:@"config" object:nil userInfo:dict];
});
Expand Down
6 changes: 3 additions & 3 deletions launcher.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@
9A1B3A8D273BA4780084DF92 /* UpdateNetwork.xib */,
9A1B3A8F273BA5840084DF92 /* UpdateNetworkModalDelegate.h */,
9A1B3A90273BA5840084DF92 /* UpdateNetworkModalDelegate.m */,
9A1B3A96273BD7AC0084DF92 /* UpdateLauncher.xib */,
9A1B3A95273BD7AC0084DF92 /* UpdateLauncherModalDelegate.h */,
9A1B3A94273BD7AC0084DF92 /* UpdateLauncherModalDelegate.m */,
9A1B3A96273BD7AC0084DF92 /* UpdateLauncher.xib */,
);
path = launcher;
sourceTree = "<group>";
Expand Down Expand Up @@ -578,7 +578,7 @@
"$(PROJECT_DIR)/gobridge",
"$(PROJECT_DIR)",
);
MARKETING_VERSION = 1.0.30;
MARKETING_VERSION = 1.0.36;
PRODUCT_BUNDLE_IDENTIFIER = com.mysterium.launcher;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -606,7 +606,7 @@
"$(PROJECT_DIR)/gobridge",
"$(PROJECT_DIR)",
);
MARKETING_VERSION = 1.0.30;
MARKETING_VERSION = 1.0.36;
PRODUCT_BUNDLE_IDENTIFIER = com.mysterium.launcher;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
4 changes: 4 additions & 0 deletions launcher/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
@interface AppDelegate : NSObject <NSApplicationDelegate>

@property (weak) IBOutlet NSMenuItem *itemEnableNode;
@property (weak) IBOutlet NSMenuItem *itemEnableNative;
@property (weak) IBOutlet NSMenuItem *itemEnableDocker;
@property (weak) IBOutlet NSMenu *statusBarMenu;

@property (strong) NSWindowController *mainWin;
Expand All @@ -27,6 +29,8 @@
- (IBAction)enableNode:(id)sender;
- (IBAction)openNodeUIAction:(id)sender;

- (IBAction)enableNative:(id)sender;
- (IBAction)enableDocker:(id)sender;
@end


Expand Down
23 changes: 19 additions & 4 deletions launcher/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,31 @@ - (IBAction)showNetworkingDlg:(id)sender {
- (IBAction)enableNode:(id)sender {
NSLog(@"enableNode %@", mod.enabled);

if ([mod.enabled isEqualToNumber:@0]) {
mod.enabled = @1;
} else {
mod.enabled = @0;
mod.enabled = [mod.enabled isEqualToNumber:@0]? @1 : @0;
[mod setState];
[self setMenuItemState];
}

- (IBAction)enableNative:(NSButton*)sender {

switch (sender.tag) {
case 1:
mod.backend = @"native";
break;
case 2:
mod.backend = @"docker";
break;
}

[mod setState];
[self setMenuItemState];
}

- (void)setMenuItemState {
[self.itemEnableNode setState:(NSControlStateValue) [mod.enabled intValue]];

[self.itemEnableNative setState:(NSControlStateValue) [mod.backend isEqualToString:@"native"]?1:0];
[self.itemEnableDocker setState:(NSControlStateValue) [mod.backend isEqualToString:@"docker"]?1:0];
}

@end
30 changes: 25 additions & 5 deletions launcher/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15705" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="20037" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15705"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="20037"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand All @@ -15,6 +15,8 @@
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate">
<connections>
<outlet property="itemEnableDocker" destination="19M-bp-ipp" id="ih2-dr-wyq"/>
<outlet property="itemEnableNative" destination="DxM-Jr-zSe" id="Bi3-km-rrG"/>
<outlet property="itemEnableNode" destination="NMo-om-nkz" id="pHd-EP-dkz"/>
<outlet property="statusBarMenu" destination="9Rz-46-1v1" id="TGN-b0-jWj"/>
</connections>
Expand Down Expand Up @@ -57,7 +59,25 @@
<action selector="showUpgradeDlg:" target="Voe-Tx-rLC" id="NDB-Ye-cSA"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="4je-JR-u6R"/>
<menuItem isSeparatorItem="YES" id="4je-JR-u6R">
<attributedString key="attributedTitle"/>
</menuItem>
<menuItem title="Backend:" enabled="NO" id="RfF-90-qTi">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Native (beta)" tag="1" id="DxM-Jr-zSe">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="enableNative:" target="Voe-Tx-rLC" id="q89-Vb-ARt"/>
</connections>
</menuItem>
<menuItem title="Docker" tag="2" id="19M-bp-ipp">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="enableNative:" target="Voe-Tx-rLC" id="3CD-BX-0Cr"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="gNR-Gd-iBb"/>
<menuItem title="Hide launcher" keyEquivalent="h" id="Olw-nP-bQN">
<connections>
<action selector="hide:" target="-1" id="PnN-Uc-m68"/>
Expand Down Expand Up @@ -85,13 +105,13 @@
</menu>
</menuItem>
</items>
<point key="canvasLocation" x="21" y="-84"/>
<point key="canvasLocation" x="-332" y="-79"/>
</menu>
<window title="launcher" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="QvC-M9-y7g">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="335" y="390" width="269" height="192"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1057"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="875"/>
<view key="contentView" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="269" height="192"/>
<autoresizingMask key="autoresizingMask"/>
Expand Down
Loading

0 comments on commit 93f5db8

Please sign in to comment.