Skip to content

Commit

Permalink
found the problem, yiehah
Browse files Browse the repository at this point in the history
  • Loading branch information
altsheets committed Jan 24, 2016
1 parent 3fde5ad commit 58a4e24
Showing 1 changed file with 65 additions and 5 deletions.
70 changes: 65 additions & 5 deletions tools/test7774.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@

"""
attempt to contact the peerServer port 7774 on HZ
Tying to find out how to contact the peerServer port 7774 on HZ
the example from MaWo's script https://bitcointalk.org/index.php?topic=823785.msg13656332#msg13656332 is:
The example from MaWo's script https://bitcointalk.org/index.php?topic=823785.msg13656332#msg13656332 is:
curl -4 -m5 --data '{"platform":"TEST","protocol":1,"application":"TEST Bot","requestType":"getInfo","version":"v0.1"}' "http://woll-e.net:7774/nhz"
But I just cannot get it working, however I try. Always the same answer:
At first, I just could not get it working, however I tried. Always the same answer:
http://woll-e.net:7774/nhz
test 1:
{"cause":"Unexpected character (r) at position 0.","error":"Your peer is blacklisted"}
test 2:
{"cause":"Unexpected character (r) at position 0.","error":"Your peer is blacklisted"}
Please help. Thanks.
Then I had the idea to send both requests (curl, python.requests) to requestb.in, to compare them.
And that helped!
The 'header' has to be set to 'application/x-www-form-urlencoded',
for the 7774 peerserver to accept the data. *sigh*, I made it ...
"""

import urllib2
import urllib2, urllib, urlparse

try: import requests
except: print "pip install requests"

PORT=7774

Expand Down Expand Up @@ -48,9 +56,61 @@ def test2():
r=requests.post(URL, data=data)
print r.text

import json

def test3():
"""
Trying to find out what is wrong
by comparing curl with python.requests.post
in requestb.in
"""


print """
test against this manual curl:
curl -d '{"protocol":1,"requestType":"getInfo"}' "http://requestb.in/11c8di01"
"""

url="http://requestb.in/11c8di01" # http://requestb.in/11c8di01?inspect

data={"protocol":1,"requestType":"getInfo"}
data=json.dumps(data)

# THIS WAS THE THING TO DO *sigh*:
headers = {'content-type': 'application/x-www-form-urlencoded'}

r=requests.post(url, data=data, headers=headers)
print r.status_code, r.text
print "now lookup %s_inspect to see the results.\n\n" % url

def test4():
nodes=[u'5.9.149.197', u'5.196.143.14', u'23.95.44.142', u'23.245.7.15', u'31.24.29.221', u'37.120.160.148', u'37.120.173.114', u'40.115.9.5', u'40.115.9.55', u'45.55.81.226', u'45.55.157.54', u'52.24.16.77', u'52.24.85.12', u'52.24.187.95', u'52.26.95.4']

data={"protocol":1,"requestType":"getInfo"}
data=json.dumps(data)
headers = {'content-type': 'application/x-www-form-urlencoded'}

for n in nodes:
url="http://%s:%s/nhz" % (n, PORT)
print "%15s" % n,
try:
r=requests.post(url, data=data, headers=headers, timeout=1)
except:
print
continue

print r.status_code,
j = r.json()
for k in ("version", "announcedAddress", "platform"):
print "%15s" % j.get(k, ""),
print


if __name__=="__main__":
print URL
test1()
test2()
test3()
test4()


0 comments on commit 58a4e24

Please sign in to comment.