-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
105 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Microsoft.Extensions.DependencyInjection.Extensions; | ||
using NewLife.Caching; | ||
using NewLife.Remoting.Extensions.Models; | ||
using NewLife.Remoting.Extensions.Services; | ||
using NewLife.Security; | ||
|
||
namespace NewLife.Remoting.Extensions; | ||
|
||
/// <summary>远程通信框架扩展</summary> | ||
public static class RemotingExtensions | ||
{ | ||
/// <summary>添加远程通信服务端</summary> | ||
/// <param name="services"></param> | ||
/// <param name="setting"></param> | ||
/// <returns></returns> | ||
/// <exception cref="ArgumentNullException"></exception> | ||
public static IServiceCollection AddRemoting(this IServiceCollection services, ITokenSetting setting) | ||
{ | ||
if (setting == null) throw new ArgumentNullException(nameof(setting)); | ||
|
||
// 注册Remoting所必须的服务 | ||
services.TryAddSingleton<TokenService>(); | ||
services.TryAddSingleton(setting); | ||
|
||
// 注册密码提供者,用于通信过程中保护密钥,避免明文传输 | ||
services.TryAddSingleton<IPasswordProvider>(new SaltPasswordProvider { Algorithm = "md5", SaltTime = 60 }); | ||
|
||
services.TryAddSingleton<ICache, MemoryCache>(); | ||
|
||
return services; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace NewLife.Remoting.Clients; | ||
|
||
/// <summary>客户端设置</summary> | ||
public interface IClientSetting | ||
{ | ||
/// <summary>服务端地址。IoT服务平台地址</summary> | ||
String Server { get; set; } | ||
|
||
/// <summary>设备证书。在一机一密时手工填写,一型一密时自动下发</summary> | ||
String DeviceCode { get; set; } | ||
|
||
/// <summary>设备密钥。在一机一密时手工填写,一型一密时自动下发</summary> | ||
String? DeviceSecret { get; set; } | ||
|
||
/// <summary>保存数据</summary> | ||
void Save(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters