Master-Slave LDAP server switching when one fails

You can share your Lua Scripts with everybody here.
Post Reply
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Master-Slave LDAP server switching when one fails

Post by FTP »

-- 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
Post Reply