Master-Slave LDAP server switching when one fails

You can share your Lua Scripts with everybody here.

Master-Slave LDAP server switching when one fails

Postby FTP » Fri Oct 14, 2016 2:12 pm

-- Description: Master-Slave LDAP server switching when one fails
-- You should add the below scripts into "Event Manager -> FTP/SSH/HTTP -> OnExceedUSERPASS"
-- And you should also enable anti-hammer feature under "Domain > Settings > General Settings > Password & Security > Enable Anti-hammer"
-- Author: Luke
-- Date: 2016-10-14


Code: Select all
require("socket.socket")

local MasterServer = "192.168.1.11"
local SlaveServer = "192.168.1.22"
local domain = "%Domain"
local ip = "%IP"

c_DelTempBlockIp(domain, ip)

if c_GetOptionInt(domain, DOPTION_ENABLE_LDAP_INT) == 1 then

   local ldapServer = c_GetOptionStr(domain, DOPTION_LDAP_HOST_STR)
   local ldapPort = c_GetOptionInt(domain, DOPTION_LDAP_PORT_INT)

   local socket = connect(ldapServer, ldapPort)
   if socket == nil then
      if ldapServer == MasterServer then
         c_SetOptionStr(domain, DOPTION_LDAP_HOST_STR, SlaveServer)
      else
         c_SetOptionStr(domain, DOPTION_LDAP_HOST_STR, MasterServer)
      end
   end

end



Image
Image


The above scripts use a modified version of luasocket library, you can download and unzip it into the working directory of Wing FTP Server. The download URL: https://www.wftpserver.com/bbsres/socket.zip
FTP
Site Admin
 
1852
 
Tue Sep 29, 2009 6:09 am

Return to Lua scripts

Who is online

Users browsing this forum: No registered users and 4 guests