finalized the tcpconnect service. should be ready for takeoff now.... ;)
This commit is contained in:
parent
cdd3b7f7ac
commit
c35b956677
1 changed files with 8 additions and 4 deletions
|
|
@ -11,7 +11,6 @@ from lib.services.service import Service
|
|||
|
||||
class TcpconnectService(Service):
|
||||
def __init__(self, **kwargs):
|
||||
#Service.__init__(self, **kwargs)
|
||||
super(TcpconnectService, self).__init__(**kwargs)
|
||||
|
||||
args = self.get_arguments()
|
||||
|
|
@ -28,19 +27,24 @@ class TcpconnectService(Service):
|
|||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
except socket.error, msg:
|
||||
jobInfo.set_errorcode(1)
|
||||
jobInfo.set_message("Could not create socket to host: " + jobInfo.get_host() + " to port: " + str(self.port) + " (" + str(msg) + ")")
|
||||
jobInfo.set_message("Could not create socket to host: " + jobInfo.get_host() + " to port: " +
|
||||
str(self.port) + " (" + str(msg) + ")")
|
||||
|
||||
try:
|
||||
sock.connect((jobInfo.get_host(), self.port))
|
||||
except socket.error, msg:
|
||||
jobInfo.set_errorcode(2)
|
||||
jobInfo.set_message("Could not establish connection to host: " + jobInfo.get_host() + " to port: " + str(self.port) + " (" + str(msg) + ")")
|
||||
jobInfo.set_message("Could not establish connection to host: " + jobInfo.get_host() + " to port: " +
|
||||
str(self.port) + " (" + str(msg) + ")")
|
||||
|
||||
if jobInfo.get_errorcode() == -1:
|
||||
jobInfo.set_execution_successful(True)
|
||||
jobInfo.set_errorcode(0)
|
||||
jobInfo.set_message("Connection successful established to host: " + jobInfo.get_host() + " to port: " + str(self.port))
|
||||
jobInfo.set_message("Connection successful established to host: " + jobInfo.get_host() + " to port: " +
|
||||
str(self.port))
|
||||
|
||||
sock.close()
|
||||
|
||||
|
||||
def create(kwargs):
|
||||
return TcpconnectService(**kwargs)
|
||||
Loading…
Add table
Add a link
Reference in a new issue