Skip to content
This repository was archived by the owner on Dec 7, 2023. It is now read-only.
Merged
Changes from 13 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
93272da
Install plugin and dependancies.
Aug 6, 2021
0ed1611
remove unsed if statement
Aug 6, 2021
6bd6491
fix incorrect file path check
Aug 6, 2021
b789bfa
Add plugin file checksum
Aug 6, 2021
57556ae
update format
Aug 6, 2021
6920e43
Update Checksum
Aug 6, 2021
79a63ed
Update MainService.Plugins.cs
Aug 7, 2021
aac4acb
Merge branch 'master' into plugin-dependancy
Aug 7, 2021
32e9835
Update MainService.Plugins.cs
Aug 7, 2021
6ace0c0
Update MainService.Plugins.cs
Aug 8, 2021
aec9aa2
Update MainService.Plugins.cs
Aug 8, 2021
6b697b3
version
Aug 8, 2021
3af86cc
Update Helper.cs
Aug 8, 2021
0c26ba9
Remove using
erikzhang Aug 8, 2021
252956b
Merge branch 'plugin-dependancy' of github.com:Liaojinghui/neo-node i…
Aug 8, 2021
3786f17
remove hard code dependency
Aug 8, 2021
cbd2566
catch exception if no dependency file
Aug 8, 2021
5ba876f
skip existing dependency
Aug 8, 2021
6cdf6c4
fix typo
Aug 8, 2021
3f2f34f
update comments
Aug 9, 2021
f22c4e2
add `reinstall` command
Aug 9, 2021
7b8a696
fix format
Aug 9, 2021
571f8de
optimise dependency check
Aug 9, 2021
e2e8537
optimise `Uninstall` command
Aug 9, 2021
2e1942b
check dependency from archive file before install plugin
Aug 10, 2021
a8bf3aa
prevent circular dependency
Aug 10, 2021
4e5eac6
fix typo
Aug 10, 2021
5718a3d
update comment
Aug 10, 2021
6ab1591
fix `reinstall`
Aug 10, 2021
1d409ab
fix circular dependency
Aug 10, 2021
386cfdd
fix format
Aug 10, 2021
2e804c3
install dependency from config.json
Aug 15, 2021
b03fbc5
Merge branch 'master' into plugin-dependancy
Aug 19, 2021
a26dff4
Add url
Aug 19, 2021
c29cdd8
Merge branch 'master' into plugin-dependancy
Aug 25, 2021
087bbaf
Update MainService.Plugins.cs
shargon Aug 26, 2021
90d062e
Merge branch 'master' into plugin-dependancy
Aug 27, 2021
1b1651a
update command suggestion
Aug 30, 2021
224bf21
Merge branch 'master' into plugin-dependancy
Aug 31, 2021
450cc22
remove unused file path.
Sep 3, 2021
7e29ca6
Merge branch 'master' into plugin-dependancy
shargon Sep 16, 2021
8172b16
Merge branch 'master' into plugin-dependancy
Oct 10, 2021
be611a9
Merge branch 'master' into plugin-dependancy
Dec 11, 2021
4b4a9c5
fix merge issues
Dec 11, 2021
05ba379
Merge branch 'master' into plugin-dependancy
Jan 19, 2022
cc201b9
update typo and format
Jan 19, 2022
79e5ada
update console output format
Mar 29, 2022
5dd3b9f
Merge branch 'develop' into plugin-dependancy
Apr 1, 2022
1833dd6
Update neo-cli/CLI/MainService.Plugins.cs
Apr 8, 2022
2ffb8ae
Rename
erikzhang Apr 10, 2022
3c2adee
Update MainService.Plugins.cs
erikzhang Apr 10, 2022
a2d4280
install plugin first
Apr 10, 2022
be78734
update temp path
Apr 10, 2022
4e688e3
in case of multiple `config.json` no matter what
Apr 10, 2022
44b30b7
format
Apr 10, 2022
1b429da
Optimize
erikzhang Apr 11, 2022
8cf1154
Remove pluginToInstall
erikzhang Apr 11, 2022
372928a
Optimize console messages
erikzhang Apr 11, 2022
d653a05
Optimize InstallPluginAsync and InstallDependency
erikzhang Apr 11, 2022
d91896d
Rename
erikzhang Apr 11, 2022
72ff5e6
Add installed
erikzhang Apr 11, 2022
321eee1
remove reinstall
Apr 11, 2022
a65b8e1
Revert "remove reinstall"
Apr 13, 2022
c3b40a1
fix reinstall issue
Apr 13, 2022
d8c257c
optimise logic
Apr 13, 2022
6c4542f
optimise logic
Apr 13, 2022
c9754a2
optimise logic...
Apr 13, 2022
5091ae0
fix format
Apr 13, 2022
770d3b0
ignore file operation exception
Apr 13, 2022
bd0631b
remove uninstall.plugin.txt
Apr 14, 2022
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
66 changes: 58 additions & 8 deletions neo-cli/CLI/MainService.Plugins.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Security.Cryptography;

namespace Neo.CLI
{
Expand All @@ -17,6 +18,30 @@ partial class MainService
/// <param name="pluginName">Plugin name</param>
[ConsoleCommand("install", Category = "Plugin Commands")]
private void OnInstallCommand(string pluginName)
{
CheckAndInstall(pluginName);
}

private void CheckAndInstall(string pluginName)
{
if (pluginName == "ApplicationLogs" ||
pluginName == "RpcNep17Tracker" ||
pluginName == "StateService" ||
pluginName == "OracleService"
)
{
if (!Directory.Exists("./Plugins/RpcServer") || !File.Exists("./Plugins/RpcServer.dll"))
{
Console.WriteLine($"Installing plugin and dependencies.");

InstallPlugin(DownloadPlugin("RpcServer"));
}
}
InstallPlugin(DownloadPlugin(pluginName));
}


private MemoryStream DownloadPlugin(string pluginName)
{
HttpWebRequest request = WebRequest.CreateHttp($"https://github.com/neo-project/neo-modules/releases/download/v{typeof(Plugin).Assembly.GetVersion()}/{pluginName}.zip");
HttpWebResponse response;
Expand Down Expand Up @@ -49,20 +74,45 @@ private void OnInstallCommand(string pluginName)
}
using (response)
{
var totalRead = 0L;
byte[] buffer = new byte[1024];
int read;

using Stream stream = response.GetResponseStream();
using ZipArchive zip = new(stream, ZipArchiveMode.Read);
try
{
zip.ExtractToDirectory(".");
Console.WriteLine($"Install successful, please restart neo-cli.");
}
catch (IOException)

var output = new MemoryStream();
while ((read = stream.Read(buffer, 0, buffer.Length)) > 0)
{
Console.WriteLine($"Plugin already exist.");
output.Write(buffer, 0, read);
totalRead += read;
Console.Write($"\rDownloading {pluginName}.zip {totalRead / 1024}KB/{response.ContentLength / 1024}KB {(totalRead * 100) / response.ContentLength}%");
}
Console.WriteLine();

return output;
}
}


private void InstallPlugin(MemoryStream stream)
{
using (SHA256 sha256 = SHA256.Create())
{
Console.WriteLine("SHA256: " + sha256.ComputeHash(stream.ToArray()).ToHexString().ToString());
}

using ZipArchive zip = new(stream, ZipArchiveMode.Read);

try
{
zip.ExtractToDirectory(".");
Console.WriteLine($"Install successful, please restart neo-cli.");
}
catch (IOException)
{
Console.WriteLine($"Plugin already exist.");
};
}
/// <summary>
/// Process "uninstall" command
/// </summary>
Expand Down