コード例 #1
0
 def __init__(self):
     bankconfig = OnlineBankConfig()
     self.bank_addr = bankconfig.get_parameter("CLIENT", "bank_addr")
     self.bank_port = int(bankconfig.get_parameter("CLIENT", "bank_port"))
     # bank_stack = bankconfig.get_parameter("CLIENT", "stack", "default")
     self.bank_username = bankconfig.get_parameter("CLIENT", "username")
     self.certPath = os.path.join(bankconfig.path(), BANK_CERT_FILE_NAME)
     self.bank_cert = loadCertFromFile(self.certPath)
     self.bank_client = None
コード例 #2
0
import asyncio
import sys
import time

from playground.common.logging import EnablePresetLogging, PRESET_VERBOSE
from playground.network.packet.fieldtypes import BOOL, STRING
from playground.network.common import PlaygroundAddress
from playground.network.packet import PacketType
import playground
from autograder_ex6_packets import *
from game_packets import *

from CipherUtil import loadCertFromFile
from BankCore import LedgerLineStorage, LedgerLine
from OnlineBank import BankClientProtocol, OnlineBankConfig
import playground
import getpass, sys, os, asyncio

bankconfig = OnlineBankConfig()
bank_addr =     bankconfig.get_parameter("CLIENT", "bank_addr")
print('Client Bank Addr: ' + str(bank_addr))
bank_port = int(bankconfig.get_parameter("CLIENT", "bank_port"))
print('Client Bank Port: ' + str(bank_port))
bank_stack     =     bankconfig.get_parameter("CLIENT", "stack","default")
# bank_username  =     bankconfig.get_parameter("CLIENT", "username")
コード例 #3
0
from playground.network.packet.fieldtypes.attributes import Optional
from playground.common.logging import EnablePresetLogging, PRESET_DEBUG, PRESET_VERBOSE
from prfc_packet import *
from escape_room_006 import *

EnablePresetLogging(PRESET_DEBUG)

sys.path.append('../BitPoints-Bank-Playground3/src')
from CipherUtil import loadCertFromFile
from BankCore import LedgerLineStorage, LedgerLine
from OnlineBank import BankClientProtocol, OnlineBankConfig

bankconfig = OnlineBankConfig()
# bank_addr =     bankconfig.get_parameter("CLIENT", "bank_addr")
# bank_port = int(bankconfig.get_parameter("CLIENT", "bank_port"))
bank_stack = bankconfig.get_parameter("CLIENT", "stack", "default")
# bank_username  =     bankconfig.get_parameter("CLIENT", "username")

bank_addr = '20194.0.0.19000'
bank_port = '777'
bank_username = '******'

# certPath = os.path.join(bankconfig.path(), "bank.cert")
certPath = os.path.join('20194_online_bank.cert')
bank_cert = loadCertFromFile(certPath)

#Server_Port_number=1943+int(random.random()*1000)+int(random.random()*1000)
Server_Port_number = 18302


async def example_transfer(bank_client, src, dst, amount, memo, transs):
コード例 #4
0
import functools
import playground
import time
from autograder_ex8_packets import AutogradeStartTest, AutogradeTestStatus
from playground.network.packet import PacketType
import gc_packet_types
from CipherUtil import loadCertFromFile
from BankCore import LedgerLineStorage, LedgerLine
from OnlineBank import BankClientProtocol, OnlineBankConfig
import getpass, sys, os, asyncio

from playground.common.logging import EnablePresetLogging, PRESET_DEBUG
EnablePresetLogging(PRESET_DEBUG)

bankconfig = OnlineBankConfig()
bank_addr =     bankconfig.get_parameter("CLIENT", "bank_addr")
bank_port = int(bankconfig.get_parameter("CLIENT", "bank_port"))

certPath = os.path.join(bankconfig.path(), "bank.cert")
bank_cert = loadCertFromFile(certPath)
SRC_ACCOUNT = "jlee662_account"


async def transfer(bank_client, src, dst, amount, memo):
    await playground.create_connection(
            lambda: bank_client,
            bank_addr,
            bank_port,
            family='default'
            )
    print("Connected. Logging in.")
コード例 #5
0
import functools
import playground
import time
from autograder_ex6_packets import AutogradeStartTest, AutogradeTestStatus
from playground.network.packet import PacketType
import gc_packet_types
from CipherUtil import loadCertFromFile
from BankCore import LedgerLineStorage, LedgerLine
from OnlineBank import BankClientProtocol, OnlineBankConfig
import getpass, sys, os, asyncio

from playground.common.logging import EnablePresetLogging, PRESET_DEBUG
EnablePresetLogging(PRESET_DEBUG)

bankconfig = OnlineBankConfig()
bank_addr = bankconfig.get_parameter("CLIENT", "bank_addr")
bank_port = int(bankconfig.get_parameter("CLIENT", "bank_port"))

certPath = os.path.join(bankconfig.path(), "bank.cert")
bank_cert = loadCertFromFile(certPath)
SRC_ACCOUNT = "jlee662_account"


def verify(bank_client, receipt_bytes, signature_bytes, dst, amount, memo):
    if not bank_client.verify(receipt_bytes, signature_bytes):
        raise Exception("Bad receipt. Not correctly signed by bank")
    ledger_line = LedgerLineStorage.deserialize(receipt_bytes)
    if ledger_line.getTransactionAmount(dst) != amount:
        raise Exception("Invalid amount. Expected {} got {}".format(
            amount, ledger_line.getTransactionAmount(dst)))
    elif ledger_line.memo(dst) != memo: