def call(target_ip): private_key = None username = None rres = load_from_data(socks_host) if rres is None: res = assign_to_ip(socks_host) username = res['name'] private_key = res['private_key'] elif rres is None and get_count_active() > max_ips_vps: print('We have {} IPs, no need to add this to our server'.format( max_ips_vps)) else: username = rres['name'] private_key = rres['private_key'] # print(private_key) if get_count_active() <= max_ips_vps: verbose = True target_port = 9444 config.load() connection_args_dict = dict(verbose=verbose) message_args_dict = dict(app_log=app_log) message_args_dict.update({ 'timestamp': int(time() * 1000) # 'sourceNodePrivateKey': private_key }) if (socks_host is None and socks_port is not None) or (socks_host is not None and socks_port is None): raise Exception('Socks port or socks host is not provided') if socks_host is not None: connection_args_dict.update({ 'socks_host': socks_host, 'socks_port': socks_port }) print('Propagating to {}:{}'.format(socks_host, socks_port)) try: connection = Connection(target_ip, **connection_args_dict) request = NodeJoin(target_port, username, app_log=app_log) message = Message(MessageType.NodeJoin3, private_key, request, **message_args_dict) res = connection.fetch(message) print(res.to_json()) except Exception as e: print('Skipped {}, {}'.format(target_ip, e)) pass
def main(): parser = argparse.ArgumentParser(description='Nyzo node join test') parser.add_argument("-I", "--ip", type=str, default='127.0.0.1', help="IP to query (default 127.0.0.1)") parser.add_argument("-p", "--port", type=int, default=9444, help='Port to query') parser.add_argument("-u", "--user", type=str, help='Username') parser.add_argument("-v", "--verbose", action="count", default=True, help='Be verbose.') parser.add_argument("-sh", "--socks_host", type=str, help='Socks5 host') parser.add_argument("-sp", "--socks_port", type=int, help='Socks5 port') parser.add_argument("-i", "--identifier", type=str, help='Source node identifier') parser.add_argument("-s", "--signature", type=str, help='Source node signature') parser.add_argument("-sip", "--source_ip", type=int, help='Source ip address') parser.add_argument("-pkey", "--private_key", type=str, help='Private key string') args = parser.parse_args() app_log = tornado_logger() config.load() connection_args_dict = dict(verbose=args.verbose) message_args_dict = dict(app_log=app_log) if args.identifier is not None: if args.signature is None: raise Exception('Signature data should be provided as well') try: message_args_dict.update({ 'timestamp': int(time() * 1000), 'sourceNodeIdentifier': args.identifier.encode(), 'sourceNodeSignature': args.signature.encode() }) except Exception: raise Exception( "Provided data in the arguments for identifier or signature are not correct" ) message_args_dict['sourceNodePrivateKey'] = args.private_key if (args.socks_host is None and args.socks_port is not None) or (args.socks_host is not None and args.socks_port is None): raise Exception('Socks port or socks host is not provided') if args.socks_host is not None: connection_args_dict.update({ 'socks_host': args.socks_host, 'socks_port': args.socks_port }) connection = Connection(args.ip, **connection_args_dict) request = NodeJoin(args.port, args.user, app_log=app_log) message = Message(MessageType.NodeJoin3, request, **message_args_dict) res = connection.fetch(message) print(res.to_json())
res = get(url).text if VERBOSE: print(res) if "Error:" in res: print("E", res) else: # Assemble, sign and forward if ok client = NyzoClient(ctx.obj['client']) res = client.send(recipient, fees, data, key_) print(res) if __name__ == '__main__': logger = logging.getLogger('push') app_log = logging.getLogger() app_log.setLevel(logging.INFO) ch = logging.StreamHandler(sys.stdout) ch.setLevel(logging.DEBUG) formatter = logging.Formatter('%(asctime)s [%(levelname)-5s] %(message)s') ch.setFormatter(formatter) app_log.addHandler(ch) # Use user private dir private_dir = get_private_dir() config.NYZO_SEED = private_dir + '/private_seed' config.load(private_dir) cli(obj={})
help="IP to query (default 127.0.0.1)") parser.add_argument("-v", "--verbose", action="count", default=False, help='Be verbose.') parser.add_argument("-a", "--action", type=str, default='status', help='Action (status, block)') args = parser.parse_args() app_log = tornado_logger() config.load() connection = Connection(args.ip, app_log=app_log, verbose=args.verbose) if args.action == 'status': empty = EmptyMessageObject(app_log=app_log) message = Message(MessageType.StatusRequest17, empty, app_log=app_log) res = connection.fetch(message) print(res.to_json()) elif args.action == 'block': # test. Use a block high enough so it's not frozen. # TODO: get last block from reference verifiers request = BlockRequest(start_height=1695400, end_height=1695400 + 2, include_balance_list=True, app_log=app_log)