-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This also removes the capability of choosing the network interface by its primary IP address, since we've never needed it and the code got too confusing.
- Loading branch information
1 parent
726ab01
commit cb72758
Showing
3 changed files
with
23 additions
and
22 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 |
---|---|---|
@@ -1,12 +1,25 @@ | ||
namespace Abc.Zebus.Transport; | ||
using System; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace Abc.Zebus.Transport; | ||
|
||
internal readonly struct ZmqEndPoint | ||
{ | ||
private static readonly Regex _endpointRegex = new(@"^tcp://(?<host>\*|[0-9a-zA-Z_.-]+):(?<port>\*|[0-9]+)/?$", RegexOptions.IgnoreCase); | ||
|
||
private readonly string? _value; | ||
|
||
public ZmqEndPoint(string? value) | ||
=> _value = value; | ||
|
||
public override string ToString() | ||
=> _value ?? "tcp://*:*"; | ||
|
||
public static (string host, string port) Parse(string? endpoint) | ||
{ | ||
var match = _endpointRegex.Match(endpoint ?? string.Empty); | ||
return match.Success | ||
? (match.Groups["host"].Value, match.Groups["port"].Value) | ||
: throw new InvalidOperationException($"Invalid endpoint: {endpoint}"); | ||
} | ||
} |
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