work on new communicator, with nist beacon
This commit is contained in:
parent
7d3e7e7a30
commit
d73b69c9b4
@ -19,12 +19,32 @@
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
'''
|
'''
|
||||||
import core, config, onionrblockapi as block
|
import core, config, onionrblockapi as block, requests, xml
|
||||||
class OnionrDaemon:
|
class OnionrCommunicatorDaemon:
|
||||||
def __init__(self, debug, developmentMode):
|
def __init__(self, debug, developmentMode):
|
||||||
self.timers = [] # list of tuples, function, time in seconds
|
self.timers = [] # list of tuples, function, time in seconds
|
||||||
self.nodeInfo
|
self._core = core.Core()
|
||||||
|
|
||||||
|
self.nistSalt = 0
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def getNistTimeStamp(self):
|
||||||
|
curTime = self._core._utils.getCurrentHourEpoch
|
||||||
|
data = doGetRequest('https://beacon.nist.gov/rest/record/' + str(curTime))
|
||||||
|
|
||||||
|
|
||||||
|
def doGetRequest(self, url, port=sys.argv[2], proxyType='tor'):
|
||||||
|
'''
|
||||||
|
Do a get request through a local tor or i2p instance
|
||||||
|
'''
|
||||||
|
if proxyType == 'tor':
|
||||||
|
proxies = {'http': 'socks5://127.0.0.1:' + str(port), 'https': 'socks5://127.0.0.1:' + str(port)}
|
||||||
|
elif proxyType == 'i2p':
|
||||||
|
proxies = {'http': 'http://127.0.0.1:4444'}
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
headers = {'user-agent': 'PyOnionr'}
|
||||||
|
r = requests.get(url, headers=headers, proxies=proxies, allow_redirects=False, timeout=(15, 30))
|
||||||
|
|
||||||
shouldRun = False
|
shouldRun = False
|
||||||
debug = True
|
debug = True
|
||||||
@ -38,7 +58,7 @@ except IndexError:
|
|||||||
pass
|
pass
|
||||||
if shouldRun:
|
if shouldRun:
|
||||||
try:
|
try:
|
||||||
OnionrCommunicate(debug, developmentMode)
|
OnionrCommunicatorDaemon(debug, developmentMode)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
pass
|
pass
|
||||||
|
@ -78,6 +78,13 @@ class OnionrUtils:
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def getCurrentHourEpoch(self):
|
||||||
|
'''
|
||||||
|
Returns the current epoch, rounded down to the hour
|
||||||
|
'''
|
||||||
|
epoch = self.getEpoch()
|
||||||
|
return epoch - (epoch % 3600)
|
||||||
|
|
||||||
def incrementAddressSuccess(self, address):
|
def incrementAddressSuccess(self, address):
|
||||||
'''
|
'''
|
||||||
Increase the recorded sucesses for an address
|
Increase the recorded sucesses for an address
|
||||||
|
Loading…
Reference in New Issue
Block a user