Skip to content

Commit

Permalink
Modify MasterFile to be Extensible (#62)
Browse files Browse the repository at this point in the history
* Modify MasterFile to be extensible

Co-authored-by: malcomvetter <malcomvetter@gmail.com>
Co-authored-by: Mirza Kapetanovic <mirza.kapetanovic@gmail.com>
  • Loading branch information
3 people authored Nov 27, 2021
1 parent 3334793 commit 8899fc6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions DNS/Server/MasterFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

namespace DNS.Server {
public class MasterFile : IRequestResolver {
private static readonly TimeSpan DEFAULT_TTL = new TimeSpan(0);
protected static readonly TimeSpan DEFAULT_TTL = new TimeSpan(0);

private static bool Matches(Domain domain, Domain entry) {
protected static bool Matches(Domain domain, Domain entry) {
string[] labels = entry.ToString().Split('.');
string[] patterns = new string[labels.Length];

Expand All @@ -26,14 +26,14 @@ private static bool Matches(Domain domain, Domain entry) {
return re.IsMatch(domain.ToString());
}

private static void Merge<T>(IList<T> l1, IList<T> l2) {
protected static void Merge<T>(IList<T> l1, IList<T> l2) {
foreach (T obj in l2) {
l1.Add(obj);
}
}

private IList<IResourceRecord> entries = new List<IResourceRecord>();
private TimeSpan ttl = DEFAULT_TTL;
protected IList<IResourceRecord> entries = new List<IResourceRecord>();
protected TimeSpan ttl = DEFAULT_TTL;

public MasterFile(TimeSpan ttl) {
this.ttl = ttl;
Expand Down Expand Up @@ -113,11 +113,11 @@ public void AddServiceResourceRecord(string domain, ushort priority, ushort weig
return Task.FromResult(response);
}

private IList<IResourceRecord> Get(Domain domain, RecordType type) {
protected IList<IResourceRecord> Get(Domain domain, RecordType type) {
return entries.Where(e => Matches(domain, e.Name) && (e.Type == type || type == RecordType.ANY)).ToList();
}

private IList<IResourceRecord> Get(Question question) {
protected IList<IResourceRecord> Get(Question question) {
return Get(question.Name, question.Type);
}
}
Expand Down

0 comments on commit 8899fc6

Please # to comment.