-
Notifications
You must be signed in to change notification settings - Fork 4
/
FixedHostPlugIn.vb
69 lines (57 loc) · 2.45 KB
/
FixedHostPlugIn.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Imports System.Threading.Tasks
Imports JHSoftware.SimpleDNS.Plugin
Public Class FixedHostPlugIn
Implements ILookupRecord
Implements IOptionsUI
Dim cfg As MyConfigHost
Dim cfgHNDom As JHSoftware.SimpleDNS.DomName
Public Property Host As IHost Implements IPlugInBase.Host
#Region "not implemented"
Public Function InstanceConflict(ByVal config1 As String, ByVal config2 As String, ByRef errorMsg As String) As Boolean Implements JHSoftware.SimpleDNS.Plugin.IPlugInBase.InstanceConflict
Return False
End Function
Public Sub StopService() Implements JHSoftware.SimpleDNS.Plugin.IPlugInBase.StopService
End Sub
Private Function StartService() As Task Implements IPlugInBase.StartService
Return Task.CompletedTask
End Function
#End Region
Public Function GetPlugInTypeInfo() As TypeInfo Implements JHSoftware.SimpleDNS.Plugin.IPlugInBase.GetTypeInfo
With GetPlugInTypeInfo
.Name = "Fixed Host Name"
.Description = "Returns a fixed host name"
.InfoURL = "https://simpledns.plus/plugin-fixedhostname"
End With
End Function
Public Sub LoadConfig(config As String, instanceID As Guid, dataPath As String) Implements IPlugInBase.LoadConfig
cfg = MyConfigHost.Load(config)
cfgHNDom = JHSoftware.SimpleDNS.DomName.Parse(cfg.HostName)
End Sub
Public Function GetOptionsUI(ByVal instanceID As Guid, ByVal dataPath As String) As JHSoftware.SimpleDNS.Plugin.OptionsUI Implements JHSoftware.SimpleDNS.Plugin.IOptionsUI.GetOptionsUI
Return New FixedHostUI
End Function
Public Function LookupRecord(request As IRequestContext) As Task(Of RecordData) Implements ILookupRecord.LookupRecord
If cfg.CNAME Then
If request.QName = cfgHNDom Then Return Task.FromResult(Of RecordData)(Nothing)
Return Task.FromResult(New RecordData With {
.RRType = JHSoftware.SimpleDNS.DNSRecType.CNAME,
.Data = cfg.HostName,
.TTL = cfg.TTL
})
ElseIf (cfg.MX AndAlso request.QType = DNSRecType.MX) OrElse
(cfg.NS AndAlso request.QType = DNSRecType.NS) OrElse
(cfg.PTR AndAlso request.QType = DNSRecType.PTR) Then
Dim rv As New RecordData With {.RRType = request.QType, .TTL = cfg.TTL}
If request.QType = DNSRecType.MX Then
'MX
rv.Data = "10 " & cfg.HostName
Else
'NS,PTR
rv.Data = cfg.HostName
End If
Return Task.FromResult(rv)
Else
Return Task.FromResult(Of RecordData)(Nothing)
End If
End Function
End Class