Skip to content

Commit

Permalink
v. 5.2.30
Browse files Browse the repository at this point in the history
  • Loading branch information
jesperhoy committed Jan 10, 2017
1 parent 7fb3201 commit 14e5139
Show file tree
Hide file tree
Showing 8 changed files with 203 additions and 92 deletions.
16 changes: 9 additions & 7 deletions DynDNSPlugIn.vb
Expand Up @@ -50,7 +50,7 @@ Public Class DynDNSPlugIn
With GetPlugInTypeInfo
.Name = "DynDNS Service"
.Description = "Accepts remote updates from DynDNS clients"
.InfoURL = "http://www.simpledns.com/kb.asp?kbid=1267"
.InfoURL = "http://simpledns.com/plugin-dyndns"
.ConfigFile = True
.MultiThreaded = False
End With
Expand All @@ -73,7 +73,7 @@ Public Class DynDNSPlugIn
errorMsg = "Another plug-in instance is using the same host name suffix"
Return True
End If
If c1.AnyHTTPServices AndAlso c2.AnyHTTPServices AndAlso _
If c1.BaseUrlInUse AndAlso c2.BaseUrlInUse AndAlso
c1.BaseURL.ToLower = c2.BaseURL.ToLower Then
errorMsg = "Another plug-in instance is using the same base URL for HTTP services"
Return True
Expand Down Expand Up @@ -130,8 +130,8 @@ Public Class DynDNSPlugIn
user.CurTTL = elem.GetAttrInt("TTL", DefaultTTL)
user.LastUpdate = elem.GetAttrDateTime("LastUpdate", #1/1/1970#)
user.Offline = elem.GetAttrBool("Offline")
If Not user.Disabled AndAlso _
Not user.Offline AndAlso _
If Not user.Disabled AndAlso
Not user.Offline AndAlso
user.CurIP IsNot Nothing Then UserByIP.Add(user.CurIP, user)
End If
Next
Expand Down Expand Up @@ -166,19 +166,21 @@ Public Class DynDNSPlugIn
RaiseEvent LogLine("GnuDIP socket not started - Error: " & ex.Message)
End Try
End If
If Cfg.AnyHTTPServices Then
If Cfg.BaseUrlInUse Or Cfg.UpMeHttpDynCom Then
hli = New Net.HttpListener
hli.IgnoreWriteExceptions = True
hli.AuthenticationSchemes = Net.AuthenticationSchemes.Anonymous Or Net.AuthenticationSchemes.Basic
Try
hli.Prefixes.Add(Cfg.BaseURL)
If Cfg.BaseUrlInUse Then hli.Prefixes.Add(Cfg.BaseURL)
If Cfg.UpMeHttpDynCom Then hli.Prefixes.Add("http://*/nic/")
hli.Start()
hli.BeginGetContext(AddressOf HLI_CallBack, hli)
Catch ex As Exception
RaiseEvent LogLine("HTTP listener not started - Error: " & ex.Message)
Exit Sub
End Try
RaiseEvent LogLine("Listening for HTTP requests at " & Cfg.BaseURL)
If Cfg.BaseUrlInUse Then RaiseEvent LogLine("Listening for HTTP requests at " & Cfg.BaseURL)
If Cfg.UpMeHttpDynCom Then RaiseEvent LogLine("Listening for HTTP requests at http://*/nic/")
End If
End Sub

Expand Down
38 changes: 38 additions & 0 deletions HTTPHandler.vb
Expand Up @@ -15,6 +15,8 @@
Case Else
If x.EndsWith("/gnudip/cgi-bin/gdipupdt.cgi") Then
ProcGnuDIP()
ElseIf x = "/nic/update" Then
ProcDynCom()
Else
Send404()
End If
Expand Down Expand Up @@ -101,6 +103,42 @@
End If
End Sub

Private Sub ProcDynCom()
If Not plugin.Cfg.UpMeHttpDynCom Then SendError("Dyn.com update method is not enabled") : Exit Sub

Dim userID As JHSoftware.SimpleDNS.Plugin.DomainName = Nothing
Dim user As MyConfig.User = Nothing
If ctx.User Is Nothing OrElse Not TypeOf ctx.User.Identity Is Net.HttpListenerBasicIdentity Then Send401() : Exit Sub

With DirectCast(ctx.User.Identity, Net.HttpListenerBasicIdentity)
If Not JHSoftware.SimpleDNS.Plugin.DomainName.TryParse(.Name, userID) OrElse
Not plugin.Cfg.Users.TryGetValue(userID, user) OrElse
user.Disabled OrElse
user.Password <> .Password Then Send401() : Exit Sub
End With

Dim ipAddr As JHSoftware.SimpleDNS.Plugin.IPAddressV4 = Nothing
Dim x As String

x = ctx.Request.QueryString("myip")
If Not String.IsNullOrEmpty(x) Then
'When invalid IP is specified dyn.com uses client IP (tested 10 jan 2017)
If Not JHSoftware.SimpleDNS.Plugin.IPAddressV4.TryParse(x.Trim, ipAddr) Then ipAddr = DetectIP()
Else
ipAddr = DetectIP()
End If

x = ctx.Request.QueryString("offline")
If Not String.IsNullOrEmpty(x) AndAlso x.ToUpper()(0) = "Y"c Then
plugin.SetUserOffline(user, "HTTP - Dyn.com URL format")
Else
plugin.PerformUpdate(user, ipAddr, DynDNSPlugIn.DefaultTTL, "HTTP - Dyn.com URL format")
End If

ctx.Response.ContentType = "text/plain"
ctx.Response.Close(System.Text.Encoding.ASCII.GetBytes("good " & ipAddr.ToString), False)
End Sub


Private Sub ProcGnuDIP()
If Not plugin.Cfg.UpMeHttpGD Then SendError("GNUDIP authentication update method is not enabled") : Exit Sub
Expand Down
10 changes: 5 additions & 5 deletions My Project/AssemblyInfo.vb
Expand Up @@ -11,14 +11,14 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyTitle("DynDNS Service Plug-In")>
<Assembly: AssemblyDescription("DynDNS Service Plug-In")>
<Assembly: AssemblyCompany("JH Software ApS")>
<Assembly: AssemblyProduct("Simple DNS Plus")>
<Assembly: AssemblyCopyright("Copyright © 2008-2009 JH Software ApS")>
<Assembly: AssemblyProduct("Simple DNS Plus")>
<Assembly: AssemblyCopyright("Copyright © 2008-2017 JH Software ApS")>
<Assembly: AssemblyTrademark("Simple DNS Plus")>

<Assembly: ComVisible(False)>

'The following GUID is for the ID of the typelib if this project is exposed to COM
<Assembly: Guid("effbf0d7-a46c-4f32-a898-54d7d38e4120")>
<Assembly: Guid("effbf0d7-a46c-4f32-a898-54d7d38e4120")>

' Version information for an assembly consists of the following four values:
'
Expand All @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("5.2.25.0")>
<Assembly: AssemblyFileVersion("5.2.25.0")>
<Assembly: AssemblyVersion("5.2.30.0")>
<Assembly: AssemblyFileVersion("5.2.30.0")>
5 changes: 4 additions & 1 deletion MyConfig.vb
Expand Up @@ -12,13 +12,14 @@ Friend Class MyConfig
Public UpMeHttpBasic As Boolean = False
Public UpMeHttpUrl As Boolean = False
Public UpMeHttpGD As Boolean = False
Public UpMeHttpDynCom As Boolean = False
Public GnuDIPPort As Integer = 3495

Public RemoteDetect As Boolean = False

Public BaseURL As String = "http://"

Friend Function AnyHTTPServices() As Boolean
Friend Function BaseUrlInUse() As Boolean
Return (UpMeHttpBasic Or UpMeHttpUrl Or UpMeHttpGD Or RemoteDetect)
End Function

Expand All @@ -32,6 +33,7 @@ Friend Class MyConfig
root.SetAttrBool("UpMeHTTPURL", UpMeHttpUrl)
root.SetAttrBool("UpMeHTTPBasic", UpMeHttpBasic)
root.SetAttrBool("UpMeHTTPGnuDIP", UpMeHttpGD)
root.SetAttrBool("UpMeHTTPDynCom", UpMeHttpDynCom)
root.SetAttrInt("GNUDIPPort", GnuDIPPort)
root.SetAttrBool("RemoteDetect", RemoteDetect)
root.SetAttribute("BaseURL", BaseURL)
Expand All @@ -55,6 +57,7 @@ Friend Class MyConfig
.UpMeHttpUrl = root.GetAttrBool("UpMeHTTPURL")
.UpMeHttpBasic = root.GetAttrBool("UpMeHTTPBasic")
.UpMeHttpGD = root.GetAttrBool("UpMeHTTPGnuDIP")
.UpMeHttpDynCom = root.GetAttrBool("UpMeHTTPDynCom")
.GnuDIPPort = root.GetAttrInt("GNUDIPPort", 3495)
.RemoteDetect = root.GetAttrBool("RemoteDetect")
.BaseURL = root.GetAttribute("BaseURL")
Expand Down
116 changes: 78 additions & 38 deletions frmShowURLs.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions frmShowURLs.vb
Expand Up @@ -19,6 +19,9 @@ Public Class frmShowURLs
Private Sub btnCopy4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCopy4.Click
MyCopy(txtURL4)
End Sub
Private Sub btnCopy5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCopy5.Click
MyCopy(txtURL5)
End Sub

Private Sub MyCopy(ByVal txt As TextBox)
txt.SelectAll()
Expand Down

0 comments on commit 14e5139

Please sign in to comment.