コード例 #1
0
ファイル: main.py プロジェクト: ilebedie/imageserver
def main():
    try:
        logging.basicConfig(level=logging.DEBUG)

        parser = argparse.ArgumentParser()
        parser.add_argument('--host', default='127.0.0.1', type=str)
        parser.add_argument('--port', default=8000, type=int)
        args = parser.parse_args()

        config['HOST'] = config.get('HOST') or args.host
        config['PORT'] = config.get('PORT') or args.port

        middlewares = [
            basic_auth_middleware,
        ]
        app = web.Application(middlewares=middlewares)

        executor = concurrent.futures.ThreadPoolExecutor(
            max_workers=config['NUM_THREADS'])
        loop = asyncio.get_event_loop()
        app['config'] = config
        setup_storage(loop, executor)
        setup_handlers(app, loop, executor)
        setup_routes(app)
        web.run_app(app, host=config['HOST'], port=config['PORT'])
    finally:
        logging.info('Exiting app')
コード例 #2
0
ファイル: main.py プロジェクト: jcnelson/syndicatemail
def setup_storage( config ):
   rc = storage.setup_storage( config['volume_storage_root'], config['local_storage_root'], [contact, message, storage, keys] )
   if not rc:
      log.error("Failed to set up storage directories")
      return False 
   
   return True
コード例 #3
0
ファイル: message.py プロジェクト: jcnelson/syndicatemail
 def test_post_message( privkey_pem, encrypted_incoming_message, use_http=False ):
    """
    rc = network.post_message( privkey_pem, encrypted_incoming_message )
    if not rc:
       return rc
    """
    singleton.set_volume( fake_vol2 )
    assert storage.setup_storage( privkey_str2, "/apps/syndicatemail/data", "/tmp/storage-test/local2", [fake_mod] ), "setup_storage 2 failed"
    contact.write_contact( pubkey_str2, alice )
    contact.write_contact( pubkey_str2, bob )
    
    incoming_message = validate_and_parse_incoming_message( pubkey_str2, privkey_str2, bob.addr, encrypted_incoming_message )
    assert incoming_message is not False, "validate and parse incoming message failed"
    
    rc = store_incoming_message( bob.pubkey_pem, incoming_message, volume=fake_vol2 )
    assert rc, "store_incoming_message failed"
    
    singleton.set_volume( fake_vol )
    
    return True
コード例 #4
0
ファイル: contact.py プロジェクト: jcnelson/syndicatemail
+G9mWRvQgM3PptUXM6XV1kSPd+VofGvQ3ApYJ3I7f7VPPNTPVLI57vUkhOrKbBvh
Td3OGzhV48behsSmOEsXkNcOiogtqQsACZzgzI+46akS87m+OHhP8H3KcdsvGUNM
xwHi4nnnVSMQ+SWtSuCHgA+1gX5YlNKDjq3RLCRG//9XHIApfc9c52TJKZukLpfx
chit4EZW1ws/JPkQ+Yer91mCQaSkPnIBn2crzce4yqm2dOeHlhsfo25Wr37uJtWY
X8H/SaEdrJv+LaA61Fy4rJS/56Qg+LSy05lISwIHBu9SmhTuY1lBrr9jMa3Q
-----END RSA PRIVATE KEY-----
""".strip()

   import session 
   
   fake_module = collections.namedtuple( "FakeModule", ["VOLUME_STORAGE_DIRS", "LOCAL_STORAGE_DIRS"] )
   fake_vol = session.do_test_volume( "/tmp/storage-test/volume" )
   singleton.set_volume( fake_vol )
   
   fake_mod = fake_module( LOCAL_STORAGE_DIRS=LOCAL_STORAGE_DIRS, VOLUME_STORAGE_DIRS=VOLUME_STORAGE_DIRS )
   assert storage.setup_storage( privkey_str, "/apps/syndicatemail/data", "/tmp/storage-test/local", [fake_mod] ), "setup_storage failed"
   
   
   test_email_addrs = [
      "*****@*****.**",
      "*****@*****.**",
      "muneeb.volume.localhost@localhost"
   ]
   
   print "-------- parse_addr -----------"
   for addr in test_email_addrs:
      print addr
      print "%s" % str(parse_addr( addr ))
     
   print "-------- contact DB -----------"
   
コード例 #5
0
ファイル: session.py プロジェクト: jcnelson/syndicatemail
                  gateway_port=gateway_port,
                  ms_url=parsed_email.MS,
                  my_key_str=gateway_privkey_pem,
                  volume_key_pem=volume_pubkey_pem,   # FIXME: volume_pubkey_pem consistent naming
                  volume_name=parsed_email.volume,
                  oid_username=syndicate_oid_username,
                  oid_password=syndicate_oid_password )
                  
 
 config['gateway_privkey_pem'] = gateway_privkey_pem
 config['volume'] = volume
 singleton.set_volume( volume )
 
 # set up volume storage
 if need_storage_setup:
    rc = storage.setup_storage( account.VOLUME_STORAGE_ROOT, account.LOCAL_STORAGE_ROOT, [], volume=volume )
    if not rc:
       do_logout( config )
       raise Exception( "Failed to set up storage" )
 
 # get our account private key
 if privkey is None:
    # attempt to load the SyndicateMail private key
    privkey = keys.load_private_key( email, password )
    if privkey is None:
       
       raise Exception("Invalid username/password")
 
 privkey_str = privkey.exportKey()
 
 config['privkey'] = privkey