1. loginrl__103

    loginrl__103 New Member

    Joined:
    4 Mar 2008
    Messages:
    1
    Likes Received:
    0
    Reputations:
    0
    интересуют исходники (пусть старьё, слабый функционал, глючный) p2p софта/ботов/чатов(маленьких и с шифровокй(желательно), sf.net пока что мусором кормит))...уточню - общающихся через р2р...)

    пс трешовые генераторы не предлагать)
     
    #1 loginrl__103, 12 Jun 2008
    Last edited by a moderator: 12 Jun 2008
  2. Евдоким

    Евдоким New Member

    Joined:
    7 Jun 2008
    Messages:
    1
    Likes Received:
    0
    Reputations:
    0
    Одна из самых маленьких P2P приложений. Написано на Python.

    Code:
    # simplep2p.py v1.1 (C) 2004, Richard Jones
    # with litle touch from Leonardo Santagada
    # A slightly more readable version of tinyp2p.py (C) 2004, E.W. Felten
    # (also handles binary transmissions now too)
    # license: http://creativecommons.org/licenses/by-nc-sa/2.0
    # Usage:
    #   python simplep2p.py password server hostname portnum [otherurl]
    # or
    #   python simplep2p.py password client serverurl pattern
    import os, SimpleXMLRPCServer, re, hmac, sets, base64
    from sys import argv
    from xmlrpclib import ServerProxy
    
    def gen_password(url):
       return hmac.new(argv[1], url).hexdigest()
    def ls(pat=""):
        ''' List the files in the current working directory that optionall match
        a regular expression "pat". '''
        return [fn for fn in os.listdir(os.getcwd())
            if not pat or re.search(pat, fn)]
    
    if argv[2] == "server":
        my_url = "http://"+argv[3]+":"+argv[4]
    
        # keep a list of servers we know about
        servers = sets.Set([my_url] + argv[5:])
        def update_servers(new_servers=[]):
            servers.union_update(sets.Set(new_servers))
            return list(servers)
        def discover(other_url):
            if other_url == my_url: return servers
            pw = gen_password(other_url)
            server = ServerProxy(other_url)
            return update_servers(server.list_servers(pw, update_servers()))
    
        # ask all our known servers about the servers *they* know about
        if servers: [discover(url) for url in list(servers)]
    
        # serve up the files
        def list_servers(password, arg=[]):
            if password == gen_password(my_url):
                return update_servers(arg)
        def list_files(password, arg):
            if password == gen_password(my_url):
                return ls(arg)
        def get_file(password, arg):
            if password == gen_password(my_url):
                f = file(arg)
                try:
                    return base64.encodestring(f.read())
                finally:
                    f.close()
        server = SimpleXMLRPCServer.SimpleXMLRPCServer((argv[3], int(argv[4])))
        server.register_function(list_servers)
        server.register_function(list_files)
        server.register_function(get_file)
        server.serve_forever()
    
    # client - contact our server
    for url in ServerProxy(argv[3]).list_servers(gen_password(argv[3])):
        # ask for the files we want, that we don't already have
        files = sets.Set(ServerProxy(url).list_files(gen_password(url), argv[4]))
        my_files = sets.Set(ls())
        for fn in files - my_files:
            # and fetch
            c = ServerProxy(url).get_file(gen_password(url), fn)
            f = file(fn, "wb")
            f.write(base64.decodestring(c))
            f.close()