-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add AppProtocolVersion property to SwarmOptions
- Loading branch information
Showing
11 changed files
with
80 additions
and
20 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
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
33 changes: 33 additions & 0 deletions
33
sdk/node/Libplanet.Node/DataAnnotations/AppProtocolVersionAttribute.cs
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,33 @@ | ||
#pragma warning disable SA1402 // File may only contain a single type | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace Libplanet.Node.DataAnnotations; | ||
|
||
[AttributeUsage(AttributeTargets.Property)] | ||
public sealed class AppProtocolVersionAttribute : RegularExpressionAttribute | ||
{ | ||
public const string VersionPattern = @"\d+"; | ||
public const string AddressPattern = @"[0-9a-fA-F]{40}"; | ||
public const string Base64Pattern | ||
= @"(?:[A-Za-z0-9+\.]{4})*(?:[A-Za-z0-9+\.]{2}==|[A-Za-z0-9+\.]{3}=)?"; | ||
|
||
public static readonly string OriginPattern = GenerateOriginPattern(); | ||
|
||
public AppProtocolVersionAttribute() | ||
: base($"^{OriginPattern}$") | ||
{ | ||
} | ||
|
||
private static string GenerateOriginPattern() | ||
{ | ||
var items = new string[] | ||
{ | ||
$"(?<version>{VersionPattern})", | ||
$"(?<address>{AddressPattern})", | ||
$"(?<signature>{Base64Pattern})", | ||
$"(?<extra>{Base64Pattern})", | ||
}; | ||
|
||
return string.Join('/', items); | ||
} | ||
} |
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
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