import pickle
import socket
from struct import *
import time
import random
import sys
from time import strftime, localtime

def createDefaultKnownNodes(appdata):
    ############## Stream 1 ################
    stream1 = {}
    
    stream1['98.28.255.178'] = (8444,int(time.time()))
    stream1['66.65.120.151'] = (8080,int(time.time()))
    stream1['87.236.30.170'] = (8444,int(time.time()))
    stream1['163.118.75.118'] = (8444,int(time.time()))
    stream1['88.130.32.123'] = (8444,int(time.time()))

    ############# 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]
            print host, '\t', port, '\t', unicode(strftime('%a, %d %b %Y  %I:%M %p',localtime(storedtime)))

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)
    readDefaultKnownNodes(appdata)



@@ -239,21 +239,19 @@
 m1%5B'
-98.28.255.178
+109.91.57.2
 '%5D =
@@ -247,33 +247,33 @@
 91.57.2'%5D = (844
-4
+3
 ,int(time.time()
@@ -347,21 +347,21 @@
 m1%5B'
-87.236.30.170
+188.18.69.115
 '%5D =
@@ -357,33 +357,33 @@
 .69.115'%5D = (844
-4
+3
 ,int(time.time()
@@ -402,77 +402,188 @@
 m1%5B'
-163.118.75.118'%5D = (8444,int(time.time()))%0A    stream1%5B'88.130.32.
+204.236.246.212'%5D = (8444,int(time.time()))%0A    stream1%5B'85.177.81.73'%5D = (8444,int(time.time()))%0A    stream1%5B'78.81.56.239'%5D = (8444,int(time.time()))%0A    stream1%5B'204.236.246.2
 12
-3
 '%5D =
@@ -608,16 +608,17 @@
 me()))%0A%0A
+%0A
     ####

update defaultKnownNodes.py