Fixes
This commit is contained in:
parent
9144fa536f
commit
0b4eda648e
@ -1979,7 +1979,7 @@ class Tox:
|
||||
raise ToxError("group_disconnect {error.value}")
|
||||
return result
|
||||
|
||||
def group_leave(self, group_number, message=''):
|
||||
def group_leave(self, group_number, message=None):
|
||||
"""Leaves a group.
|
||||
|
||||
This function sends a parting packet containing a custom
|
||||
@ -2000,7 +2000,7 @@ class Tox:
|
||||
f = Tox.libtoxcore.tox_group_leave
|
||||
f.restype = c_bool
|
||||
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:
|
||||
LOG_ERROR(f"group_leave {error.value}")
|
||||
raise ToxError("group_leave {error.value}")
|
||||
@ -2414,7 +2414,7 @@ class Tox:
|
||||
if error.value == 1:
|
||||
LOG_ERROR(f"tox_group_get_chat_id ERROR GROUP_STATE_QUERIES_GROUP_NOT_FOUND group_number={group_number}")
|
||||
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}")
|
||||
#
|
||||
# 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}")
|
||||
return result
|
||||
|
||||
# API change
|
||||
# API change - this no longer exists
|
||||
# @staticmethod
|
||||
# def group_self_peer_info_new():
|
||||
# error = c_int()
|
||||
@ -2796,7 +2796,8 @@ class Tox:
|
||||
# result = f(byref(error))
|
||||
# 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
|
||||
is only valid while the inviter is present in the group.
|
||||
@ -2814,10 +2815,10 @@ class Tox:
|
||||
except:
|
||||
nick = b''
|
||||
try:
|
||||
if password is None: password = b''
|
||||
if password is not None:
|
||||
password = bytes(password, 'utf-8')
|
||||
except:
|
||||
password = b''
|
||||
password = None
|
||||
invite_data = invite_data or b''
|
||||
|
||||
if False: # API change
|
||||
@ -2836,7 +2837,7 @@ class Tox:
|
||||
byref(error))
|
||||
except Exception as e:
|
||||
LOG_ERROR(f"group_invite_accept ERROR {e}")
|
||||
raise
|
||||
raise ToxError(f"group_invite_accept ERROR {e}")
|
||||
if error.value:
|
||||
# The invite data is not in the expected format.
|
||||
LOG_ERROR(f"group_invite_accept {TOX_ERR_GROUP_INVITE_ACCEPT[error.value]}")
|
||||
|
@ -262,7 +262,7 @@ class ToxAV:
|
||||
24000, or 48000.
|
||||
"""
|
||||
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]
|
||||
result = self.libtoxav.toxav_audio_send_frame(self._toxav_pointer,
|
||||
c_uint32(friend_number),
|
||||
@ -305,7 +305,7 @@ class ToxAV:
|
||||
:param v: V (Chroma) plane data.
|
||||
"""
|
||||
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),
|
||||
c_uint16(height), c_char_p(y), c_char_p(u), c_char_p(v),
|
||||
byref(toxav_err_send_frame))
|
||||
|
@ -27,6 +27,10 @@ try:
|
||||
import stem
|
||||
except ImportError as e:
|
||||
stem = False
|
||||
try:
|
||||
import nmap
|
||||
except ImportError as e:
|
||||
nmap = False
|
||||
|
||||
import wrapper
|
||||
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)
|
||||
|
||||
def bootstrap_udp(lelts, lToxes):
|
||||
|
||||
for elt in lToxes:
|
||||
LOG.debug(f'DHT bootstraping {len(lelts)}')
|
||||
for elt in lToxes:
|
||||
for largs in sDNSClean(lelts):
|
||||
host, port, key = largs
|
||||
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')
|
||||
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'):
|
||||
if sHost in ['-', 'NONE']: return 0
|
||||
|
||||
sFile = os.path.join("/tmp", f"{sHost}.{os.getpid()}.nmap")
|
||||
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:
|
||||
cmd += f" -Pn -n -sU -p U:{sPort} {sHost} | grep /tcp >{sFile}"
|
||||
iRet = os.system('sudo ' +cmd)
|
||||
LOG.debug(f"iNmapInfo cmd={cmd} {iRet}")
|
||||
cmd += f" -Pn -n -sU -p U:{sPort} {sHost} | grep /udp "
|
||||
LOG.debug(f"iNmapInfo cmd={cmd}")
|
||||
sys.stdout.flush()
|
||||
iRet = os.system('sudo ' +cmd +f" >{sFile} 2>&1 ")
|
||||
LOG.debug(f"iNmapInfo cmd={cmd} iRet={iRet}")
|
||||
if iRet != 0:
|
||||
return iRet
|
||||
assert os.path.exists(sFile), sFile
|
||||
with open(sFile, 'rt') as oFd:
|
||||
l = oFd.readlines()
|
||||
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])
|
||||
LOG.debug(f"iNmapInfo: {s}")
|
||||
LOG.info(f"iNmapInfo: to {sHost}\n{s}")
|
||||
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():
|
||||
LOG.warn(f"bootstrap_iNmapInfo not local and NOT CONNECTED")
|
||||
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 = []
|
||||
for elts in lElts[:iNODES]:
|
||||
host, port, key = elts
|
||||
@ -878,26 +895,23 @@ def bootstrap_iNmapInfo(lElts, oArgs, bIS_LOCAL=False, iNODES=iNODES, cmd='nmap'
|
||||
if not ip:
|
||||
LOG.info('bootstrap_iNmapInfo to {host} did not resolve')
|
||||
continue
|
||||
assert len(key) == 64, key
|
||||
if type(port) == str:
|
||||
port = int(port)
|
||||
iRet = -1
|
||||
try:
|
||||
if not nmap:
|
||||
iRet = iNmapInfo(protocol, ip, port, key, cmd=cmd)
|
||||
else:
|
||||
iRet = iNmapInfoNmap(protocol, ip, port, key)
|
||||
if iRet != 0:
|
||||
LOG.warn('iNmapInfo to ' +repr(host) +' retval=' +str(iRet))
|
||||
lRetval += [False]
|
||||
else:
|
||||
LOG.info(f'bootstrap_iNmapInfo '
|
||||
+f" net={oArgs.network}"
|
||||
+f" prot={protocol}"
|
||||
+f" proxy={oArgs.proxy_type}"
|
||||
+f' {elts[:2]!r}'
|
||||
)
|
||||
LOG.debug('iNmapInfo to ' +repr(host) +' retval=' +str(iRet))
|
||||
lRetval += [True]
|
||||
except Exception as e:
|
||||
LOG.error('iNmapInfo to {host} : ' +str(e) \
|
||||
+'\n' + traceback.format_exc())
|
||||
LOG.exception('iNmapInfo to {host} : ' +str(e)
|
||||
)
|
||||
lRetval += [False]
|
||||
return any(lRetval)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user