playing around with tor

separate_pages
quadrismegistus 4 years ago
parent 8c05e6f9e9
commit fcde2f1e02

@ -0,0 +1,42 @@
from torpy import TorClient
import json,requests
import struct
#hostname = 'ifconfig.me' # It's possible use onion hostname here as well
#port = 80
hostname = '128.232.229.63' #:5555'
port = 5555
#from torpy.http.requests import tor_requests_session
#with tor_requests_session() as s:
from torpy.http.requests import TorRequests
with TorRequests() as tor_requests:
with tor_requests.get_session() as s:
#with requests.Session() as s:
#res = s.get('http://'+hostname+':'+str(port) + '/api/followers/MrY')
#print(json.loads(res.text))
res = s.get('http://'+hostname+':'+str(port))
print(res,res.text)
# tor = TorClient()
# # # Choose random guard node and create 3-hops circuit
# # try:
# # with tor.create_circuit(3) as circuit:
# # # Create tor stream to host
# # with circuit.create_stream((hostname, port)) as stream:
# # # Now we can communicate with host
# # stream.send(b'GET / HTTP/1.0\r\nHost: %s\r\n\r\n' % hostname.encode())
# # recv = stream.recv(1024 * 10)
# # print(recv)
# # except struct.error as e:
# # print('struct error!?',e)

@ -64,8 +64,8 @@ class Group(MyGraphObject):
def test_models():
x = Person(); x.name='Mr X'
y = Person(); y.name='Mr Y'
x = Person(); x.name='MrX'
y = Person(); y.name='MrY'
p1 = Post(); p1.title='Post 1'; p1.content='Hello world!'
p2 = Post(); p2.title='Post 2'; p2.content='Hello world!!!'
p3 = Post(); p3.title='Post 3'; p3.content='Hello world!!!!!!!!!!!!'

@ -5,6 +5,13 @@ from models import *
from flask_api import FlaskAPI, status, exceptions
from werkzeug.security import generate_password_hash,check_password_hash
# works better with tor?
import json
jsonify = json.dumps
jsonify = str
# Start server
app = flask.Flask(__name__)
@ -105,4 +112,4 @@ def get_post(id=None):
app.run(port=5555)
app.run(host='0.0.0.0', port=5555)
Loading…
Cancel
Save