I run a server for a project of mine. The clients invoke an Update check function running as a webservice at start-up. These requests are logged to file.
I use the following function to log to file:
Public Sub Log(ByVal Message As String, ByVal Level As LogEntryLevel, ByVal Additional As Boolean)
Dim base As String = "C:\SERVER\log\"
Dim fileName As String = Date.Now.ToString("dd-MM-yyyy") & ".log"
Dim newString As String = ""
If Not Additional Then
If System.IO.File.Exists(base + fileName) Then newString &= vbNewLine
newString &= Date.Now.ToString("[dd/MM/yyyy HH:mm:ss.fff ") & Level.ToString & "] " & Message
Else
newString &= Message
End If
My.Computer.FileSystem.WriteAllText(base + fileName, newString, True)
End Sub
I use the following function to get the clients IP-address:
Public Function getIP() As String
Dim ip As String
ip = Context.Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If ip = String.Empty Then
ip = Context.Request.ServerVariables("REMOTE_ADDR")
End If
Return ip
End Function
The log message is constructed as follows:
Log(String.Format("Client {0} invoked CheckForUpdate with [{1}]", getIP, ver), LogEntryLevel.INFO, False)
Some time ago this got logged:
[11-12-2011 22:10:20.730 INFO] Client 10.0.1.4, 127.0.0.1 invoked CheckForUpdate with [0.5]
O_O How can this be returned? Is this normal? Is this possible? How can the request have originated from localhost (127.0.0.1) and at the same time from a remote IP-address? Was the server hacked? Is this a glitch? Can someone please explain this to me?
- This was posted some time ago on XtremeVBTalk.com: http://www.xtremevbtalk.com/showthread.php?t=322915 but no one answered, so I am asking it here again.