Fixes
This commit is contained in:
parent
9144fa536f
commit
0b4eda648e
@ -1979,7 +1979,7 @@ class Tox:
|
|||||||
raise ToxError("group_disconnect {error.value}")
|
raise ToxError("group_disconnect {error.value}")
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def group_leave(self, group_number, message=''):
|
def group_leave(self, group_number, message=None):
|
||||||
"""Leaves a group.
|
"""Leaves a group.
|
||||||
|
|
||||||
This function sends a parting packet containing a custom
|
This function sends a parting packet containing a custom
|
||||||
@ -2000,7 +2000,7 @@ class Tox:
|
|||||||
f = Tox.libtoxcore.tox_group_leave
|
f = Tox.libtoxcore.tox_group_leave
|
||||||
f.restype = c_bool
|
f.restype = c_bool
|
||||||
result = f(self._tox_pointer, group_number, message,
|
result = f(self._tox_pointer, group_number, message,
|
||||||
len(message) if message is not None else 0, byref(error))
|
len(message) if message else 0, byref(error))
|
||||||
if error.value:
|
if error.value:
|
||||||
LOG_ERROR(f"group_leave {error.value}")
|
LOG_ERROR(f"group_leave {error.value}")
|
||||||
raise ToxError("group_leave {error.value}")
|
raise ToxError("group_leave {error.value}")
|
||||||
@ -2414,7 +2414,7 @@ class Tox:
|
|||||||
if error.value == 1:
|
if error.value == 1:
|
||||||
LOG_ERROR(f"tox_group_get_chat_id ERROR GROUP_STATE_QUERIES_GROUP_NOT_FOUND group_number={group_number}")
|
LOG_ERROR(f"tox_group_get_chat_id ERROR GROUP_STATE_QUERIES_GROUP_NOT_FOUND group_number={group_number}")
|
||||||
else:
|
else:
|
||||||
LOG_ERROR(f"tox_group_get_chat_id group_number={group_number} {error.value}")
|
LOG_ERROR(f"tox_group_get_chat_id group_number={group_number} error={error.value}")
|
||||||
raise ToxError(f"tox_group_get_chat_id {error.value}")
|
raise ToxError(f"tox_group_get_chat_id {error.value}")
|
||||||
#
|
#
|
||||||
# QObject::setParent: Cannot set parent, new parent is in a different thread
|
# QObject::setParent: Cannot set parent, new parent is in a different thread
|
||||||
@ -2787,7 +2787,7 @@ class Tox:
|
|||||||
raise ToxError(f"group_invite_friend {error.value} {s}")
|
raise ToxError(f"group_invite_friend {error.value} {s}")
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# API change
|
# API change - this no longer exists
|
||||||
# @staticmethod
|
# @staticmethod
|
||||||
# def group_self_peer_info_new():
|
# def group_self_peer_info_new():
|
||||||
# error = c_int()
|
# error = c_int()
|
||||||
@ -2796,7 +2796,8 @@ class Tox:
|
|||||||
# result = f(byref(error))
|
# result = f(byref(error))
|
||||||
# return result
|
# return result
|
||||||
|
|
||||||
def group_invite_accept(self, invite_data, friend_number, nick, password=None):
|
# status should be dropped
|
||||||
|
def group_invite_accept(self, invite_data, friend_number, nick, status='', password=None):
|
||||||
"""
|
"""
|
||||||
Accept an invite to a group chat that the client previously received from a friend. The invite
|
Accept an invite to a group chat that the client previously received from a friend. The invite
|
||||||
is only valid while the inviter is present in the group.
|
is only valid while the inviter is present in the group.
|
||||||
@ -2814,10 +2815,10 @@ class Tox:
|
|||||||
except:
|
except:
|
||||||
nick = b''
|
nick = b''
|
||||||
try:
|
try:
|
||||||
if password is None: password = b''
|
if password is not None:
|
||||||
password = bytes(password, 'utf-8')
|
password = bytes(password, 'utf-8')
|
||||||
except:
|
except:
|
||||||
password = b''
|
password = None
|
||||||
invite_data = invite_data or b''
|
invite_data = invite_data or b''
|
||||||
|
|
||||||
if False: # API change
|
if False: # API change
|
||||||
@ -2836,7 +2837,7 @@ class Tox:
|
|||||||
byref(error))
|
byref(error))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG_ERROR(f"group_invite_accept ERROR {e}")
|
LOG_ERROR(f"group_invite_accept ERROR {e}")
|
||||||
raise
|
raise ToxError(f"group_invite_accept ERROR {e}")
|
||||||
if error.value:
|
if error.value:
|
||||||
# The invite data is not in the expected format.
|
# The invite data is not in the expected format.
|
||||||
LOG_ERROR(f"group_invite_accept {TOX_ERR_GROUP_INVITE_ACCEPT[error.value]}")
|
LOG_ERROR(f"group_invite_accept {TOX_ERR_GROUP_INVITE_ACCEPT[error.value]}")
|
||||||
|
@ -262,7 +262,7 @@ class ToxAV:
|
|||||||
24000, or 48000.
|
24000, or 48000.
|
||||||
"""
|
"""
|
||||||
toxav_err_send_frame = c_int()
|
toxav_err_send_frame = c_int()
|
||||||
LOG_DEBUG(f"toxav_audio_send_frame")
|
LOG_TRACE(f"toxav_audio_send_frame")
|
||||||
assert sampling_rate in [8000, 12000, 16000, 24000, 48000]
|
assert sampling_rate in [8000, 12000, 16000, 24000, 48000]
|
||||||
result = self.libtoxav.toxav_audio_send_frame(self._toxav_pointer,
|
result = self.libtoxav.toxav_audio_send_frame(self._toxav_pointer,
|
||||||
c_uint32(friend_number),
|
c_uint32(friend_number),
|
||||||
@ -305,7 +305,7 @@ class ToxAV:
|
|||||||
:param v: V (Chroma) plane data.
|
:param v: V (Chroma) plane data.
|
||||||
"""
|
"""
|
||||||
toxav_err_send_frame = c_int()
|
toxav_err_send_frame = c_int()
|
||||||
LOG_DEBUG(f"toxav_video_send_frame")
|
LOG_TRACE(f"toxav_video_send_frame")
|
||||||
result = self.libtoxav.toxav_video_send_frame(self._toxav_pointer, c_uint32(friend_number), c_uint16(width),
|
result = self.libtoxav.toxav_video_send_frame(self._toxav_pointer, c_uint32(friend_number), c_uint16(width),
|
||||||
c_uint16(height), c_char_p(y), c_char_p(u), c_char_p(v),
|
c_uint16(height), c_char_p(y), c_char_p(u), c_char_p(v),
|
||||||
byref(toxav_err_send_frame))
|
byref(toxav_err_send_frame))
|
||||||
|
@ -27,6 +27,10 @@ try:
|
|||||||
import stem
|
import stem
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
stem = False
|
stem = False
|
||||||
|
try:
|
||||||
|
import nmap
|
||||||
|
except ImportError as e:
|
||||||
|
nmap = False
|
||||||
|
|
||||||
import wrapper
|
import wrapper
|
||||||
from wrapper.toxcore_enums_and_consts import TOX_CONNECTION, TOX_USER_STATUS
|
from wrapper.toxcore_enums_and_consts import TOX_CONNECTION, TOX_USER_STATUS
|
||||||
@ -774,9 +778,8 @@ def bootstrap_good(lelts, lToxes):
|
|||||||
return bootstrap_udp(lelts, lToxes)
|
return bootstrap_udp(lelts, lToxes)
|
||||||
|
|
||||||
def bootstrap_udp(lelts, lToxes):
|
def bootstrap_udp(lelts, lToxes):
|
||||||
|
LOG.debug(f'DHT bootstraping {len(lelts)}')
|
||||||
for elt in lToxes:
|
for elt in lToxes:
|
||||||
LOG.debug(f'DHT bootstraping {len(lelts)}')
|
|
||||||
for largs in sDNSClean(lelts):
|
for largs in sDNSClean(lelts):
|
||||||
host, port, key = largs
|
host, port, key = largs
|
||||||
if host in lDEAD_BS: continue
|
if host in lDEAD_BS: continue
|
||||||
@ -839,38 +842,52 @@ def bootstrap_tcp(lelts, lToxes):
|
|||||||
LOG.debug(f'bootstrap_tcp to {host} but not connected')
|
LOG.debug(f'bootstrap_tcp to {host} but not connected')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def iNmapInfoNmap(sProt, sHost, sPort, key=None, environ=None, cmd=''):
|
||||||
|
if sHost in ['-', 'NONE']: return 0
|
||||||
|
if not nmap: return 0
|
||||||
|
nmps = nmap.PortScanner
|
||||||
|
if sProt in ['socks', 'socks5', 'tcp4']:
|
||||||
|
prot = 'tcp'
|
||||||
|
cmd = f" -Pn -n -sT -p T:{sPort}"
|
||||||
|
else:
|
||||||
|
prot = 'udp'
|
||||||
|
cmd = f" -Pn -n -sU -p U:{sPort}"
|
||||||
|
LOG.debug(f"iNmapInfoNmap cmd={cmd}")
|
||||||
|
sys.stdout.flush()
|
||||||
|
o = nmps().scan(hosts=sHost, arguments=cmd)
|
||||||
|
aScan = o['scan']
|
||||||
|
ip = list(aScan.keys())[0]
|
||||||
|
state = aScam[ip][prot][iPort]['state']
|
||||||
|
LOG.info(f"iNmapInfoNmap: to {sHost} {state}")
|
||||||
|
return 0
|
||||||
|
|
||||||
def iNmapInfo(sProt, sHost, sPort, key=None, environ=None, cmd='nmap'):
|
def iNmapInfo(sProt, sHost, sPort, key=None, environ=None, cmd='nmap'):
|
||||||
if sHost in ['-', 'NONE']: return 0
|
if sHost in ['-', 'NONE']: return 0
|
||||||
|
|
||||||
sFile = os.path.join("/tmp", f"{sHost}.{os.getpid()}.nmap")
|
sFile = os.path.join("/tmp", f"{sHost}.{os.getpid()}.nmap")
|
||||||
if sProt in ['socks', 'socks5', 'tcp4']:
|
if sProt in ['socks', 'socks5', 'tcp4']:
|
||||||
cmd += f" -Pn -n -sT -p T:{sPort} {sHost} | grep /tcp >{sFile}"
|
cmd += f" -Pn -n -sT -p T:{sPort} {sHost} | grep /tcp "
|
||||||
else:
|
else:
|
||||||
cmd += f" -Pn -n -sU -p U:{sPort} {sHost} | grep /tcp >{sFile}"
|
cmd += f" -Pn -n -sU -p U:{sPort} {sHost} | grep /udp "
|
||||||
iRet = os.system('sudo ' +cmd)
|
LOG.debug(f"iNmapInfo cmd={cmd}")
|
||||||
LOG.debug(f"iNmapInfo cmd={cmd} {iRet}")
|
sys.stdout.flush()
|
||||||
|
iRet = os.system('sudo ' +cmd +f" >{sFile} 2>&1 ")
|
||||||
|
LOG.debug(f"iNmapInfo cmd={cmd} iRet={iRet}")
|
||||||
if iRet != 0:
|
if iRet != 0:
|
||||||
return iRet
|
return iRet
|
||||||
assert os.path.exists(sFile), sFile
|
assert os.path.exists(sFile), sFile
|
||||||
with open(sFile, 'rt') as oFd:
|
with open(sFile, 'rt') as oFd:
|
||||||
l = oFd.readlines()
|
l = oFd.readlines()
|
||||||
assert len(l)
|
assert len(l)
|
||||||
|
l = [line for line in l if line and not line.startswith('WARNING:')]
|
||||||
s = '\n'.join([s.strip() for s in l])
|
s = '\n'.join([s.strip() for s in l])
|
||||||
LOG.debug(f"iNmapInfo: {s}")
|
LOG.info(f"iNmapInfo: to {sHost}\n{s}")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def bootstrap_iNmapInfo(lElts, oArgs, bIS_LOCAL=False, iNODES=iNODES, cmd='nmap'):
|
def bootstrap_iNmapInfo(lElts, oArgs, protocol="tcp4", bIS_LOCAL=False, iNODES=iNODES, cmd='nmap'):
|
||||||
if not bIS_LOCAL and not bAreWeConnected():
|
if not bIS_LOCAL and not bAreWeConnected():
|
||||||
LOG.warn(f"bootstrap_iNmapInfo not local and NOT CONNECTED")
|
LOG.warn(f"bootstrap_iNmapInfo not local and NOT CONNECTED")
|
||||||
return True
|
return True
|
||||||
env = dict()
|
|
||||||
if oArgs.proxy_type == 2:
|
|
||||||
protocol='socks'
|
|
||||||
elif oArgs.proxy_type == 1:
|
|
||||||
protocol='https'
|
|
||||||
else:
|
|
||||||
protocol='ipv4'
|
|
||||||
env = os.environ
|
|
||||||
lRetval = []
|
lRetval = []
|
||||||
for elts in lElts[:iNODES]:
|
for elts in lElts[:iNODES]:
|
||||||
host, port, key = elts
|
host, port, key = elts
|
||||||
@ -878,26 +895,23 @@ def bootstrap_iNmapInfo(lElts, oArgs, bIS_LOCAL=False, iNODES=iNODES, cmd='nmap'
|
|||||||
if not ip:
|
if not ip:
|
||||||
LOG.info('bootstrap_iNmapInfo to {host} did not resolve')
|
LOG.info('bootstrap_iNmapInfo to {host} did not resolve')
|
||||||
continue
|
continue
|
||||||
assert len(key) == 64, key
|
|
||||||
if type(port) == str:
|
if type(port) == str:
|
||||||
port = int(port)
|
port = int(port)
|
||||||
iRet = -1
|
iRet = -1
|
||||||
try:
|
try:
|
||||||
iRet = iNmapInfo(protocol, ip, port, key, cmd=cmd)
|
if not nmap:
|
||||||
|
iRet = iNmapInfo(protocol, ip, port, key, cmd=cmd)
|
||||||
|
else:
|
||||||
|
iRet = iNmapInfoNmap(protocol, ip, port, key)
|
||||||
if iRet != 0:
|
if iRet != 0:
|
||||||
LOG.warn('iNmapInfo to ' +repr(host) +' retval=' +str(iRet))
|
LOG.warn('iNmapInfo to ' +repr(host) +' retval=' +str(iRet))
|
||||||
lRetval += [False]
|
lRetval += [False]
|
||||||
else:
|
else:
|
||||||
LOG.info(f'bootstrap_iNmapInfo '
|
LOG.debug('iNmapInfo to ' +repr(host) +' retval=' +str(iRet))
|
||||||
+f" net={oArgs.network}"
|
|
||||||
+f" prot={protocol}"
|
|
||||||
+f" proxy={oArgs.proxy_type}"
|
|
||||||
+f' {elts[:2]!r}'
|
|
||||||
)
|
|
||||||
lRetval += [True]
|
lRetval += [True]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.error('iNmapInfo to {host} : ' +str(e) \
|
LOG.exception('iNmapInfo to {host} : ' +str(e)
|
||||||
+'\n' + traceback.format_exc())
|
)
|
||||||
lRetval += [False]
|
lRetval += [False]
|
||||||
return any(lRetval)
|
return any(lRetval)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user