Switch to full style
Use this forum to post questions relating to WinGate, feature requests, technical or configuration problems
Post a reply

NAT Policy - how to log disconnected server ip

Oct 11 13 3:31 am

Hi Qbik Wingate Team

I doing test on wingate trial at my test server.
I enable NAT Policy (add new policy -> any nat controller -> client connect)
so I add some {{Session.ServerPort}} & {{Session.ServerIp}} to whitelist, if server port & ip not in the list, it will be disconnected.

so what can i do to log all disconnected connection (log all disconnected {{Session.ServerPort}} & {{Session.ServerIp}} ) ?

thanks :)

Re: NAT Policy - how to log disconnected server ip

Oct 29 13 3:32 pm

Hi

When the connection is terminated, the session logs a termination reason of "terminated in event handler". These are logged only at debug level though.

Alternatively you can use the Lua Script policy item to open a file, write to it and then close it.

Or a SQL policy item to insert a record into a database. In fact this may be easiest.

Regards

Adrien

Re: NAT Policy - how to log disconnected server ip

Oct 29 13 8:37 pm

thanks Adrien.

I'm not so good in programming, so I had try several Lua script test, but failed to successfully get what i want.

this is example what i had do.

this line already there when i drag Lua script from policy toolbox :
Code:
--return true or false depending on whether you wish the
--'Yes' or 'No' path to be taken
function filter(User, Session, Event)
   return true;
end


so below that line i add this line :
Code:
local file = io.open("NATlog.txt", "a")
file:write("Session.ServerIP")
file:close()


when i open the log file, it's succesfully read & write, but it don't write a server ip address, it only show the text "Session.ServerIP", not the server ip address that disconnected by policy.

maybe somebody can show me the correct programming code.
thanks for reading n helping :)

Re: NAT Policy - how to log disconnected server ip

Oct 29 13 10:42 pm

Hi

in script languages, normally anything in quotes is taken literally (actually called a literal). So it prints the text in quotes. If you want to print the value of the variable, take away the quotes, e.g.

Code:
local file = io.open("NATlog.txt", "a")
file:write(Session.ServerIP)
file:close()


If you want to put them each on their own line, you could do something like

Code:
local file = io.open("NATlog.txt", "a")
line = Session.ServerIP.."\n";
file:write(line)
file:close()


Regards

Adrien
Post a reply