tox dns update

This commit is contained in:
ingvar1995 2016-07-04 12:45:51 +03:00
parent 5df82c6b3c
commit 326ebc155c
2 changed files with 45 additions and 21 deletions

View File

@ -9,11 +9,12 @@
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)
3. Install PyAudio: ``pip3 install pyaudio``
4. [Download toxygen](https://github.com/xveduk/toxygen/archive/master.zip)
5. Unpack archive
6. Download latest libtox.dll build, download latest libsodium.a build, put it into \src\libs\
7. Run \src\main.py
3. Install PyAudio: ``pip3.4 install pyaudio``
4. Install PySocks: ``pip3.4 install PySocks``
5. [Download toxygen](https://github.com/xveduk/toxygen/archive/master.zip)
6. Unpack archive
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)
@ -30,19 +31,15 @@ Dependencies:
1. Install latest Python3.4:
``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/)
4. Install PyAudio:
```bash
sudo apt-get install portaudio19-dev
sudo apt-get install python3-pyaudio
```
Toxygen:
1. [Download toxygen](https://github.com/xveduk/toxygen/archive/master.zip)
2. Unpack archive
3. Run app:
``python3 main.py``
``sudo apt-get install portaudio19-dev`` and ``sudo apt-get install python3-pyaudio``
5. Install PySocks: ``pip3.4 install PySocks``
6. [Download toxygen](https://github.com/xveduk/toxygen/archive/master.zip)
7. Unpack archive
8. Run app:
``python3.4 main.py``
## Compile Toxygen
Check [compile.md](/docs/compile.md) for more info

View File

@ -1,6 +1,7 @@
import json
import urllib.request
from util import log
import settings
def tox_dns(email):
@ -11,16 +12,42 @@ def tox_dns(email):
"""
site = email.split('@')[1]
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)
except Exception as ex: # try http
return send_request(url, data, proxy)
except Exception as ex:
log('TOX DNS ERROR: ' + str(ex))
else: # SOCKS5 proxy
try:
import socks
import socket
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
def send_request(url, data):
def send_request(url, data, proxy):
req = urllib.request.Request(url)
if proxy is not None:
req.set_proxy(proxy, 'http')
req.add_header('Content-Type', 'application/json')
response = urllib.request.urlopen(req, bytes(json.dumps(data), 'utf-8'))
res = json.loads(str(response.read(), 'utf-8'))