Example #1
0
        public MappingService()
        {
            string externalip = new WebClient().DownloadString("http://icanhazip.com");

            Peers    = new List <Peer>();
            ThisPeer = new Peer()
            {
                Address = externalip, Port = Configurations.Config.MainPort
            };
            ActiveRequestForPeers = new List <RequestForPeers>();

            _server = Services.GetService <IP2PServer>();
            Logger  = Services.GetService <ILogger>();
        }
Example #2
0
        public void Init()
        {
            _blockChainPath      = Configurations.CurrentPath + "\\BlockChain\\";
            _blockChainFullPath  = $"{_blockChainPath}\\Chain\\";
            _blockInfoDbFullPath = _blockChainPath + "\\Data\\BlockInfo.sqlite";

            _logger = Services.GetService <ILogger>();
            _transactionVerifier = Services.GetService <ITransactionVerifier>();
            _blockVerifier       = Services.GetService <IBlockVerifier>();
            _server       = Services.GetService <IP2PServer>();
            _eventManager = Services.GetService <IEventManager>();
            _eventManager.RegisterEventListener(OnNewBlock, EventTypes.EventType.NewBlock);
            _mappingService = Services.GetService <IMappingService>();
            _minerService   = Services.GetService <IMinerService>();
            _walletService  = Services.GetService <IWalletService>();

            TryConnectToBlockInfoDb();
            TryLoadSavedInfo();
            _askedForRequests = new List <InvitationRequest>();
        }
Example #3
0
        public void Init()
        {
            _logger            = Services.GetService <ILogger>();
            _mappingService    = Services.GetService <IMappingService>();
            _server            = Services.GetService <IP2PServer>();
            _minerService      = Services.GetService <IMinerService>();
            _eventManager      = Services.GetService <IEventManager>();
            _blockChainService = Services.GetService <IBlockChainService>();

            _catchDataFullPath = $"{Configurations.CurrentPath}\\BlockChain\\Catchup";
            _logger.Log("Ketchup started to flow ....", 1);
            CaughtUp               = false;
            bufferedTransactions   = new List <Transaction>();
            bufferedBlockInfos     = new List <BlockInfo>();
            supposedLongestBlockId = "";
            shouldTryEnd           = false;
            LastGotResponse        = DateTime.UtcNow;

            if (!Directory.Exists(_catchDataFullPath))
            {
                Directory.CreateDirectory(_catchDataFullPath);
            }
        }
Example #4
0
        public void Init()
        {
            externalIp = JsonConvert.DeserializeObject <IpJson>(new WebClient().DownloadString("https://api.ipify.org/?format=json")).Ip;

            _peersFullPath   = Configurations.CurrentPath + "\\BlockChain\\Data\\Peers.json";
            _originsFullPath = Configurations.CurrentPath + "\\BlockChain\\Data\\Origins.json";

            ThisPeer = new Peer()
            {
                Address = externalIp, Port = Configurations.Config.MainPort
            };
            RequestHeader.Me = ThisPeer;

            ActiveRequestForPeers = new List <RequestForPeers>();

            _server    = Services.GetService <IP2PServer>();
            _catcherUp = Services.GetService <ICatchUpService>();

            Logger = Services.GetService <ILogger>();


            TryLoadPeers();
            Task.Run(() => PeerUpdateLoop());

            Peers.CollectionChanged += Peers_CollectionChanged;

            try
            {
                DoUPnP().Wait();
                Logger.Log("NAT traversal successfull.");
            }
            catch (Exception ex)
            {
                Logger.Log("UPnP NAT traversal error: " + ex.Message + " || " + ex.StackTrace, 2);
            }
        }
Example #5
0
 public Server(IP2PServer server)
 {
     _server      = server;
     ServerThread = new Thread(new ThreadStart(ServerLoop));
     ServerThread.Start();
 }
Example #6
0
    public void Initialize(int port, ICustomizeHandler customizeHandler, IBasicHandler basicHandler)
    {
        if (this.emptyAgileLogger_0 == null)
        {
            if (this.string_0 == null)
            {
                this.emptyAgileLogger_0 = new EmptyAgileLogger();
            }
            else
            {
                FileAgileLogger logger = new FileAgileLogger(this.string_0)
                {
                    MaxLength4ChangeFile = 0x100000L
                };
                this.emptyAgileLogger_0 = (EmptyAgileLogger)logger;
            }
        }
        Class16 class4 = new Class16();
        MessageForbiddenHandler class8 = new MessageForbiddenHandler();

        CJPlus.Rapid.WssOptions options = this.wssOptions_0 ?? new CJPlus.Rapid.WssOptions();
        this.object_0 = Class157.smethod_0((Enum6)0, true, options.X509Certificate2, options.SslProtocols, options.OnlyWssClient);
        BasicMessageTypeRoom room3 = new BasicMessageTypeRoom();

        room3.Initialize();
        this.int_0 = room3.Logon;
        this.int_1 = room3.HeartBeat;
        CustomizeMessageTypeRoom room4 = new CustomizeMessageTypeRoom();

        room4.Initialize();
        FileMessageTypeRoom room2 = new FileMessageTypeRoom();

        room2.Initialize();
        P2PSessionMessageTypeRoom room = new P2PSessionMessageTypeRoom();

        room.Initialize();
        FriendsMessageTypeRoom room5 = new FriendsMessageTypeRoom();

        room5.Initialize();
        GroupMessageTypeRoom room6 = new GroupMessageTypeRoom();

        room6.Initialize();
        ContactsMessageTypeRoom room7 = new ContactsMessageTypeRoom();

        room7.Initialize();
        this.class40_0 = new Class40(new IMessageTypeRoom[] { room3, room4, room2, room, room5, room6, room7 }, null);
        this.class40_0.method_2();
        this.class98_0             = new UserManager();
        this.class98_0.RelogonMode = RelogonMode.ReplaceOld;
        this.class98_0.method_2(this.int_2);
        this.class98_0.SetAgileLogger(this.emptyAgileLogger_0);
        this.class98_0.method_3((IConnection)this.object_0);
        this.class98_0.Initialize();
        this.class135_0 = new Class135(this.class98_0);
        RegularSender class5 = new RegularSender();

        class5.method_0(this.class98_0);
        class5.method_2(class8);
        class5.method_1((IAction)this.object_0);
        class5.method_3(this.emptyAgileLogger_0);
        if (basicHandler == null)
        {
            basicHandler = new EmptyBasicHandler();
        }
        Class159 class7 = new Class159();

        class7.Event_0 += new CbGeneric <string, IPEndPoint>(this.OnConnectionBound);
        class7.method_1(room3);
        class7.method_3(class4);
        class7.method_2(this.class98_0);
        class7.method_7(this.bool_2);
        class7.method_5(class5);
        class7.method_8(this.class21_0.DiagnosticsEnabled ? this.class64_0 : basicHandler);
        class7.method_9(this.class135_0);
        class7.method_10(this.igroupManager_0 != null);
        class7.method_12(this.bool_3);
        class7.method_14(this.bool_4);
        class7.method_15();
        this.class159_0 = class7;
        if (customizeHandler == null)
        {
            customizeHandler = new EmptyCustomizeHandler();
        }
        Server class2 = new Server();

        class2.SetStreamContract(class4);
        class2.SetAgileLogger(this.emptyAgileLogger_0);
        class2.SetICustomizeHandler(this.class21_0.DiagnosticsEnabled ? this.class64_0 : customizeHandler);
        class2.SetCustomizeMessageTypeRoom(room4);
        class2.method_1(class5);
        class2.SetUserManager(this.class98_0);
        class2.method_8(this.int_3);
        class2.method_11(this.class21_0.CheckResponseTTL4Query ? 10 : 0);
        class2.method_9(this.class135_0);
        class2.Event_0 += new CbGeneric <string, int, byte[], string>(this.method_6);
        class2.method_14(this.class21_0.CustomizeInfoHandleMode, this.class21_0.QueueWorkerThreadCount);
        this.class21_0.method_0((IConnection)this.object_0, this.class21_0.DiagnosticsEnabled ? this.class64_0.method_0() : null, class2.method_13());
        this.class112_0 = class2;
        Class132 class3 = new Class132();

        class3.method_1(room);
        class3.method_0(class4);
        class3.method_2(class5);
        class3.method_3(this.class98_0);
        class3.method_4(this.class135_0);
        class3.method_5(this.emptyAgileLogger_0);
        this.class2_0 = new FileTransfering();
        this.class2_0.method_0(this.emptyAgileLogger_0);
        this.class13_0 = new FileHandler();
        this.class13_0.method_0(this.emptyAgileLogger_0);
        this.class2_0.TTL4ResumedFileItem = this.class21_0.TempFile4ResumedTTL;
        this.class13_0.method_2(class5);
        this.class13_0.method_3(class4);
        this.class13_0.imethod_1(0x100000);
        this.class13_0.method_4(new Class3(0x800));
        this.class13_0.method_7(this.class21_0.UseWorkThreadPool);
        this.class13_0.Initialize("_0", room2.FilePackageData);
        this.class27_0 = new Parameterized(port);
        this.class27_0.method_2(this.class21_0.CheckFileZeroSpeedSpanInSecs);
        this.class27_0.method_0(this.emptyAgileLogger_0);
        this.class27_0.method_11(this.class13_0);
        this.class27_0.method_13(room2);
        this.class27_0.method_12(this.class2_0);
        this.class27_0.method_14(class4);
        this.class27_0.method_15(class5);
        this.class27_0.method_3("_0");
        Class69 class6 = new Class69();

        class6.method_0(room2);
        class6.method_6(class5);
        class6.method_1(class4);
        class6.method_3(this.class13_0);
        class6.method_2(this.class2_0);
        class6.method_4(this.class27_0);
        this.class98_0.SomeOneDisconnected += new CbGeneric <UserData, DisconnectedType>(this.method_8);
        this.class25_0.method_6(this.class21_0.DiagnosticsEnabled ? this.class64_0 : this.ifriendsManager_0);
        this.class25_0.method_1(room5);
        this.class25_0.method_7(this.class135_0);
        this.class25_0.method_3(class4);
        this.class25_0.method_5(class5);
        this.class25_0.method_2(this.class98_0);
        this.class25_0.method_9();
        this.class139_0.SetMessageTypeRoom(room6);
        this.class139_0.method_2(class4);
        this.class139_0.method_4(class5);
        this.class139_0.method_0(this.class98_0);
        this.class139_0.SetGroupManager(this.class21_0.DiagnosticsEnabled ? this.class64_0 : this.igroupManager_0);
        this.class139_0.method_6(this.class135_0);
        this.class139_0.Init();
        this.class60_0.method_1(room7);
        this.class60_0.method_2(class4);
        this.class60_0.method_4(class5);
        this.class60_0.method_0(this.class98_0);
        this.class60_0.method_5(this.class21_0.DiagnosticsEnabled ? this.class64_0 : this.icontactsManager_0);
        this.class60_0.method_6(this.class135_0);
        this.class60_0.method_7();
        IProcess[]        processers = new IProcess[] { class7, class2, class6, class3, this.class25_0, this.class139_0, this.class60_0 };
        MessageDispatcher class9     = new MessageDispatcher(new Class144(new Class115(processers)), class8);

        class9.imethod_0(this.emptyAgileLogger_0);
        this.object_0.imethod_22(this);
        this.object_0.SetAgileLogger(this.emptyAgileLogger_0);
        this.object_0.LjXdpkRter(this.string_1);
        this.object_0.SetData(port);
        this.object_0.imethod_10(GlobalUtil.MaxLengthOfMessage);
        this.object_0.SetStreamContract(class4);
        this.object_0.imethod_12(class9);
        this.object_0.SocketSendBuffSize = this.class21_0.SocketSendBuffSize;
        this.object_0.imethod_26((this.class21_0.WriteTimeoutInSecs <= 0) ? -1 : (this.class21_0.WriteTimeoutInSecs * 0x3e8));
        this.object_0.MaxChannelCacheSize          = this.class21_0.MaxChannelCacheSize;
        this.object_0.Boolean_0                    = this.class21_0.Boolean_0;
        this.object_0.AsynConnectionEvent          = this.class21_0.AsynConnectionEvent;
        this.object_0.UncompletedSendingCount4Busy = this.class21_0.UncompletedSendingCount4Busy;
        ((BaseTcpEngine)this.object_0).method_1(new Class119(class2, this.class98_0));
        this.object_0.Initialize();
        if (this.bool_1)
        {
            this.class17_0 = new Class17(this.class98_0, new SecurityFileLogger(this.emptyAgileLogger_0));
            this.class17_0.method_2();
        }
        if (this.bool_3)
        {
            this.object_1 = this.method_9(port + 1);
        }
        this.class64_0.ieduNnurne(customizeHandler, basicHandler, this.igroupManager_0, this.ifriendsManager_0, this.icontactsManager_0);
        this.bool_0 = true;
    }