mirror of
https://github.com/jakobadam/RDSFactor.git
synced 2025-06-11 06:54:29 +02:00
Only listen on port 1812
Remove the second instance of the server running on port 1645. Fixes #3
This commit is contained in:
parent
18f1adb31a
commit
30872ee278
1 changed files with 40 additions and 69 deletions
|
@ -15,49 +15,42 @@ Public Class RDSFactor
|
|||
Public Shared ADField As String = ""
|
||||
Public Shared ADMailField As String = ""
|
||||
Public Shared EnableOTP As Boolean
|
||||
Public Shared secrets As NASAuthList
|
||||
|
||||
Private Shared DEBUG As Boolean
|
||||
|
||||
Private Shared UserAccessLog As New LogWriter
|
||||
Private Shared Log As New LogWriter
|
||||
|
||||
|
||||
Private radius1812 As RADIUSServer
|
||||
Private radius1645 As RADIUSServer
|
||||
Private userHash As New Hashtable
|
||||
Private packetHash As New Hashtable
|
||||
Private clientHash As New Hashtable
|
||||
|
||||
Public Shared NetBiosDomain As String = ""
|
||||
|
||||
Private Shared Provider As String = ""
|
||||
|
||||
|
||||
Private Shared ModemType As String = ""
|
||||
Private Shared ComPort As String = ""
|
||||
Private Shared SmsC As String = ""
|
||||
Private Shared MailServer As String = ""
|
||||
Private Shared SenderEmail As String = ""
|
||||
|
||||
Private TSGW As String = ""
|
||||
Public Shared secrets As NASAuthList
|
||||
|
||||
Public Shared SessionTimeOut As Integer = 30 ' in minutes
|
||||
Public Shared LaunchTimeOut As Integer = 30 ' in seconds
|
||||
Public Shared EnableSMS As Boolean = False
|
||||
Public Shared EnableEmail As Boolean = False
|
||||
|
||||
Protected Overrides Sub OnStart(ByVal args() As String)
|
||||
Private Shared DEBUG As Boolean
|
||||
Private Shared UserAccessLog As New LogWriter
|
||||
Private Shared Log As New LogWriter
|
||||
|
||||
Private server As RADIUSServer
|
||||
Private serverPort As Integer = 1812
|
||||
Private userHash As New Hashtable
|
||||
Private packetHash As New Hashtable
|
||||
Private clientHash As New Hashtable
|
||||
|
||||
Private Shared Provider As String = ""
|
||||
Private Shared ModemType As String = ""
|
||||
Private Shared ComPort As String = ""
|
||||
Private Shared SmsC As String = ""
|
||||
Private Shared MailServer As String = ""
|
||||
Private Shared SenderEmail As String = ""
|
||||
Private TSGW As String = ""
|
||||
|
||||
Protected Overrides Sub OnStart(ByVal args() As String)
|
||||
Log.filePath = ApplicationPath() & "\log.txt"
|
||||
UserAccessLog.filePath = ApplicationPath() & "\UserAccessLog.txt"
|
||||
|
||||
Log.WriteLog("---------------------------------------------------------------------------------------------------")
|
||||
ServerLog("Starting Service")
|
||||
ServerLog("Loading Configuration...")
|
||||
Call loadConfiguration()
|
||||
loadConfiguration()
|
||||
ServerLog("Starting Radius listner ports...")
|
||||
Call StartUpServer()
|
||||
StartUpServer()
|
||||
End Sub
|
||||
|
||||
Public Sub OnstartTest()
|
||||
|
@ -67,9 +60,9 @@ Public Class RDSFactor
|
|||
ServerLog("---------------------------------------------------------------------------------------------------")
|
||||
ServerLog("Starting Service")
|
||||
ServerLog("Loading Configuration...")
|
||||
Call loadConfiguration()
|
||||
loadConfiguration()
|
||||
ServerLog("Starting Radius listner ports...")
|
||||
Call StartUpServer()
|
||||
StartUpServer()
|
||||
End Sub
|
||||
|
||||
Protected Overrides Sub OnStop()
|
||||
|
@ -82,43 +75,37 @@ Public Class RDSFactor
|
|||
End Sub
|
||||
|
||||
Public Sub StartUpServer()
|
||||
|
||||
' First, let's load a list of RADIUS shared secrets
|
||||
' in a NASAuthList object (a glorified Dictionary, basically)
|
||||
secrets = New NASAuthList
|
||||
' Populate from DB, I suppose ...
|
||||
|
||||
For Each cl As DictionaryEntry In clientHash
|
||||
ServerLog("Adding Shared Secret to Radius Server")
|
||||
ServerLog("Adding Shared Secrets to Radius Server")
|
||||
secrets.AddSharedSecret(cl.Key, cl.Value)
|
||||
Next
|
||||
' Then, we just create a RADIUS server ...
|
||||
Try
|
||||
radius1812 = New RADIUSServer(1812, AddressOf ProcessPacket1812, secrets)
|
||||
ServerLog("Starting Radius Server on Port 1812...OK")
|
||||
Catch
|
||||
ServerLog("Starting Radius Server on Port 1812...FAILED")
|
||||
End Try
|
||||
|
||||
Try
|
||||
radius1645 = New RADIUSServer(1645, AddressOf ProcessPacket1645, secrets)
|
||||
ServerLog("Starting Radius Server on Port 1645...OK")
|
||||
server = New RADIUSServer(serverPort, AddressOf ProcessPacket, secrets)
|
||||
ServerLog("Starting Radius Server on Port " & serverPort & " ...OK")
|
||||
Catch
|
||||
ServerLog("Starting Radius Server on Port 1645...FAILED")
|
||||
ServerLog("Starting Radius Server on Port " & serverPort & "...FAILED")
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
' Every valid RADIUS request generated by the server(s) we created earlier
|
||||
' will fire up the callback procedure. Invalid requests are dropped, per RFC.
|
||||
Private Sub ProcessPacket1812(ByVal packet As RADIUSPacket)
|
||||
'Console.WriteLine("packet " & Now)
|
||||
ProcessPacket(radius1812, packet)
|
||||
End Sub
|
||||
Private Sub ProcessPacket(ByVal packet As RADIUSPacket)
|
||||
If Not packet.IsValid Then
|
||||
Console.WriteLine("Packet is not valid. Discarding.")
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Private Sub ProcessPacket1645(ByVal packet As RADIUSPacket)
|
||||
ProcessPacket(radius1645, packet)
|
||||
Dim handler
|
||||
If TSGW = "1" Then
|
||||
handler = New RDSHandler(packet)
|
||||
Else
|
||||
'handler = New CitrixHandler(packet)
|
||||
End If
|
||||
|
||||
handler.ProcessRequest()
|
||||
End Sub
|
||||
|
||||
Public Shared Sub AccessLog(packet As RADIUSPacket, message As String)
|
||||
|
@ -147,22 +134,6 @@ Public Class RDSFactor
|
|||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub ProcessPacket(ByVal server As RADIUSServer, ByVal packet As RADIUSPacket)
|
||||
If Not packet.IsValid Then
|
||||
Console.WriteLine("Packet is not valid. Discarding.")
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim handler
|
||||
If TSGW = "1" Then
|
||||
handler = New RDSHandler(packet)
|
||||
Else
|
||||
'handler = New CitrixHandler(packet)
|
||||
End If
|
||||
|
||||
handler.ProcessRequest()
|
||||
End Sub
|
||||
|
||||
Public Shared Function GenerateCode() As String
|
||||
Dim dummy As Integer = 0
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue