work on new communicator, with nist beacon
This commit is contained in:
parent
7d3e7e7a30
commit
d73b69c9b4
@ -19,13 +19,33 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
'''
|
||||
import core, config, onionrblockapi as block
|
||||
class OnionrDaemon:
|
||||
import core, config, onionrblockapi as block, requests, xml
|
||||
class OnionrCommunicatorDaemon:
|
||||
def __init__(self, debug, developmentMode):
|
||||
self.timers = [] # list of tuples, function, time in seconds
|
||||
self.nodeInfo
|
||||
self._core = core.Core()
|
||||
|
||||
self.nistSalt = 0
|
||||
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
|
||||
debug = True
|
||||
developmentMode = False
|
||||
@ -38,7 +58,7 @@ except IndexError:
|
||||
pass
|
||||
if shouldRun:
|
||||
try:
|
||||
OnionrCommunicate(debug, developmentMode)
|
||||
OnionrCommunicatorDaemon(debug, developmentMode)
|
||||
except KeyboardInterrupt:
|
||||
sys.exit(1)
|
||||
pass
|
||||
|
@ -78,6 +78,13 @@ class OnionrUtils:
|
||||
|
||||
return
|
||||
|
||||
def getCurrentHourEpoch(self):
|
||||
'''
|
||||
Returns the current epoch, rounded down to the hour
|
||||
'''
|
||||
epoch = self.getEpoch()
|
||||
return epoch - (epoch % 3600)
|
||||
|
||||
def incrementAddressSuccess(self, address):
|
||||
'''
|
||||
Increase the recorded sucesses for an address
|
||||
|
Loading…
Reference in New Issue
Block a user