try:
# mssql.batch("DECLARE @ip varchar(15); SET @ip=TRIM(CONVERT(char(15), CONNECTIONPROPERTY('client_net_address')));"
# "EXEC msdb.dbo.%s '%s', @ip, %d" % (PROCEDURE_NAME, args.reciclador, lport), tuplemode=False, wait=False)
mssql.batch("DECLARE @ip varchar(15); SET @ip=RTRIM(LTRIM(CONVERT(char(15), CONNECTIONPROPERTY('client_net_address'))))"
"EXEC msdb.dbo.%s '%s', @ip, %d" % (PROCEDURE_NAME, args.reciclador, lport), tuplemode=False, wait=False)
data = mssql.socket.recv(2048)
if 'Powered by blackarrow.net' in data:
logging.info("ACK from server!")
mssql.socket.sendall("ACK")
else:
logging.error("cannot establish connection")
raise Exception('cannot establish connection')
s.listen(10)
while True:
client, c = s.accept()
thread.start_new_thread(proxy_worker, (mssql.socket, client))