Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS Util Plugin, MBS MacOSX Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacOSX/DNS Lookup
This example is the version from Sun, 17th Mar 2012.
Project "DNS Lookup.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control QueryButton Inherits PushButton
ControlInstance QueryButton Inherits PushButton
EventHandler Sub Action()
dim c as integer = PopupClass.RowTag(PopupClass.ListIndex)
dim t as integer = PopupType.RowTag(PopupType.ListIndex)
dim n as string = EditField1.text
List.DeleteAllRows
List.AddRow "Class:",c
List.AddRow "Type:" ,t
List.AddRow "Name:" ,n
dim r as DNSReplyMBS = DNSUtilMBS.Lookup(n, c, t)
if r=nil then
List.AddRow "Failed to perform query"
Return
end if
// Status
dim s as string
Select case r.Status
case r.StatusOK
s="OK"
case r.StatusBadHandle
s="bad handle"
case r.StatusMalformedQuery
s="malformed query"
case r.StatusTimeout
s="timeout"
case r.StatusSendFailed
s="send failed"
case r.StatusReceiveFailed
s="receive failed"
case r.StatusConnectionFailed
s="connection failed"
case r.StatusWrongServer
s="wrong server"
case r.StatusWrongXID
S="wrong XID"
case r.StatusWrongQuestion
s="wrong question"
else
s="?"
end Select
list.AddRow "Status: "+str(r.Status)+" ("+s+")"
// Server
list.AddFolder "Server", r.Server
list.AddFolder "Header", r.Header
for each q as DNSQuestionMBS in r.Questions
list.AddFolder "Question", q
next
for each q as DNSResourceRecordMBS in r.Answers
list.AddFolder "Answer", q
next
for each q as DNSResourceRecordMBS in r.Authoritys
list.AddFolder "Authority", q
next
for each q as DNSResourceRecordMBS in r.Additionals
list.AddFolder "Additional", q
next
End EventHandler
End Control
Control EditField1 Inherits TextField
ControlInstance EditField1 Inherits TextField
End Control
Control List Inherits Listbox
ControlInstance List Inherits Listbox
EventHandler Sub ExpandRow(row As Integer)
dim v as Variant = me.CellTag(row, 0)
if v isa DNSHeaderMBS then
dim h as DNSHeaderMBS = v
List.AddRow "Flags:", h.flags
List.AddRow "XID:", h.xid
List.AddRow "AnswerCount:", h.AnswerCount
List.AddRow "AuthorityCount:", h.AuthorityCount
List.AddRow "AdditionalCount:", h.AdditionalCount
List.AddRow "QuestionCount:", h.QuestionCount
end if
if v isa DNSSocketAddressMBS then
dim s as DNSSocketAddressMBS = v
List.AddRow "Family:", s.Family
List.AddRow "Address:", s.address
List.AddRow "Port:", s.Port
end if
if v isa DNSQuestionMBS then
dim q as DNSQuestionMBS = v
List.AddRow "DNS Class", q.dnsclass
List.AddRow "DNS Type", q.dnstype
List.AddRow "Name", q.name
end if
if v isa DNSResourceRecordMBS then
dim r as DNSResourceRecordMBS = v
List.AddRow "DNS Type:",r.dnstype
List.AddRow "DNS Class:",r.dnsclass
List.AddRow "TTL:",r.ttl
List.AddRow "Name:",r.name
List.AddFolder "Record:",r.Record
end if
if v isa DNSAddressRecordMBS then
dim r as DNSAddressRecordMBS = v
List.AddRow "Address:",r.address
end if
if v isa DNSDomainNameRecordMBS then
dim r as DNSDomainNameRecordMBS = v
List.AddRow "Name:",r.name
end if
if v isa DNSMXRecordMBS then
dim r as DNSMXRecordMBS = v
List.AddRow "Name:",r.name
List.AddRow "Preference:",r.preference
end if
if v isa DNSTXTRecordMBS then
dim r as DNSTXTRecordMBS = v
dim c as integer=r.Count-1
for i as integer=0 to c
List.AddRow "String "+str(i+1),r.Strings(i)
next
end if
if v isa DNSSOARecordMBS then
dim r as DNSSOARecordMBS = v
List.AddRow "Expire:",r.expire
List.AddRow "Minimum:",r.minimum
List.AddRow "Mname:",r.mname
List.AddRow "Refresh:",r.refresh
List.AddRow "Retry:",r.retry
List.AddRow "Rname:",r.rname
List.AddRow "Serial:",r.serial
end if
if v isa DNSRawResourceRecordMBS then
dim r as DNSRawResourceRecordMBS = v
List.AddRow "Length:",r.length
List.AddRow "Data:",r.data
end if
if v isa DNSWKSRecordMBS then
dim r as DNSWKSRecordMBS = v
dim m(-1) as string
dim c as integer = r.maplength-1
for i as integer = 0 to c
m.Append str(r.Map(i))
next
List.AddRow "Map:",Join(m,", ")
List.AddRow "Address:",r.address
List.AddRow "Protocol:",r.protocol
end if
if v isa DNSHINFORecordMBS then
dim r as DNSHINFORecordMBS = v
List.AddRow "CPU:",r.CPU
List.AddRow "OS:",r.OS
end if
if v isa DNSMINFORecordMBS then
dim r as DNSMINFORecordMBS = v
List.AddRow "emailbx:",r.emailbx
List.AddRow "rmailbx:",r.rmailbx
end if
if v isa DNSRPRecordMBS then
dim r as DNSRPRecordMBS = v
List.AddRow "mailbox:",r.mailbox
List.AddRow "txtdname:",r.txtdname
end if
if v isa DNSAFSDBRecordMBS then
dim r as DNSAFSDBRecordMBS = v
List.AddRow "hostname:",r.hostname
List.AddRow "subtype:",r.subtype
end if
if v isa DNSX25RecordMBS then
dim r as DNSX25RecordMBS = v
List.AddRow "psdnAddress:",r.psdnAddress
end if
if v isa DNSISDNRecordMBS then
dim r as DNSISDNRecordMBS = v
List.AddRow "isdnAddress:",r.isdnAddress
List.AddRow "subAddress:",r.subAddress
end if
if v isa DNSRTRecordMBS then
dim r as DNSRTRecordMBS = v
List.AddRow "intermediate:",r.intermediate
List.AddRow "preference:",r.preference
end if
if v isa DNSIN6AddressRecordMBS then
dim r as DNSIN6AddressRecordMBS = v
List.AddRow "Address:",r.address
List.AddRow "RawAddress:",EncodingToHexMBS(r.rawaddress)
end if
if v isa DNSLocRecordMBS then
dim r as DNSLocRecordMBS = v
List.AddRow "Altitude:",r.altitude
List.AddRow "HorizontalPrecision:",r.horizontalPrecision
List.AddRow "Latitude:",r.latitude
List.AddRow "Longitude:",r.longitude
List.AddRow "Size:",r.size
List.AddRow "Version:",r.version
List.AddRow "VerticalPrecision:",r.verticalPrecision
end if
if v isa DNSSRVRecordMBS then
dim r as DNSSRVRecordMBS = v
List.AddRow "port:",r.port
List.AddRow "priority:",r.priority
List.AddRow "target:",r.target
List.AddRow "weight:",r.weight
end if
End EventHandler
End Control
Control PopupType Inherits PopupMenu
ControlInstance PopupType Inherits PopupMenu
EventHandler Sub Open()
me.AddRow "TypeA", 1 // 1
me.AddRow "TypeNS", 2 // 2
me.AddRow "TypeMD", 3 // 3
me.AddRow "TypeMF", 4 // 4
me.AddRow "TypeCNAME", 5 // 5
me.AddRow "TypeSOA", 6 // 6
me.AddRow "TypeMB", 7 // 7
me.AddRow "TypeMG", 8 // 8
me.AddRow "TypeMR", 9 // 9
me.AddRow "TypeNULL", &h0a // 10
me.AddRow "TypeWKS", &h0b // 11
me.AddRow "TypePTR", &h0c // 12
me.AddRow "TypeHINFO", &h0d // 13
me.AddRow "TypeMINFO", &h0e // 14
me.AddRow "TypeMX", &h0f // 15
me.AddRow "TypeTEXT", &h10 // 16
// RFC 1183
me.AddRow "TypeRP", &h11 // 17
me.AddRow "TypeAFSDB", &h12 // 18
me.AddRow "TypeX25", &h13 // 19
me.AddRow "TypeISDN", &h14 // 20
me.AddRow "TypeRT", &h15 // 21
// RFC 1348
me.AddRow "TypeNSAP", &h16 // 22
me.AddRow "TypeNSAPPTR", &h17 // 23
// RFC 2065 (DNS security)
me.AddRow "TypeSIG", &h18 // 24
me.AddRow "TypeKEY", &h19 // 25
// RFC 1664 (X.400 mail)
me.AddRow "TypePX", &h1a // 26
// RFC 1712 (Geographic position)
me.AddRow "TypeGPOS", &h1b // 27
// RFC 1886 (IPv6 Address)
me.AddRow "TypeAAAA", &h1c // 28
// RFC 1876 (Geographic location)
me.AddRow "TypeLOC", &h1d // 29
// RFC 2065 (Secure negative response)
me.AddRow "TypeNXT", &h1e // 30
// RFC 2052 (Service location)
me.AddRow "TypeSRV", &h21 // 33
// ATM Standard something-or-another
me.AddRow "TypeATMA", &h22 // 34
//
// Query only types (1035, 1995)
//
me.AddRow "TypeTKEY", &hf9 // 249
me.AddRow "TypeTSIG", &hfa // 250
me.AddRow "TypeIXFR", &hfb // 251
me.AddRow "TypeAXFR", &hfc // 252
me.AddRow "TypeMAILB", &hfd // 253
me.AddRow "TypeMAILA", &hfe // 254
me.AddRow "TypeALL", &hff // 255
me.AddRow "TypeANY", &hff // 255
me.ListIndex=0
End EventHandler
End Control
Control PopupClass Inherits PopupMenu
ControlInstance PopupClass Inherits PopupMenu
EventHandler Sub Open()
me.AddRow "ClassINTERNET", 1 // 1
me.AddRow "ClassCSNET", 2 // 2
me.AddRow "ClassCHAOS", 3 // 3
me.AddRow "ClassHESIOD", 4 // 4
me.AddRow "ClassNONE", &hfe // 254
me.AddRow "ClassALL", &hff // 255
me.AddRow "ClassANY", &hff // 255
me.ListIndex=0
End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action()
test "www.apple.com", DNSUtilMBS.ClassINTERNET, DNSUtilMBS.TypeA
End EventHandler
End Control
Control PushButton3 Inherits PushButton
ControlInstance PushButton3 Inherits PushButton
EventHandler Sub Action()
test "www.six.heise.de", DNSUtilMBS.ClassINTERNET, DNSUtilMBS.TypeAAAA
End EventHandler
End Control
Sub test(name as string, cc as integer, tt as integer)
EditField1.text = name
dim c as integer = PopupClass.ListCount-1
for i as integer=0 to c
if PopupClass.RowTag(i)=cc then
PopupClass.ListIndex=i
exit
end if
next
c = PopupType.ListCount-1
for i as integer=0 to c
if PopupType.RowTag(i)=tt then
PopupType.ListIndex=i
exit
end if
next
querybutton.Push
End Sub
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
Module Module1
Sub AddFolder(extends p as listbox, s as string, v as Variant)
p.AddFolder s
p.celltag(p.lastindex,0)=v
End Sub
Sub AddRow(extends p as PopupMenu, s as string, v as Variant)
p.AddRow s
p.RowTag(p.ListCount-1)=v
End Sub
Sub AddRow(extends p as listbox, s as string, v as Variant)
p.AddRow s
p.cell(p.lastindex,1)=v
End Sub
End Module
End Project
The items on this page are in the following plugins: MBS MacOSX Plugin.