diff --git a/src/Neo.CLI/CLI/MainService.Plugins.cs b/src/Neo.CLI/CLI/MainService.Plugins.cs
index a73cdcb31e..761dd386d2 100644
--- a/src/Neo.CLI/CLI/MainService.Plugins.cs
+++ b/src/Neo.CLI/CLI/MainService.Plugins.cs
@@ -32,8 +32,9 @@ partial class MainService
/// Process "install" command
///
/// Plugin name
+ /// Custom plugins download url, this is optional.
[ConsoleCommand("install", Category = "Plugin Commands")]
- private void OnInstallCommand(string pluginName)
+ private void OnInstallCommand(string pluginName, string? downloadUrl = null)
{
if (PluginExists(pluginName))
{
@@ -41,7 +42,7 @@ private void OnInstallCommand(string pluginName)
return;
}
- var result = InstallPluginAsync(pluginName).GetAwaiter().GetResult();
+ var result = InstallPluginAsync(pluginName, downloadUrl).GetAwaiter().GetResult();
if (result)
{
var asmName = Assembly.GetExecutingAssembly().GetName().Name;
@@ -74,16 +75,17 @@ private void OnReinstallCommand(string pluginName)
///
/// name of the plugin
///
+ /// Custom plugin download url.
///
/// Downloaded content
- private static async Task DownloadPluginAsync(string pluginName, Version pluginVersion, bool prerelease = false)
+ private static async Task DownloadPluginAsync(string pluginName, Version pluginVersion, string? customDownloadUrl = null, bool prerelease = false)
{
using var httpClient = new HttpClient();
var asmName = Assembly.GetExecutingAssembly().GetName();
httpClient.DefaultRequestHeaders.UserAgent.Add(new(asmName.Name!, asmName.Version!.ToString(3)));
-
- var json = await httpClient.GetFromJsonAsync(Settings.Default.Plugins.DownloadUrl) ?? throw new HttpRequestException($"Failed: {Settings.Default.Plugins.DownloadUrl}");
+ var url = customDownloadUrl == null ? Settings.Default.Plugins.DownloadUrl : new Uri(customDownloadUrl);
+ var json = await httpClient.GetFromJsonAsync(url) ?? throw new HttpRequestException($"Failed: {url}");
var jsonRelease = json.AsArray()
.SingleOrDefault(s =>
s != null &&
@@ -110,10 +112,12 @@ private static async Task DownloadPluginAsync(string pluginName, Version
/// Install plugin from stream
///
/// Name of the plugin
+ /// Custom plugins download url.
/// Dependency set
/// Install by force for `update`
private async Task InstallPluginAsync(
string pluginName,
+ string? downloadUrl = null,
HashSet? installed = null,
bool overWrite = false)
{
@@ -124,14 +128,14 @@ private async Task InstallPluginAsync(
try
{
- using var stream = await DownloadPluginAsync(pluginName, Settings.Default.Plugins.Version, Settings.Default.Plugins.Prerelease);
+ using var stream = await DownloadPluginAsync(pluginName, Settings.Default.Plugins.Version, downloadUrl, Settings.Default.Plugins.Prerelease);
using var zip = new ZipArchive(stream, ZipArchiveMode.Read);
var entry = zip.Entries.FirstOrDefault(p => p.Name == "config.json");
if (entry is not null)
{
await using var es = entry.Open();
- await InstallDependenciesAsync(es, installed);
+ await InstallDependenciesAsync(es, installed, downloadUrl);
}
zip.ExtractToDirectory("./", true);
return true;
@@ -148,7 +152,8 @@ private async Task InstallPluginAsync(
///
/// plugin config path in temp
/// Dependency set
- private async Task InstallDependenciesAsync(Stream config, HashSet installed)
+ /// Custom plugin download url.
+ private async Task InstallDependenciesAsync(Stream config, HashSet installed, string? downloadUrl = null)
{
var dependency = new ConfigurationBuilder()
.AddJsonStream(config)
@@ -162,7 +167,7 @@ private async Task InstallDependenciesAsync(Stream config, HashSet insta
foreach (var plugin in dependencies.Where(p => p is not null && !PluginExists(p)))
{
ConsoleHelper.Info($"Installing dependency: {plugin}");
- await InstallPluginAsync(plugin!, installed);
+ await InstallPluginAsync(plugin!, downloadUrl, installed);
}
}
diff --git a/src/Neo.CLI/Settings.cs b/src/Neo.CLI/Settings.cs
index 7687b8cbda..e831d15ebd 100644
--- a/src/Neo.CLI/Settings.cs
+++ b/src/Neo.CLI/Settings.cs
@@ -13,6 +13,7 @@
using Neo.Network.P2P;
using Neo.Persistence;
using System;
+using System.Linq;
using System.Reflection;
using System.Threading;
diff --git a/src/Neo.CLI/config.json b/src/Neo.CLI/config.json
index 87e38b2efe..821eb364f5 100644
--- a/src/Neo.CLI/config.json
+++ b/src/Neo.CLI/config.json
@@ -6,8 +6,8 @@
"Active": false
},
"Storage": {
- "Engine": "LevelDBStore", // Candidates [MemoryStore, LevelDBStore, RocksDBStore]
- "Path": "Data_LevelDB_{0}" // {0} is a placeholder for the network id
+ "Engine": "LevelDBStore",
+ "Path": "Data_LevelDB_{0}"
},
"P2P": {
"Port": 10333,
diff --git a/src/Neo.CLI/config.json.md b/src/Neo.CLI/config.json.md
index da3bbaec6e..b32b1f2f8f 100644
--- a/src/Neo.CLI/config.json.md
+++ b/src/Neo.CLI/config.json.md
@@ -1,6 +1,6 @@
# README for Application and Protocol Configuration JSON File
-This README provides an explanation for each field in the JSON configuration file for a NEO node.
+This README provides an explanation for each field in the JSON configuration file for a Neo node.
## ApplicationConfiguration
@@ -31,15 +31,15 @@ This README provides an explanation for each field in the JSON configuration fil
- **NeoNameService**: Script hash of the Neo Name Service contract. MainNet is `0x50ac1c37690cc2cfc594472833cf57505d5f46de`, TestNet is `0x50ac1c37690cc2cfc594472833cf57505d5f46de`.
### Plugins
-- **DownloadUrl**: URL to download plugins, typically from the NEO project's GitHub releases. Default is `https://api.github.com/repos/neo-project/neo/releases`.
+- **DownloadUrl**: URL to download plugins, typically from the Neo project's GitHub releases. Default is `https://api.github.com/repos/neo-project/neo/releases`.
## ProtocolConfiguration
### Network
-- **Network**: Network ID for the NEO network. MainNet is `860833102`, TestNet is `894710606`
+- **Network**: Network ID for the Neo network. MainNet is `860833102`, TestNet is `894710606`
### AddressVersion
-- **AddressVersion**: Version byte used in NEO address generation. Default is `53`.
+- **AddressVersion**: Version byte used in Neo address generation. Default is `53`.
### MillisecondsPerBlock
- **MillisecondsPerBlock**: Time interval between blocks in milliseconds. Default is `15000` (15 seconds).
@@ -82,4 +82,4 @@ This README provides an explanation for each field in the JSON configuration fil
- `seed4t5.neo.org:20333`
- `seed5t5.neo.org:20333`
-This configuration file is essential for setting up and running a NEO node, ensuring proper logging, storage, network connectivity, and consensus protocol parameters.
+This configuration file is essential for setting up and running a Neo node, ensuring proper logging, storage, network connectivity, and consensus protocol parameters.