tox dns update
This commit is contained in:
parent
5df82c6b3c
commit
326ebc155c
2 changed files with 45 additions and 21 deletions
|
@ -9,11 +9,12 @@
|
||||||
|
|
||||||
1. [Download and install latest Python 3.4](https://www.python.org/downloads/windows/)
|
1. [Download and install latest Python 3.4](https://www.python.org/downloads/windows/)
|
||||||
2. [Install PySide](https://pypi.python.org/pypi/PySide/1.2.4) (recommended) or [PyQt4](https://riverbankcomputing.com/software/pyqt/download)
|
2. [Install PySide](https://pypi.python.org/pypi/PySide/1.2.4) (recommended) or [PyQt4](https://riverbankcomputing.com/software/pyqt/download)
|
||||||
3. Install PyAudio: ``pip3 install pyaudio``
|
3. Install PyAudio: ``pip3.4 install pyaudio``
|
||||||
4. [Download toxygen](https://github.com/xveduk/toxygen/archive/master.zip)
|
4. Install PySocks: ``pip3.4 install PySocks``
|
||||||
5. Unpack archive
|
5. [Download toxygen](https://github.com/xveduk/toxygen/archive/master.zip)
|
||||||
6. Download latest libtox.dll build, download latest libsodium.a build, put it into \src\libs\
|
6. Unpack archive
|
||||||
7. Run \src\main.py
|
7. Download latest libtox.dll build, download latest libsodium.a build, put it into \src\libs\
|
||||||
|
8. Run \src\main.py
|
||||||
|
|
||||||
[libtox.dll for 32-bit Python](https://build.tox.chat/view/libtoxcore/job/libtoxcore_build_windows_x86_shared_release/lastSuccessfulBuild/artifact/libtoxcore_build_windows_x86_shared_release.zip)
|
[libtox.dll for 32-bit Python](https://build.tox.chat/view/libtoxcore/job/libtoxcore_build_windows_x86_shared_release/lastSuccessfulBuild/artifact/libtoxcore_build_windows_x86_shared_release.zip)
|
||||||
|
|
||||||
|
@ -30,19 +31,15 @@ Dependencies:
|
||||||
|
|
||||||
1. Install latest Python3.4:
|
1. Install latest Python3.4:
|
||||||
``sudo apt-get install python3``
|
``sudo apt-get install python3``
|
||||||
2. [Install PySide](https://wiki.qt.io/PySide_Binaries_Linux) (recommended) or [PyQt4](https://riverbankcomputing.com/software/pyqt/download)
|
2. [Install PySide](https://wiki.qt.io/PySide_Binaries_Linux) (recommended), using terminal - ``sudo apt-get install python3-pyside``, or install [PyQt4](https://riverbankcomputing.com/software/pyqt/download).
|
||||||
3. Install [toxcore](https://github.com/irungentoo/toxcore/blob/master/INSTALL.md) with toxav support in your system (install in /usr/lib/)
|
3. Install [toxcore](https://github.com/irungentoo/toxcore/blob/master/INSTALL.md) with toxav support in your system (install in /usr/lib/)
|
||||||
4. Install PyAudio:
|
4. Install PyAudio:
|
||||||
```bash
|
``sudo apt-get install portaudio19-dev`` and ``sudo apt-get install python3-pyaudio``
|
||||||
sudo apt-get install portaudio19-dev
|
5. Install PySocks: ``pip3.4 install PySocks``
|
||||||
sudo apt-get install python3-pyaudio
|
6. [Download toxygen](https://github.com/xveduk/toxygen/archive/master.zip)
|
||||||
```
|
7. Unpack archive
|
||||||
Toxygen:
|
8. Run app:
|
||||||
|
``python3.4 main.py``
|
||||||
1. [Download toxygen](https://github.com/xveduk/toxygen/archive/master.zip)
|
|
||||||
2. Unpack archive
|
|
||||||
3. Run app:
|
|
||||||
``python3 main.py``
|
|
||||||
|
|
||||||
## Compile Toxygen
|
## Compile Toxygen
|
||||||
Check [compile.md](/docs/compile.md) for more info
|
Check [compile.md](/docs/compile.md) for more info
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import json
|
import json
|
||||||
import urllib.request
|
import urllib.request
|
||||||
from util import log
|
from util import log
|
||||||
|
import settings
|
||||||
|
|
||||||
|
|
||||||
def tox_dns(email):
|
def tox_dns(email):
|
||||||
|
@ -11,16 +12,42 @@ def tox_dns(email):
|
||||||
"""
|
"""
|
||||||
site = email.split('@')[1]
|
site = email.split('@')[1]
|
||||||
data = {"action": 3, "name": "{}".format(email)}
|
data = {"action": 3, "name": "{}".format(email)}
|
||||||
for url in ('https://{}/api'.format(site), 'http://{}/api'.format(site)):
|
urls = ('https://{}/api'.format(site), 'http://{}/api'.format(site))
|
||||||
|
s = settings.Settings.get_instance()
|
||||||
|
if s['proxy_type'] != 2: # no proxy or http proxy
|
||||||
|
proxy = s['proxy_host'] + ':' + s['proxy_port'] if s['proxy_type'] else None
|
||||||
|
for url in urls:
|
||||||
|
try:
|
||||||
|
return send_request(url, data, proxy)
|
||||||
|
except Exception as ex:
|
||||||
|
log('TOX DNS ERROR: ' + str(ex))
|
||||||
|
else: # SOCKS5 proxy
|
||||||
try:
|
try:
|
||||||
return send_request(url, data)
|
import socks
|
||||||
except Exception as ex: # try http
|
import socket
|
||||||
log('TOX DNS ERROR: ' + str(ex))
|
import requests
|
||||||
|
|
||||||
|
socks.set_default_proxy(socks.SOCKS5, s['proxy_host'], s['proxy_port'])
|
||||||
|
socket.socket = socks.socksocket
|
||||||
|
for url in urls:
|
||||||
|
try:
|
||||||
|
r = requests.get(url)
|
||||||
|
res = json.loads(r.text)
|
||||||
|
if not res['c']:
|
||||||
|
return res['tox_id']
|
||||||
|
else:
|
||||||
|
raise LookupError()
|
||||||
|
except Exception as ex:
|
||||||
|
log('TOX DNS ERROR: ' + str(ex))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
return None # error
|
return None # error
|
||||||
|
|
||||||
|
|
||||||
def send_request(url, data):
|
def send_request(url, data, proxy):
|
||||||
req = urllib.request.Request(url)
|
req = urllib.request.Request(url)
|
||||||
|
if proxy is not None:
|
||||||
|
req.set_proxy(proxy, 'http')
|
||||||
req.add_header('Content-Type', 'application/json')
|
req.add_header('Content-Type', 'application/json')
|
||||||
response = urllib.request.urlopen(req, bytes(json.dumps(data), 'utf-8'))
|
response = urllib.request.urlopen(req, bytes(json.dumps(data), 'utf-8'))
|
||||||
res = json.loads(str(response.read(), 'utf-8'))
|
res = json.loads(str(response.read(), 'utf-8'))
|
||||||
|
|
Loading…
Reference in a new issue