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
|
2017-01-12 06:58:35 +01:00
|
|
|
import state
|
2012-11-19 20:45:05 +01:00
|
|
|
|
|
|
|
def createDefaultKnownNodes(appdata):
|
|
|
|
############## Stream 1 ################
|
|
|
|
stream1 = {}
|
2013-06-18 18:37:13 +02:00
|
|
|
|
2017-01-12 06:58:35 +01:00
|
|
|
#stream1[state.Peer('2604:2000:1380:9f:82e:148b:2746:d0c7', 8080)] = int(time.time())
|
2017-07-05 09:17:01 +02:00
|
|
|
stream1[state.Peer('5.45.99.75', 8444)] = {"lastseen": int(time.time()), "rating": 0, "self": False}
|
|
|
|
stream1[state.Peer('75.167.159.54', 8444)] = {"lastseen": int(time.time()), "rating": 0, "self": False}
|
|
|
|
stream1[state.Peer('95.165.168.168', 8444)] = {"lastseen": int(time.time()), "rating": 0, "self": False}
|
|
|
|
stream1[state.Peer('85.180.139.241', 8444)] = {"lastseen": int(time.time()), "rating": 0, "self": False}
|
|
|
|
stream1[state.Peer('158.222.217.190', 8080)] = {"lastseen": int(time.time()), "rating": 0, "self": False}
|
|
|
|
stream1[state.Peer('178.62.12.187', 8448)] = {"lastseen": int(time.time()), "rating": 0, "self": False}
|
|
|
|
stream1[state.Peer('24.188.198.204', 8111)] = {"lastseen": int(time.time()), "rating": 0, "self": False}
|
|
|
|
stream1[state.Peer('109.147.204.113', 1195)] = {"lastseen": int(time.time()), "rating": 0, "self": False}
|
|
|
|
stream1[state.Peer('178.11.46.221', 8444)] = {"lastseen": int(time.time()), "rating": 0, "self": False}
|
2014-04-30 21:39:25 +02:00
|
|
|
|
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
|
|
|
|
|
2013-08-09 18:12:57 +02:00
|
|
|
with open(appdata + 'knownnodes.dat', 'wb') as output:
|
2013-08-08 09:52:47 +02:00
|
|
|
# Pickle dictionary using protocol 0.
|
|
|
|
pickle.dump(allKnownNodes, output)
|
2012-11-19 20:45:05 +01:00
|
|
|
|
|
|
|
return allKnownNodes
|
|
|
|
|
|
|
|
def readDefaultKnownNodes(appdata):
|
|
|
|
pickleFile = open(appdata + 'knownnodes.dat', 'rb')
|
|
|
|
knownNodes = pickle.load(pickleFile)
|
|
|
|
pickleFile.close()
|
|
|
|
for stream, storedValue in knownNodes.items():
|
|
|
|
for host,value in storedValue.items():
|
2013-08-01 12:31:40 +02:00
|
|
|
try:
|
|
|
|
# Old knownNodes format.
|
|
|
|
port, storedtime = value
|
|
|
|
except:
|
|
|
|
# New knownNodes format.
|
|
|
|
host, port = host
|
|
|
|
storedtime = value
|
2013-06-18 19:11:30 +02:00
|
|
|
print host, '\t', port, '\t', unicode(strftime('%a, %d %b %Y %I:%M %p',localtime(storedtime)),'utf-8')
|
2012-11-19 20:45:05 +01:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
|
|
APPNAME = "PyBitmessage"
|
|
|
|
from os import path, environ
|
|
|
|
if sys.platform == 'darwin':
|
2013-06-23 21:52:39 +02:00
|
|
|
from AppKit import NSSearchPathForDirectoriesInDomains # @UnresolvedImport
|
2012-11-19 20:45:05 +01:00
|
|
|
# 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 + "/"))
|
|
|
|
|
|
|
|
|
2012-11-23 09:22:56 +01:00
|
|
|
print 'New list of all known nodes:', createDefaultKnownNodes(appdata)
|
2012-11-19 20:45:05 +01:00
|
|
|
readDefaultKnownNodes(appdata)
|
|
|
|
|
|
|
|
|