Skip to content

Commit

Permalink
Change style from x.x.x.x.xxx.com to x-x-x-x.xxx.com because wildcard…
Browse files Browse the repository at this point in the history
… domain only supports one level
  • Loading branch information
xieyubo committed Nov 7, 2023
1 parent 2310c0b commit 298cdca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/IPStyleDomainRequestResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace IPDNS;

internal class IPStyleDomainRequestResolver : IRequestResolver
{
private static Regex _ipPattern = new Regex(@"^(\d+\.\d+\.\d+\.\d+)\.");
private static Regex _ipPattern = new Regex(@"^(\d+-\d+-\d+-\d+)\.");

public Task<IResponse> Resolve(IRequest request, CancellationToken cancellationToken = default)
{
Expand All @@ -22,7 +22,7 @@ public Task<IResponse> Resolve(IRequest request, CancellationToken cancellationT
if (question.Type == RecordType.A)
{
var match = _ipPattern.Match(question.Name.ToString());
if (match.Success && IPAddress.TryParse(match.Groups[1].Value, out var ipAddress))
if (match.Success && IPAddress.TryParse(match.Groups[1].Value.Replace("-", "."), out var ipAddress))
{
response.AnswerRecords.Add(new IPAddressResourceRecord(question.Name, ipAddress, ttl: TimeSpan.FromDays(3650)));
}
Expand Down

0 comments on commit 298cdca

Please sign in to comment.