PyBitmessage-2021-04-27/src/defaultKnownNodes.py

77 lines
2.4 KiB
Python
Raw Normal View History

2012-11-19 20:45:05 +01:00
import pickle
import socket
from struct import *
import time
import random
import sys
from time import strftime, localtime
def createDefaultKnownNodes(appdata):
############## Stream 1 ################
stream1 = {}
2013-05-20 21:58:45 +02:00
stream1['109.91.57.2'] = (8443,int(time.time()))
2013-02-26 23:20:43 +01:00
stream1['66.65.120.151'] = (8080,int(time.time()))
2013-05-20 21:58:45 +02:00
stream1['188.18.69.115'] = (8443,int(time.time()))
stream1['204.236.246.212'] = (8444,int(time.time()))
stream1['85.177.81.73'] = (8444,int(time.time()))
stream1['78.81.56.239'] = (8444,int(time.time()))
stream1['204.236.246.212'] = (8444,int(time.time()))
2012-11-19 20:45:05 +01:00
############# Stream 2 #################
stream2 = {}
# None yet
############# Stream 3 #################
stream3 = {}
# None yet
allKnownNodes = {}
allKnownNodes[1] = stream1
allKnownNodes[2] = stream2
allKnownNodes[3] = stream3
#print stream1
#print allKnownNodes
output = open(appdata + 'knownnodes.dat', 'wb')
# Pickle dictionary using protocol 0.
pickle.dump(allKnownNodes, output)
output.close()
return allKnownNodes
def readDefaultKnownNodes(appdata):
pickleFile = open(appdata + 'knownnodes.dat', 'rb')
knownNodes = pickle.load(pickleFile)
pickleFile.close()
knownNodes
for stream, storedValue in knownNodes.items():
for host,value in storedValue.items():
port, storedtime = storedValue[host]
2013-03-27 09:31:03 +01:00
print host, '\t', port, '\t', unicode(strftime('%a, %d %b %Y %I:%M %p',localtime(storedtime)))
2012-11-19 20:45:05 +01:00
if __name__ == "__main__":
APPNAME = "PyBitmessage"
from os import path, environ
if sys.platform == 'darwin':
from AppKit import NSSearchPathForDirectoriesInDomains
# http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html#//apple_ref/c/func/NSSearchPathForDirectoriesInDomains
# NSApplicationSupportDirectory = 14
# NSUserDomainMask = 1
# True for expanding the tilde into a fully qualified path
appdata = path.join(NSSearchPathForDirectoriesInDomains(14, 1, True)[0], APPNAME) + '/'
elif 'win' in sys.platform:
appdata = path.join(environ['APPDATA'], APPNAME) + '\\'
else:
appdata = path.expanduser(path.join("~", "." + APPNAME + "/"))
print 'New list of all known nodes:', createDefaultKnownNodes(appdata)
2012-11-19 20:45:05 +01:00
readDefaultKnownNodes(appdata)