MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / connect

Method connect

pager_lib/smb/SMBConnection.py:100–133  ·  view source on GitHub ↗

Establish the SMB connection to the remote SMB/CIFS server. You must call this method before attempting any of the file operations with the remote server. This method will block until the SMB connection has attempted at least one authentication. :param port: Defaul

(self, ip, port = 139, sock_family = None, timeout = 60)

Source from the content-addressed store, hash-verified

98 #
99
100 def connect(self, ip, port = 139, sock_family = None, timeout = 60):
101 """
102 Establish the SMB connection to the remote SMB/CIFS server.
103
104 You must call this method before attempting any of the file operations with the remote server.
105 This method will block until the SMB connection has attempted at least one authentication.
106
107 :param port: Defaults to 139. If you are using direct TCP mode (is_direct_tcp=true when creating this SMBConnection instance), use 445.
108 :param sock_family: In Python 3.x, use *None* as we can infer the socket family from the provided *ip*. In Python 2.x, it must be either *socket.AF_INET* or *socket.AF_INET6*.
109 :return: A boolean value indicating the result of the authentication atttempt: True if authentication is successful; False, if otherwise.
110 """
111 if self.sock:
112 self.sock.close()
113
114 self.auth_result = None
115 if sock_family:
116 self.sock = socket.socket(sock_family)
117 self.sock.settimeout(timeout)
118 self.sock.connect(( ip, port ))
119 else:
120 self.sock = socket.create_connection(( ip, port ), timeout = timeout)
121
122 self.is_busy = True
123 try:
124 if not self.is_direct_tcp:
125 self.requestNMBSession()
126 else:
127 self.onNMBSessionOK()
128 while self.auth_result is None:
129 self._pollForNetBIOSPacket(timeout)
130 finally:
131 self.is_busy = False
132
133 return self.auth_result
134
135 def close(self):
136 """

Callers 3

connect_smbMethod · 0.95
smb_connectMethod · 0.95
smb_openMethod · 0.95

Calls 4

_pollForNetBIOSPacketMethod · 0.95
requestNMBSessionMethod · 0.80
closeMethod · 0.45
onNMBSessionOKMethod · 0.45

Tested by

no test coverage detected