Example #1
0
        public ActiveSearch()
        {
            UpdateBase = new FmdcEventHandler(ActiveSearch_UpdateBase);

            HubSetting settings = new HubSetting();
            settings.Address = "127.0.0.1";
            settings.Port = 411;
            settings.DisplayName = "FlowLib";
            settings.Protocol = "Auto";

            hubConnection = new Hub(settings, this);
            hubConnection.ProtocolChange += new FmdcEventHandler(hubConnection_ProtocolChange);
            hubConnection.Connect();

            Share share = new Share("Test");
            share.Port = 1000;

            // Telling that we are listening on port 1000 for incomming search results (Any means from everyone)
            UdpConnection udp = new UdpConnection(new IPEndPoint(IPAddress.Any, share.Port));
            udp.Protocol = new FlowLib.Protocols.UdpNmdcProtocol();
            udp.Protocol.MessageReceived += new FmdcEventHandler(Protocol_MessageReceived);
            // Enable Active searching
            hubConnection.Me.Mode = FlowLib.Enums.ConnectionTypes.Direct;
            hubConnection.Share = share;
        }
        public ActiveDownloadFilelistFromUser()
        {
            UpdateBase = new FmdcEventHandler(PassiveConnectToUser_UpdateBase);

            // Creates a empty share
            Share share = new Share("Testing");
            // Port to listen for incomming connections on
            share.Port = 12345;

            incomingConnectionListener = new TcpConnectionListener(share.Port);
            incomingConnectionListener.Update += new FmdcEventHandler(Connection_Update);
            incomingConnectionListener.Start();

            // Adds common filelist to share
            AddFilelistsToShare(share);

            HubSetting setting = new HubSetting();
            setting.Address = "127.0.0.1";
            setting.Port = 411;
            setting.DisplayName = "FlowLib";
            setting.Protocol = "Auto";

            Hub hubConnection = new Hub(setting, this);
            hubConnection.ProtocolChange += new FmdcEventHandler(hubConnection_ProtocolChange);
            // Adds share to hub
            hubConnection.Share = share;
            hubConnection.Me.Mode = FlowLib.Enums.ConnectionTypes.Direct;
            hubConnection.Connect();
        }
        public SendMainChatOrPMToHub()
        {
            UpdateBase = new FlowLib.Events.FmdcEventHandler(SendMainChatOrPMToHub_UpdateBase);

            HubSetting settings = new HubSetting();

            settings.Address     = "127.0.0.1";
            settings.Port        = 411;
            settings.DisplayName = "FlowLib";
            settings.Protocol    = "Auto";

            Hub hubConnection = new Hub(settings, this);

            hubConnection.Connect();
            // YOU should really listen for regmode change here.
            // Im not doing it here to make example more easy to understand.
            // Wait 10 seconds and hope we are connected.
            System.Threading.Thread.Sleep(10 * 1000);

            // Create mainchat message.
            MainMessage msg = new MainMessage(hubConnection.Me.ID, "Testing");

            // message will here be converted to right format and then be sent.
            UpdateBase(this, new FlowLib.Events.FmdcEventArgs(FlowLib.Events.Actions.MainMessage, msg));

            // Create private message.
            PrivateMessage privMsg = new PrivateMessage("DCpp706", hubConnection.Me.ID, "Testing");

            // message will here be converted to right format and then be sent.
            UpdateBase(this, new FlowLib.Events.FmdcEventArgs(FlowLib.Events.Actions.PrivateMessage, privMsg));
        }
Example #4
0
        public ActiveSearch()
        {
            UpdateBase = new FmdcEventHandler(ActiveSearch_UpdateBase);

            HubSetting settings = new HubSetting();

            settings.Address     = "127.0.0.1";
            settings.Port        = 411;
            settings.DisplayName = "FlowLib";
            settings.Protocol    = "Auto";

            hubConnection = new Hub(settings, this);
            hubConnection.ProtocolChange += new FmdcEventHandler(hubConnection_ProtocolChange);
            hubConnection.Connect();

            Share share = new Share("Test");

            share.Port = 1000;

            // Telling that we are listening on port 1000 for incomming search results (Any means from everyone)
            UdpConnection udp = new UdpConnection(new IPEndPoint(IPAddress.Any, share.Port));

            udp.Protocol = new FlowLib.Protocols.UdpNmdcProtocol();
            udp.Protocol.MessageReceived += new FmdcEventHandler(Protocol_MessageReceived);
            // Enable Active searching
            hubConnection.Me.Mode = FlowLib.Enums.ConnectionTypes.Direct;
            hubConnection.Share   = share;
        }
        public PassiveDownloadFilelistFromUserUsingTLS()
        {
            UpdateBase = new FmdcEventHandler(PassiveConnectToUser_UpdateBase);

            // Creates a empty share
            Share share = new Share("Testing");

            // Adds common filelist to share
            AddFilelistsToShare(share);

            HubSetting setting = new HubSetting();

            setting.Address     = "127.0.0.1";
            setting.Port        = 411;
            setting.DisplayName = "FlowLibPassiveTLS";
            setting.Protocol    = "Auto";

            Hub hubConnection = new Hub(setting, this);

            hubConnection.ProtocolChange += new FmdcEventHandler(hubConnection_ProtocolChange);
            // Adds share to hub
            hubConnection.Share = share;
            hubConnection.Me.Set(UserInfo.SECURE, "");
            hubConnection.Connect();
        }
Example #6
0
        public MultiConnections()
        {
            UpdateBase = new FmdcEventHandler(PassiveConnectToUser_UpdateBase);

            // Creates a empty share
            Share share = new Share("Testing");
            // Port to listen for incomming connections on
            share.Port = 12345;

            incomingConnectionListener = new TcpConnectionListener(share.Port);
            incomingConnectionListener.Update += new FmdcEventHandler(Connection_Update);
            incomingConnectionListener.Start();

            // Adds common filelist to share
            AddFilelistsToShare(share);

            HubSetting setting = new HubSetting();
            setting.Address = "127.0.0.1";
            setting.Port = 411;
            setting.DisplayName = "FlowLib";
            setting.Protocol = "Auto";

            hub = new Hub(setting, this);
            hub.ProtocolChange += new FmdcEventHandler(hubConnection_ProtocolChange);
            // Adds share to hub
            hub.Share = share;
            hub.Me.Mode = FlowLib.Enums.ConnectionTypes.Direct;
            hub.Connect();

            last = System.DateTime.Now.Ticks;
            timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
            timer.AutoReset = true;
            timer.Interval = 1000;
            timer.Start();
        }
        public SendMainChatOrPMToHub()
        {
            UpdateBase = new FlowLib.Events.FmdcEventHandler(SendMainChatOrPMToHub_UpdateBase);

            HubSetting settings = new HubSetting();
            settings.Address = "127.0.0.1";
            settings.Port = 411;
            settings.DisplayName = "FlowLib";
            settings.Protocol = "Auto";

            Hub hubConnection = new Hub(settings, this);
            hubConnection.Connect();
            // YOU should really listen for regmode change here.
            // Im not doing it here to make example more easy to understand.
            // Wait 10 seconds and hope we are connected.
            System.Threading.Thread.Sleep(10 * 1000);

            // Create mainchat message.
            MainMessage msg = new MainMessage(hubConnection.Me.ID, "Testing");
            // message will here be converted to right format and then be sent.
            UpdateBase(this, new FlowLib.Events.FmdcEventArgs(FlowLib.Events.Actions.MainMessage, msg));

            // Create private message.
            PrivateMessage privMsg = new PrivateMessage("DCpp706", hubConnection.Me.ID, "Testing");

            // message will here be converted to right format and then be sent.
            UpdateBase(this, new FlowLib.Events.FmdcEventArgs(FlowLib.Events.Actions.PrivateMessage, privMsg));
        }
Example #8
0
        public Hub(HubSetting infav, IBaseUpdater gui)
            : base(infav.Address, infav.Port)
        {
            fav = infav;    // Sets Favorites.
            me = new User(fav.DisplayName);
            me.UserInfo.Description = fav.UserDescription;
            me.Tag.Version = "FlowLib";

            UpdateRegMode();
            UpdateShare();
            #region Event(s)
            UnknownProtocolId = new FmdcEventHandler(OnUnknownProtocolId);
            RegModeUpdated += new FmdcEventHandler(Hub_RegModeUpdated);
            ProtocolChange += new FmdcEventHandler(Hub_ProtocolChange);
            #endregion
            #region Event(s)
            if (gui != null)
            {
                gui.UpdateBase += new FmdcEventHandler(OnUpdateBase);
                baseUpdater = gui;
            }
            #endregion
            //FireUpdate(Actions.Name, new HubName(HubSetting.Address + ":" + HubSetting.Port.ToString()));
            #region Keep Alive
            // For Connection Keepalive
            TimerCallback timerDelegate = new TimerCallback(OnkeepAliveTimer_Elapsed);
            keepAliveTimer = new System.Threading.Timer(timerDelegate, socket, interval * 1000, interval * 1000);
            #endregion
        }
        public CollectTransferedInformationFromFilelistDownload()
        {
            UpdateBase = new FmdcEventHandler(PassiveConnectToUser_UpdateBase);

            // Creates a empty share
            Share share = new Share("Testing");
            // Port to listen for incomming connections on
            share.Port = 12345;

            incomingConnectionListener = new TcpConnectionListener(share.Port);
            incomingConnectionListener.Update += new FmdcEventHandler(Connection_Update);
            incomingConnectionListener.Start();

            // Adds common filelist to share
            AddFilelistsToShare(share);

            HubSetting setting = new HubSetting();
            setting.Address = "127.0.0.1";
            setting.Port = 411;
            setting.DisplayName = "FlowLib";
            setting.Protocol = "Auto";

            Hub hubConnection = new Hub(setting, this);
            hubConnection.ProtocolChange += new FmdcEventHandler(hubConnection_ProtocolChange);
            // Adds share to hub
            hubConnection.Share = share;
            //hubConnection.Me.Mode = FlowLib.Enums.ConnectionTypes.Direct;
            hubConnection.Me.TagInfo.Slots = 2;
            hubConnection.Connect();

            FlowLib.Utils.Convert.General.BinaryPrefixes bp;
            Console.WriteLine("Press any key to update information");
            do
            {
                Console.ReadKey(true);
                Console.Clear();
                Console.WriteLine("Press any key to update information");
                Console.WriteLine("==================================");
                if (stats != null)
                {
                    Console.WriteLine("Total data sent: " + FlowLib.Utils.Convert.General.FormatBytes(stats.TotalBytesSent, out bp) + bp);
                    Console.WriteLine("Total data received: " + FlowLib.Utils.Convert.General.FormatBytes(stats.TotalBytesReceived, out bp) + bp);
                    Console.WriteLine("current download speed: " + FlowLib.Utils.Convert.General.FormatBytes(stats.CurrentReceiveSpeed, out bp) + bp + "/s");
                    Console.WriteLine("current upload speed: " + FlowLib.Utils.Convert.General.FormatBytes(stats.CurrentSendSpeed, out bp) + bp + "/s");
                    Decimal d = new decimal(stats.MaximumReceiveSpeed);
                    Console.WriteLine("Maximum download speed: " + FlowLib.Utils.Convert.General.FormatBytes(decimal.ToInt64(d), out bp) + bp + "/s");
                    d = new decimal(stats.MaximumSendSpeed);
                    Console.WriteLine("Maximum upload speed: " + FlowLib.Utils.Convert.General.FormatBytes(decimal.ToInt64(d), out bp) + bp + "/s");
                    d = new decimal(stats.MinimumReceiveSpeed);
                    Console.WriteLine("Minimum download speed: " + FlowLib.Utils.Convert.General.FormatBytes(decimal.ToInt64(d), out bp) + bp + "/s");
                    d = new decimal(stats.MinimumSendSpeed);
                    Console.WriteLine("Minimum upload speed: " + FlowLib.Utils.Convert.General.FormatBytes(decimal.ToInt64(d), out bp) + bp + "/s");
                }
                else
                {
                    Console.WriteLine("No transfer has started yet.");
                }
                Console.WriteLine("==================================");
            } while (true);
        }
        public CollectTransferedInformationForHub()
        {
            HubSetting settings = new HubSetting();
            settings.Address = "127.0.0.1";
            settings.Port = 411;
            settings.DisplayName = "FlowLib";
            settings.Protocol = "Auto";   // Here we tell it we dont care what protocol it uses (Adc or Nmdc). Just try to connect.

            Hub hubConnection = new Hub(settings);
            // Here we bind hub to our data collector
            stats = new GeneralProtocolDataCollector(hubConnection);
            hubConnection.Connect();
            General.BinaryPrefixes bp;
            Console.WriteLine("Press any key to update information");
            do
            {
                Console.ReadKey(true);
                Console.Clear();
                Console.WriteLine("Press any key to update information");
                Console.WriteLine("==================================");
                Console.WriteLine("Total data sent: " + General.FormatBytes(stats.TotalBytesSent, out bp) + bp);
                Console.WriteLine("Total data received: " + General.FormatBytes(stats.TotalBytesReceived, out bp) + bp);
                Console.WriteLine("current download speed: " + General.FormatBytes(stats.CurrentReceiveSpeed, out bp) + bp + "/s");
                Console.WriteLine("current upload speed: " + General.FormatBytes(stats.CurrentSendSpeed, out bp) + bp + "/s");
                Decimal d = new decimal(stats.MaximumReceiveSpeed);
                Console.WriteLine("Maximum download speed: " + General.FormatBytes(decimal.ToInt64(d), out bp) + bp + "/s");
                d = new decimal(stats.MaximumSendSpeed);
                Console.WriteLine("Maximum upload speed: " + General.FormatBytes(decimal.ToInt64(d), out bp) + bp + "/s");
                d = new decimal(stats.MinimumReceiveSpeed);
                Console.WriteLine("Minimum download speed: " + General.FormatBytes(decimal.ToInt64(d), out bp) + bp + "/s");
                d = new decimal(stats.MinimumSendSpeed);
                Console.WriteLine("Minimum upload speed: " + General.FormatBytes(decimal.ToInt64(d), out bp) + bp + "/s");
                Console.WriteLine("==================================");
            } while (true);
        }
        public ActiveEmptySharingUsingTLS()
        {
            // Creates a empty share
            Share share = new Share("Testing");
            // Port to listen for incomming connections on
            share.Port = 12345;
            AddFilelistsToShare(share);

            incomingConnectionListener = new TcpConnectionListener(share.Port);
            incomingConnectionListener.Update += new FmdcEventHandler(Connection_Update);
            incomingConnectionListener.Start();

            // TLS listener
            incomingConnectionListenerTLS = new TcpConnectionListener(tlsport);
            incomingConnectionListenerTLS.Update += new FmdcEventHandler(Connection_UpdateTLS);
            incomingConnectionListenerTLS.Start();

            HubSetting setting = new HubSetting();
            setting.Address = "127.0.0.1";
            setting.Port = 411;
            setting.DisplayName = "FlowLibActiveTLS";
            setting.Protocol = "Auto";

            Hub hubConnection = new Hub(setting);
            hubConnection.ProtocolChange += new FmdcEventHandler(hubConnection_ProtocolChange);
            hubConnection.Share = share;
            hubConnection.Me.Mode = FlowLib.Enums.ConnectionTypes.Direct;
            #if !COMPACT_FRAMEWORK
            // Security, Windows Mobile doesnt support SSLStream so we disable this feature for it.
            hubConnection.Me.Set(UserInfo.SECURE, tlsport.ToString());
            #endif
            hubConnection.Connect();
        }
Example #12
0
        public PassiveSearch()
        {
            UpdateBase = new FlowLib.Events.FmdcEventHandler(PassiveSearch_UpdateBase);

            HubSetting settings = new HubSetting();

            settings.Address     = "127.0.0.1";
            settings.Port        = 411;
            settings.DisplayName = "FlowLib";
            settings.Protocol    = "Auto";

            Hub hubConnection = new Hub(settings, this);

            hubConnection.ProtocolChange += new FmdcEventHandler(hubConnection_ProtocolChange);
            hubConnection.Connect();

            // Wait 5 seconds (We should really listen on ConnectionStatusChange instead.
            System.Threading.Thread.Sleep(5 * 1000);

            // Send Search
            SearchInfo searchInfo = new SearchInfo();

            searchInfo.Set(SearchInfo.SEARCH, "Ubuntu");

            UpdateBase(this, new FlowLib.Events.FmdcEventArgs(Actions.Search, searchInfo));
        }
 public bool DeleteHubSetting(HubSetting hubSetting)
 {
     if (hubSetting == null) return false;
     _unitOfWork.HubSettingRepository.Delete(hubSetting);
     _unitOfWork.Save();
     return true;
 }
Example #14
0
        public ActiveEmptySharing()
        {
            // Creates a empty share
            Share share = new Share("Testing");

            // Port to listen for incomming connections on
            share.Port = 12345;
            AddFilelistsToShare(share);

            incomingConnectionListener         = new TcpConnectionListener(share.Port);
            incomingConnectionListener.Update += new FmdcEventHandler(Connection_Update);
            incomingConnectionListener.Start();

            HubSetting setting = new HubSetting();

            setting.Address     = "127.0.0.1";
            setting.Port        = 411;
            setting.DisplayName = "FlowLib";
            setting.Protocol    = "Auto";

            Hub hubConnection = new Hub(setting);

            hubConnection.ProtocolChange += new FmdcEventHandler(hubConnection_ProtocolChange);
            hubConnection.Share           = share;
            hubConnection.Me.Mode         = FlowLib.Enums.ConnectionTypes.Direct;
            hubConnection.Connect();
        }
Example #15
0
        public Hub(HubSetting infav, IBaseUpdater gui)
            : base(infav.Address, infav.Port)
        {
            fav = infav;    // Sets Favorites.
            me  = new User(fav.DisplayName);
            me.UserInfo.Description = fav.UserDescription;
            me.Tag.Version          = "FlowLib";

            UpdateRegMode();
            UpdateShare();
            #region Event(s)
            UnknownProtocolId = new FmdcEventHandler(OnUnknownProtocolId);
            RegModeUpdated   += new FmdcEventHandler(Hub_RegModeUpdated);
            ProtocolChange   += new FmdcEventHandler(Hub_ProtocolChange);
            #endregion
            #region Event(s)
            if (gui != null)
            {
                gui.UpdateBase += new FmdcEventHandler(OnUpdateBase);
                baseUpdater     = gui;
            }
            #endregion
            //FireUpdate(Actions.Name, new HubName(HubSetting.Address + ":" + HubSetting.Port.ToString()));
            #region Keep Alive
            // For Connection Keepalive
            TimerCallback timerDelegate = new TimerCallback(OnkeepAliveTimer_Elapsed);
            keepAliveTimer = new System.Threading.Timer(timerDelegate, socket, interval * 1000, interval * 1000);
            #endregion
        }
Example #16
0
        public DcBot(HubSetting settings)
        {
            UpdateBase = new FlowLib.Events.FmdcEventHandler(DcBot_UpdateBase);

            downloadManager.DownloadCompleted += new FmdcEventHandler(downloadManager_DownloadCompleted);

            // Creates a empty share
            Share share = new Share("Testing");
            // Do we want bot to be active?
            if (Program.USE_ACTIVE_MODE)
            {
                if (Program.PORT_TLS > 0)
                {
                    share.Port = Program.PORT_TLS;
                }
                else
                {
                    share.Port = Program.PORT_ACTIVE;
                }

                incomingConnectionListener = new TcpConnectionListener(Program.PORT_ACTIVE);
                incomingConnectionListener.Update += new FmdcEventHandler(Connection_Update);
                incomingConnectionListener.Start();

                // TLS listener
                incomingConnectionListenerTLS = new TcpConnectionListener(Program.PORT_TLS);
                incomingConnectionListenerTLS.Update += new FmdcEventHandler(Connection_UpdateTLS);
                incomingConnectionListenerTLS.Start();
            }
            // Adds common filelist to share
            AddFilelistsToShare(share);

            hubConnection = new Hub(settings, this);

            hubConnection.Me.TagInfo.Version = "Serie V:20101125";
            hubConnection.Me.TagInfo.Slots = 2;
            // DO NOT CHANGE THIS LINE!
            hubConnection.Me.Set(UserInfo.PID, "7OP7K374IKV7YMEYUI5F5R4YICFT36M7FL64AWY");

            // Adds share to hub
            hubConnection.Share = share;

            // Do we want bot to be active?
            if (Program.USE_ACTIVE_MODE)
            {
                hubConnection.Me.TagInfo.Mode = FlowLib.Enums.ConnectionTypes.Direct;
                hubConnection.Me.Set(UserInfo.SECURE, Program.PORT_TLS.ToString());
            }
            else
            {
                hubConnection.Me.TagInfo.Mode = FlowLib.Enums.ConnectionTypes.Passive;
                hubConnection.Me.Set(UserInfo.SECURE, "");
            }

            hubConnection.ConnectionStatusChange += new FmdcEventHandler(hubConnection_ConnectionStatusChange);
            hubConnection.ProtocolChange += new FmdcEventHandler(hubConnection_ProtocolChange);
            hubConnection.SecureUpdate += new FmdcEventHandler(hubConnection_SecureUpdate);
        }
Example #17
0
        public void Init()
        {
            Application.InitilizeAll();

            _settings             = new HubSetting();
            _settings.Address     = "127.0.0.1";
            _settings.Port        = 411;
            _settings.DisplayName = "FlowLib";
            _settings.Password    = "******";
        }
Example #18
0
        public virtual ActionResult Create(HubSetting hubSetting)
        {
            if (ModelState.IsValid)
            {
                _hubSettingService.AddHubSetting(hubSetting);
                return(RedirectToAction("Index"));
            }

            return(View(hubSetting));
        }
Example #19
0
 public bool DeleteHubSetting(HubSetting hubSetting)
 {
     if (hubSetting == null)
     {
         return(false);
     }
     _unitOfWork.HubSettingRepository.Delete(hubSetting);
     _unitOfWork.Save();
     return(true);
 }
Example #20
0
 public virtual ActionResult Edit(HubSetting hubSetting)
 {
     if (ModelState.IsValid)
     {
         _hubSettingService.EditHubSetting(hubSetting);
         //return RedirectToAction("Index");
         return(Json(new { success = true }));
     }
     return(PartialView(hubSetting));
 }
Example #21
0
        private SixBot(Okno gui)
        {
            gui.Bot = this;

            m_Gui      = gui;
            m_Hostname = "sazavahub.vscht.cz";

            CekejNaPripojeni();

            m_TransferManager = new TransferManager();
            m_DownloadManager = new DownloadManager();

            m_Share = new Share("Share");
            //m_Share.ErrorOccured += new FmdcEventHandler(m_Share_ErrorOccured);
            //m_Share.HashAllowDuplicate = false;
            //m_Share.HashAutoSaveCount = 1;
            //m_Share.AddVirtualDir("Test", AppDomain.CurrentDomain.BaseDirectory+"\\Test");
            //m_Share.AddVirtualDir("Test2", @"F:\Hry\EasyUO");
            //General.AddCommonFilelistsToShare(m_Share, AppDomain.CurrentDomain.BaseDirectory);

            /* m_Share.HashContent();
             *
             * m_Gui.VypisRadek(m_Share.TotalCount.ToString());
             * m_Gui.VypisRadek(m_Share.IsHashing.ToString());
             * m_Gui.VypisRadek(m_Share.HashedCount.ToString());*/

            HubSetting nastaveni = new HubSetting();

            nastaveni.Address = m_Hostname;
            nastaveni.Port    = 411;

#if DEBUG
            nastaveni.DisplayName = "Sixbot_Test";
#else
            nastaveni.DisplayName = "Sixbot";
#endif

            nastaveni.Protocol = "Nmdc";
            nastaveni.Password = "******";

            m_Hub       = new Hub(nastaveni, this);
            m_Hub.Share = m_Share;
            m_Hub.Me.TagInfo.Version = "SixBot";
            m_Hub.Me.Description     = "http://sixbot.googlecode.com";
            m_Hub.Me.Mode            = ConnectionTypes.Direct;

            m_Hub.ConnectionStatusChange += new FmdcEventHandler(m_Hub_ConnectionStatusChange);

            HandlerPrikazu.Inicialiazce(this);

            m_Hub.Connect();

            m_Hub.Protocol.Encoding = Encoding.Default; //je to nutnй od verze 4
        }
Example #22
0
        public DisplayRawMessages()
        {
            HubSetting settings = new HubSetting();
            settings.Address = "127.0.0.1";
            settings.Port = 411;
            settings.DisplayName = "FlowLib";
            settings.Protocol = "Auto";

            Hub hubConnection = new Hub(settings);
            hubConnection.ProtocolChange += new FlowLib.Events.FmdcEventHandler(hubConnection_ProtocolChange);
            hubConnection.Connect();
        }
        public ReceiveMainChatOrPMFromHub()
        {
            HubSetting settings = new HubSetting();
            settings.Address = "127.0.0.1";
            settings.Port = 411;
            settings.DisplayName = "FlowLib";
            settings.Protocol = "Auto";

            Hub hubConnection = new Hub(settings);
            hubConnection.ProtocolChange += new FmdcEventHandler(hubConnection_ProtocolChange);
            hubConnection.Connect();
        }
Example #24
0
        public void Init()
        {
            Application.InitilizeAll();

            UpdateBase = new FlowLib.Events.FmdcEventHandler(SendMainChatOrPMToHub_UpdateBase);

            _settings             = new HubSetting();
            _settings.Address     = "127.0.0.1";
            _settings.Port        = 411;
            _settings.DisplayName = "FlowLib";
            _settings.Password    = "******";
        }
        public void Init()
        {
            Application.InitilizeAll();

            UpdateBase = new FlowLib.Events.FmdcEventHandler(SendMainChatOrPMToHub_UpdateBase);

            _settings = new HubSetting();
            _settings.Address = "127.0.0.1";
            _settings.Port = 411;
            _settings.DisplayName = "FlowLib";
            _settings.Password = "******";
        }
        public RetrievingUserInfoWhenReceivingPrivateMessage()
        {
            UpdateBase = new FlowLib.Events.FmdcEventHandler(OnUpdateBase);

            HubSetting settings = new HubSetting();
            settings.Address = "127.0.0.1";
            settings.Port = 411;
            settings.DisplayName = "FlowLib";
            settings.Protocol = "Nmdc";

            Hub hubConnection = new Hub(settings, this);
            hubConnection.ProtocolChange += new FlowLib.Events.FmdcEventHandler(hubConnection_ProtocolChange);
            hubConnection.Connect();
        }
        public ReceiveMainChatOrPMFromHub()
        {
            HubSetting settings = new HubSetting();

            settings.Address     = "127.0.0.1";
            settings.Port        = 411;
            settings.DisplayName = "FlowLib";
            settings.Protocol    = "Auto";

            Hub hubConnection = new Hub(settings);

            hubConnection.ProtocolChange += new FmdcEventHandler(hubConnection_ProtocolChange);
            hubConnection.Connect();
        }
Example #28
0
        public bool ConnectToHub(string ip)
        {
            HubSetting settings = new HubSetting();
            settings.Address = ip;
            settings.Protocol = "Zpoc";
            settings.DisplayName = prefs.Nick;

            Hub hub = new Hub(settings);
            hub.Me.TagInfo.Version = "ZPoc V:3.00a";
            hub.ProtocolChange += new FmdcEventHandler(protUpdate);
            hub.Connect();

            return true;
        }
Example #29
0
        public DisplayRawMessages()
        {
            HubSetting settings = new HubSetting();

            settings.Address     = "127.0.0.1";
            settings.Port        = 411;
            settings.DisplayName = "FlowLib";
            settings.Protocol    = "Auto";

            Hub hubConnection = new Hub(settings);

            hubConnection.ProtocolChange += new FlowLib.Events.FmdcEventHandler(hubConnection_ProtocolChange);
            hubConnection.Connect();
        }
Example #30
0
        public bool ConnectToHub(string ip)
        {
            HubSetting settings = new HubSetting();

            settings.Address     = ip;
            settings.Protocol    = "Zpoc";
            settings.DisplayName = prefs.Nick;

            Hub hub = new Hub(settings);

            hub.Me.TagInfo.Version = "ZPoc V:3.00a";
            hub.ProtocolChange    += new FmdcEventHandler(protUpdate);
            hub.Connect();

            return(true);
        }
        public RetrievingUserInfoWhenReceivingPrivateMessage()
        {
            UpdateBase = new FlowLib.Events.FmdcEventHandler(OnUpdateBase);

            HubSetting settings = new HubSetting();

            settings.Address     = "127.0.0.1";
            settings.Port        = 411;
            settings.DisplayName = "FlowLib";
            settings.Protocol    = "Nmdc";

            Hub hubConnection = new Hub(settings, this);

            hubConnection.ProtocolChange += new FlowLib.Events.FmdcEventHandler(hubConnection_ProtocolChange);
            hubConnection.Connect();
        }
Example #32
0
 public override void NewNode(string nodeName, bool read)
 {
     if (read)
     {
         switch (nodeName)
         {
         case "Hub":
             current = new HubSetting();
             break;
         }
     }
     else
     {
         base.NewNode(nodeName, read);
     }
 }
Example #33
0
        public ConnectToHub()
        {
            HubSetting settings = new HubSetting();
            settings.Address = "127.0.0.1";
            settings.Port = 411;
            settings.DisplayName = "FlowLib";
            // The below is one way to say what protocol we should use when connecting to hub.
            //settings.Protocol = "Nmdc";   // Here we are saying we know it is a Nmdc hub
            //settings.Protocol = "Adc";   // Here we are saying we know it is a Adc hub
            //settings.Protocol = "Auto";   // Here we tell it we dont care what protocol it uses (Adc or Nmdc). Just try to connect.

            Hub hubConnection = new Hub(settings);
            // This is a other way to say what protocol we should use when connecting
            hubConnection.Protocol = new FlowLib.Protocols.HubNmdcProtocol(hubConnection);

            hubConnection.Connect();
        }
Example #34
0
 public override void Dispose()
 {
     if (!disposed)
     {
         if (baseUpdater != null)
         {
             baseUpdater.UpdateBase -= OnUpdateBase;
         }
         base.Dispose();
         Hub.RegModeUpdated -= Hub_RegModeUpdated;
         UnknownProtocolId  -= OnUnknownProtocolId;
         ProtocolChange     -= Hub_ProtocolChange;
         if (updateInfoTimer != null)
         {
             updateInfoTimer.Dispose();
             updateInfoTimer = null;
         }
         if (keepAliveTimer != null)
         {
             keepAliveTimer.Dispose();
             keepAliveTimer = null;
         }
         if (worker != null)
         {
             worker.Abort();
             worker = null;
         }
         lock (userlist)
         {
             if (userlist != null)
             {
                 userlist.Clear();
                 userlist = null;
             }
         }
         this.me = null;
         if (share != null)
         {
             share.LastModifiedChanged -= share_LastModifiedChanged;
             this.share = null;
         }
         this.fav = null;
     }
 }
Example #35
0
        public void Init()
        {
            Application.InitilizeAll();

            _testTimeoutLength = 20;

            UpdateBase = new FlowLib.Events.FmdcEventHandler(Downloading_In_PassiveMode_UpdateBase);

            downloadManager.DownloadCompleted += new FmdcEventHandler(downloadManager_DownloadCompleted);
            downloadManager.DownloadAdded     += new FmdcEventHandler(downloadManager_DownloadAdded);
            downloadManager.SourceAdded       += new FmdcEventHandler(downloadManager_SourceAdded);
            downloadManager.SegmentCompleted  += new FmdcEventHandler(downloadManager_SegmentCompleted);

            _settings             = new HubSetting();
            _settings.Address     = "127.0.0.1";
            _settings.Port        = 411;
            _settings.DisplayName = "FlowLib";
            _settings.Password    = "******";
        }
Example #36
0
        public ConnectToHub()
        {
            HubSetting settings = new HubSetting();

            settings.Address     = "127.0.0.1";
            settings.Port        = 411;
            settings.DisplayName = "FlowLib";
            // The below is one way to say what protocol we should use when connecting to hub.
            //settings.Protocol = "Nmdc";   // Here we are saying we know it is a Nmdc hub
            //settings.Protocol = "Adc";   // Here we are saying we know it is a Adc hub
            //settings.Protocol = "Auto";   // Here we tell it we dont care what protocol it uses (Adc or Nmdc). Just try to connect.

            Hub hubConnection = new Hub(settings);

            // This is a other way to say what protocol we should use when connecting
            hubConnection.Protocol = new FlowLib.Protocols.HubNmdcProtocol(hubConnection);

            hubConnection.Connect();
        }
Example #37
0
        public PassiveEmptySharing()
        {
            // Creates a empty share
            Share share = new Share("Testing");
            // Adds common filelist to share
            AddFilelistsToShare(share);

            HubSetting setting = new HubSetting();
            setting.Address = "127.0.0.1";
            setting.Port = 411;
            setting.DisplayName = "FlowLib";
            setting.Protocol = "Auto";

            Hub hubConnection = new Hub(setting);
            hubConnection.ProtocolChange += new FmdcEventHandler(hubConnection_ProtocolChange);
            // Adds share to hub
            hubConnection.Share = share;
            hubConnection.Connect();
        }
Example #38
0
        public ChangeBotUserInfo()
        {
            HubSetting settings = new HubSetting();
            settings.Address = "127.0.0.1";
            settings.Port = 411;
            settings.DisplayName = "FlowLib";
            settings.Protocol = "Auto";

            Hub hubConnection = new Hub(settings);

            // Connection mode in UserInfo. Direct/Passive/Socket5
            hubConnection.Me.Mode = FlowLib.Enums.ConnectionTypes.Direct;
            // Client/Bot name and version in UserInfo.
            hubConnection.Me.TagInfo.Version = "SpeedBot V:2.0";
            // Connection in UserInfo
            hubConnection.Me.Connection = "104KiB/s";
            // User Description in UserInfo
            hubConnection.Me.Description = "Testing you for a better feature";
            hubConnection.Connect();
        }
Example #39
0
        public ChangeBotUserInfo()
        {
            HubSetting settings = new HubSetting();

            settings.Address     = "127.0.0.1";
            settings.Port        = 411;
            settings.DisplayName = "FlowLib";
            settings.Protocol    = "Auto";

            Hub hubConnection = new Hub(settings);

            // Connection mode in UserInfo. Direct/Passive/Socket5
            hubConnection.Me.Mode = FlowLib.Enums.ConnectionTypes.Direct;
            // Client/Bot name and version in UserInfo.
            hubConnection.Me.TagInfo.Version = "SpeedBot V:2.0";
            // Connection in UserInfo
            hubConnection.Me.Connection = "104KiB/s";
            // User Description in UserInfo
            hubConnection.Me.Description = "Testing you for a better feature";
            hubConnection.Connect();
        }
        public PassiveEmptySharing()
        {
            // Creates a empty share
            Share share = new Share("Testing");

            // Adds common filelist to share
            AddFilelistsToShare(share);

            HubSetting setting = new HubSetting();

            setting.Address     = "127.0.0.1";
            setting.Port        = 411;
            setting.DisplayName = "FlowLib";
            setting.Protocol    = "Auto";

            Hub hubConnection = new Hub(setting);

            hubConnection.ProtocolChange += new FmdcEventHandler(hubConnection_ProtocolChange);
            // Adds share to hub
            hubConnection.Share = share;
            hubConnection.Connect();
        }
        public PassiveDownloadFilelistFromUserUsingTLS()
        {
            UpdateBase = new FmdcEventHandler(PassiveConnectToUser_UpdateBase);

            // Creates a empty share
            Share share = new Share("Testing");
            // Adds common filelist to share
            AddFilelistsToShare(share);

            HubSetting setting = new HubSetting();
            setting.Address = "127.0.0.1";
            setting.Port = 411;
            setting.DisplayName = "FlowLibPassiveTLS";
            setting.Protocol = "Auto";

            Hub hubConnection = new Hub(setting, this);
            hubConnection.ProtocolChange += new FmdcEventHandler(hubConnection_ProtocolChange);
            // Adds share to hub
            hubConnection.Share = share;
            hubConnection.Me.Set(UserInfo.SECURE, "");
            hubConnection.Connect();
        }
Example #42
0
        public MultiConnections()
        {
            UpdateBase = new FmdcEventHandler(PassiveConnectToUser_UpdateBase);

            // Creates a empty share
            Share share = new Share("Testing");

            // Port to listen for incomming connections on
            share.Port = 12345;

            incomingConnectionListener         = new TcpConnectionListener(share.Port);
            incomingConnectionListener.Update += new FmdcEventHandler(Connection_Update);
            incomingConnectionListener.Start();

            // Adds common filelist to share
            AddFilelistsToShare(share);

            HubSetting setting = new HubSetting();

            setting.Address     = "127.0.0.1";
            setting.Port        = 411;
            setting.DisplayName = "FlowLib";
            setting.Protocol    = "Auto";

            hub = new Hub(setting, this);
            hub.ProtocolChange += new FmdcEventHandler(hubConnection_ProtocolChange);
            // Adds share to hub
            hub.Share   = share;
            hub.Me.Mode = FlowLib.Enums.ConnectionTypes.Direct;
            hub.Connect();


            last            = System.DateTime.Now.Ticks;
            timer.Elapsed  += new System.Timers.ElapsedEventHandler(timer_Elapsed);
            timer.AutoReset = true;
            timer.Interval  = 1000;
            timer.Start();
        }
Example #43
0
        public PassiveSearch()
        {
            UpdateBase = new FlowLib.Events.FmdcEventHandler(PassiveSearch_UpdateBase);

            HubSetting settings = new HubSetting();
            settings.Address = "127.0.0.1";
            settings.Port = 411;
            settings.DisplayName = "FlowLib";
            settings.Protocol = "Auto";

            Hub hubConnection = new Hub(settings,this);
            hubConnection.ProtocolChange += new FmdcEventHandler(hubConnection_ProtocolChange);
            hubConnection.Connect();

            // Wait 5 seconds (We should really listen on ConnectionStatusChange instead.
            System.Threading.Thread.Sleep(5 * 1000);

            // Send Search
            SearchInfo searchInfo = new SearchInfo();
            searchInfo.Set(SearchInfo.SEARCH, "Ubuntu");

            UpdateBase(this, new FlowLib.Events.FmdcEventArgs(Actions.Search, searchInfo));
        }
        public CollectTransferedInformationForHub()
        {
            HubSetting settings = new HubSetting();

            settings.Address     = "127.0.0.1";
            settings.Port        = 411;
            settings.DisplayName = "FlowLib";
            settings.Protocol    = "Auto"; // Here we tell it we dont care what protocol it uses (Adc or Nmdc). Just try to connect.

            Hub hubConnection = new Hub(settings);

            // Here we bind hub to our data collector
            stats = new GeneralProtocolDataCollector(hubConnection);
            hubConnection.Connect();
            General.BinaryPrefixes bp;
            Console.WriteLine("Press any key to update information");
            do
            {
                Console.ReadKey(true);
                Console.Clear();
                Console.WriteLine("Press any key to update information");
                Console.WriteLine("==================================");
                Console.WriteLine("Total data sent: " + General.FormatBytes(stats.TotalBytesSent, out bp) + bp);
                Console.WriteLine("Total data received: " + General.FormatBytes(stats.TotalBytesReceived, out bp) + bp);
                Console.WriteLine("current download speed: " + General.FormatBytes(stats.CurrentReceiveSpeed, out bp) + bp + "/s");
                Console.WriteLine("current upload speed: " + General.FormatBytes(stats.CurrentSendSpeed, out bp) + bp + "/s");
                Decimal d = new decimal(stats.MaximumReceiveSpeed);
                Console.WriteLine("Maximum download speed: " + General.FormatBytes(decimal.ToInt64(d), out bp) + bp + "/s");
                d = new decimal(stats.MaximumSendSpeed);
                Console.WriteLine("Maximum upload speed: " + General.FormatBytes(decimal.ToInt64(d), out bp) + bp + "/s");
                d = new decimal(stats.MinimumReceiveSpeed);
                Console.WriteLine("Minimum download speed: " + General.FormatBytes(decimal.ToInt64(d), out bp) + bp + "/s");
                d = new decimal(stats.MinimumSendSpeed);
                Console.WriteLine("Minimum upload speed: " + General.FormatBytes(decimal.ToInt64(d), out bp) + bp + "/s");
                Console.WriteLine("==================================");
            } while (true);
        }
        public ActiveEmptySharingUsingTLS()
        {
            // Creates a empty share
            Share share = new Share("Testing");

            // Port to listen for incomming connections on
            share.Port = 12345;
            AddFilelistsToShare(share);

            incomingConnectionListener         = new TcpConnectionListener(share.Port);
            incomingConnectionListener.Update += new FmdcEventHandler(Connection_Update);
            incomingConnectionListener.Start();

            // TLS listener
            incomingConnectionListenerTLS         = new TcpConnectionListener(tlsport);
            incomingConnectionListenerTLS.Update += new FmdcEventHandler(Connection_UpdateTLS);
            incomingConnectionListenerTLS.Start();

            HubSetting setting = new HubSetting();

            setting.Address     = "127.0.0.1";
            setting.Port        = 411;
            setting.DisplayName = "FlowLibActiveTLS";
            setting.Protocol    = "Auto";

            Hub hubConnection = new Hub(setting);

            hubConnection.ProtocolChange += new FmdcEventHandler(hubConnection_ProtocolChange);
            hubConnection.Share           = share;
            hubConnection.Me.Mode         = FlowLib.Enums.ConnectionTypes.Direct;
#if !COMPACT_FRAMEWORK
// Security, Windows Mobile doesnt support SSLStream so we disable this feature for it.
            hubConnection.Me.Set(UserInfo.SECURE, tlsport.ToString());
#endif
            hubConnection.Connect();
        }
Example #46
0
        //
        // GET: /WarehouseSetting/Details/5

        public virtual ViewResult Details(int id)
        {
            HubSetting hubSetting = _hubSettingService.FindById(id);

            return(View(hubSetting));
        }
Example #47
0
        public DcBot(HubSetting settings)
        {
            UpdateBase = new FlowLib.Events.FmdcEventHandler(DcBot_UpdateBase);

            downloadManager.DownloadCompleted += new FmdcEventHandler(downloadManager_DownloadCompleted);

            // Creates a empty share
            Share share = new Share("Testing");

            // Do we want bot to be active?
            if (Program.USE_ACTIVE_MODE)
            {
                if (Program.PORT_TLS > 0)
                {
                    share.Port = Program.PORT_TLS;
                }
                else
                {
                    share.Port = Program.PORT_ACTIVE;
                }

                incomingConnectionListener         = new TcpConnectionListener(Program.PORT_ACTIVE);
                incomingConnectionListener.Update += new FmdcEventHandler(Connection_Update);
                incomingConnectionListener.Start();

                // TLS listener
                incomingConnectionListenerTLS         = new TcpConnectionListener(Program.PORT_TLS);
                incomingConnectionListenerTLS.Update += new FmdcEventHandler(Connection_UpdateTLS);
                incomingConnectionListenerTLS.Start();
            }
            // Adds common filelist to share
            AddFilelistsToShare(share);

            hubConnection = new Hub(settings, this);

            hubConnection.Me.TagInfo.Version = "Serie V:20101125";
            hubConnection.Me.TagInfo.Slots   = 2;
            // DO NOT CHANGE THIS LINE!
            hubConnection.Me.Set(UserInfo.PID, "7OP7K374IKV7YMEYUI5F5R4YICFT36M7FL64AWY");


            // Adds share to hub
            hubConnection.Share = share;


            // Do we want bot to be active?
            if (Program.USE_ACTIVE_MODE)
            {
                hubConnection.Me.TagInfo.Mode = FlowLib.Enums.ConnectionTypes.Direct;
                hubConnection.Me.Set(UserInfo.SECURE, Program.PORT_TLS.ToString());
            }
            else
            {
                hubConnection.Me.TagInfo.Mode = FlowLib.Enums.ConnectionTypes.Passive;
                hubConnection.Me.Set(UserInfo.SECURE, "");
            }

            hubConnection.ConnectionStatusChange += new FmdcEventHandler(hubConnection_ConnectionStatusChange);
            hubConnection.ProtocolChange         += new FmdcEventHandler(hubConnection_ProtocolChange);
            hubConnection.SecureUpdate           += new FmdcEventHandler(hubConnection_SecureUpdate);
        }
 public bool EditHubSetting(HubSetting hubSetting)
 {
     _unitOfWork.HubSettingRepository.Edit(hubSetting);
     _unitOfWork.Save();
     return true;
 }
Example #49
0
 public override void Dispose()
 {
     if (!disposed)
     {
         if (baseUpdater != null)
             baseUpdater.UpdateBase -= OnUpdateBase;
         base.Dispose();
         Hub.RegModeUpdated -= Hub_RegModeUpdated;
         UnknownProtocolId -= OnUnknownProtocolId;
         ProtocolChange -= Hub_ProtocolChange;
         if (updateInfoTimer != null)
         {
             updateInfoTimer.Dispose();
             updateInfoTimer = null;
         }
         if (keepAliveTimer != null)
         {
             keepAliveTimer.Dispose();
             keepAliveTimer = null;
         }
         if (worker != null)
         {
             worker.Abort();
             worker = null;
         }
         lock (userlist)
         {
             if (userlist != null)
             {
                 userlist.Clear();
                 userlist = null;
             }
         }
         this.me = null;
         if (share != null)
         {
             share.LastModifiedChanged -= share_LastModifiedChanged;
             this.share = null;
         }
         this.fav = null;
     }
 }
 public bool AddHubSetting(HubSetting hubSetting)
 {
     _unitOfWork.HubSettingRepository.Add(hubSetting);
     _unitOfWork.Save();
     return true;
 }
Example #51
0
        public override void Show()
        {
            if (setting == null)
            {
                setting = new HubSetting();
                int width  = 20;
                int height = 5;
                int px     = (Console.WindowWidth / 2) - width;
                int py     = (Console.WindowHeight / 2) - height;

                Rectangle popup = new Rectangle(px, py, width * 2, height * 2, ConsoleColor.Gray, ConsoleColor.DarkBlue);
                popup.Show();

                Label popupTitle = new Label(px, py, "Connection Setting", width * 2);
                popupTitle.BgColor = ConsoleColor.Blue;
                popupTitle.FgColor = ConsoleColor.DarkBlue;
                popupTitle.Show();

                TextField address = new TextField(px + 1, py + 2, "IP/DNS:", 31);
                address.BgColor = ConsoleColor.DarkBlue;
                address.FgColor = ConsoleColor.Gray;
                address.Show();

                TextField port = new TextField(px + 1, py + 4, "Port:", 33);
                port.BgColor = ConsoleColor.DarkBlue;
                port.FgColor = ConsoleColor.Gray;
                port.Show();

                TextField nick = new TextField(px + 1, py + 6, "DisplayName:", 26);
                nick.BgColor = ConsoleColor.DarkBlue;
                nick.FgColor = ConsoleColor.Gray;
                nick.Show();

                Button buttonConnect = new Button(px + 1, py + 8, "Connect");
                buttonConnect.OnSelect += new EventHandler(buttonConnect_OnSelect);
                buttonConnect.BgColor   = ConsoleColor.DarkBlue;
                buttonConnect.FgColor   = ConsoleColor.Gray;
                buttonConnect.Show();

                // Select one at a time
                System.Net.IPAddress ip = null;
                do
                {
                    address.Focus();
                    if (!string.IsNullOrEmpty(address.Input))
                    {
                        try
                        {
                            ip = System.Net.Dns.GetHostEntry(address.Input).AddressList[0];
                        }
                        catch (System.Exception)
                        {
                            // We are not going to try to catch this as developer that used this class made something wrong if this has to be thrown.
                            try
                            {
                                ip = System.Net.IPAddress.Parse(address.Input);
                            }
                            catch { }
                        }
                    }
                } while (ip == null);
                setting.Address = address.Input;
                int p = 0;
                // Port
                do
                {
                    port.Focus();
                    try
                    {
                        p = int.Parse(port.Input);
                    }
                    catch { }
                } while (p <= 0 && p > 65535);
                setting.Port = p;

                do
                {
                    nick.Focus();
                } while (string.IsNullOrEmpty(nick.Input));
                setting.DisplayName = nick.Input;

                buttonConnect.Focus();

                setting.Protocol = "Auto";
                setting.Port     = -1;
            }


            base.Show();
        }
Example #52
0
 public Hub(HubSetting infav)
     : this(infav, null)
 {
 }
Example #53
0
        //
        // GET: /WarehouseSetting/Delete/5

        public virtual ActionResult Delete(int id)
        {
            HubSetting hubSetting = _hubSettingService.FindById(id);

            return(View(hubSetting));
        }
Example #54
0
        //
        // GET: /WarehouseSetting/Edit/5

        public virtual ActionResult Edit(int id)
        {
            HubSetting hubsetting = _hubSettingService.FindById(id);

            return(PartialView(hubsetting));
        }
Example #55
0
        static void Main(string[] args)
        {
            //RegExpLib.CreateRegExpAssembly();
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            HubSetting settings = new HubSetting();

            WriteLine("*** NofArguments:" + args.Length);
            string file = null;
            if (args.Length > 0)
            {
                file = args[0];
                WriteLine(string.Format("*** Arguments[0 = {0}]", file));
            }else{
                WriteLine("*** No arguments");
                file = "localhost.xml";
            }

            if (!string.IsNullOrEmpty(file) && !string.IsNullOrEmpty(file.Trim()))
            {
                Settings xml = new Settings();
                xml.Read(file);
                if (xml.Hubs.Count > 0)
                {
                    settings = xml.Hubs[0];

                    // Set custom settings
                    DEBUG = xml.UseDebug;
                    USE_ACTIVE_MODE = xml.UserActiveConnectionMode;
                    CONVERT_EXTERNAL_IP_TO_INTERNAL_IP = xml.ConvertExternalIpToInternalIp;

                    int prt = xml.ActivePort;
                    if (prt >= System.Net.IPEndPoint.MinPort && prt <= System.Net.IPEndPoint.MaxPort)
                    {
                        PORT_ACTIVE = prt;
                    }
                    int prtTls = xml.TlsPort;
                    if (prtTls >= System.Net.IPEndPoint.MinPort && prtTls <= System.Net.IPEndPoint.MaxPort)
                    {
                        PORT_TLS = prtTls;
                    }

                    int tmp = xml.MaxNumberOfLinesInMessage;
                    if (tmp > 0)
                    {
                        MAX_NUMBER_OF_LINES_IN_MESSAGE = tmp;
                    }

                    WriteLine("*** Getting External IP");
                    //string strIp = FlowLib.Utils.WebOperations.GetPage("http://ip.flowertwig.org");
                    //System.Net.IPAddress ipAddress;
                    //if (System.Net.IPAddress.TryParse(strIp, out ipAddress))
                    //{
                    //    WriteLine("\tIP: " + strIp);
                    //    settings.Set("ExternalIP", strIp);
                    //}else
                    //{
                    //    WriteLine("\tUnable to get External IP");
                    //}

                    DcBot bot = new DcBot(settings);
                    bot.Connect();

                    Cleaner.Start();
                }
                else
                {
                    WriteLine("*** No hubs found in settings file.");
                    settings.Address = "127.0.0.1";
                    settings.Port = 411;
                    settings.DisplayName = "Serie";
                    settings.Protocol = "Nmdc";
                    settings.UserDescription = "https://code.google.com/p/seriebot/";

                    // Add default values so user know that it is possible to customize.
                    settings.Set(Settings.KEY_USE_DEBUG, DEBUG.ToString());
                    settings.Set(Settings.KEY_MAX_NUMBER_OF_LINES_IN_MESSAGE, MAX_NUMBER_OF_LINES_IN_MESSAGE.ToString());
                    settings.Set(Settings.KEY_USE_ACTIVE_CONNECTION_MODE, USE_ACTIVE_MODE.ToString());
                    settings.Set(Settings.KEY_PORT_TCP_AND_UDP, PORT_ACTIVE.ToString());
                    settings.Set(Settings.KEY_PORT_TLS, PORT_TLS.ToString());

                    xml = new Settings();
                    xml.Hubs.Add(settings);
                    xml.Write("localhost.xml");
                    WriteLine("*** Example setting file has been created.");
                    WriteLine("*** Press enter/return key to quit.");
                }
            }
            Console.Read();
            WriteLine("*** Application terminated by user.");
        }
Example #56
0
 public override void NewNode(string nodeName, bool read)
 {
     if (read)
     {
         switch (nodeName)
         {
             case "Hub":
                 current = new HubSetting();
                 break;
         }
     }
     else
     {
         base.NewNode(nodeName, read);
     }
 }
Example #57
0
        public void Init()
        {
            Application.InitilizeAll();

            _settings = new HubSetting();
            _settings.Address = "127.0.0.1";
            _settings.Port = 411;
            _settings.DisplayName = "FlowLib";
            _settings.Password = "******";
        }
Example #58
0
        public override void Show()
        {
            if (setting == null)
            {
                setting = new HubSetting();
                int width = 20;
                int height = 5;
                int px = (Console.WindowWidth / 2) - width;
                int py = (Console.WindowHeight / 2) - height;

                Rectangle popup = new Rectangle(px, py, width * 2, height * 2, ConsoleColor.Gray, ConsoleColor.DarkBlue);
                popup.Show();

                Label popupTitle = new Label(px, py, "Connection Setting", width * 2);
                popupTitle.BgColor = ConsoleColor.Blue;
                popupTitle.FgColor = ConsoleColor.DarkBlue;
                popupTitle.Show();

                TextField address = new TextField(px + 1, py + 2, "IP/DNS:", 31);
                address.BgColor = ConsoleColor.DarkBlue;
                address.FgColor = ConsoleColor.Gray;
                address.Show();

                TextField port = new TextField(px + 1, py + 4, "Port:", 33);
                port.BgColor = ConsoleColor.DarkBlue;
                port.FgColor = ConsoleColor.Gray;
                port.Show();

                TextField nick = new TextField(px + 1, py + 6, "DisplayName:", 26);
                nick.BgColor = ConsoleColor.DarkBlue;
                nick.FgColor = ConsoleColor.Gray;
                nick.Show();

                Button buttonConnect = new Button(px + 1, py + 8, "Connect");
                buttonConnect.OnSelect += new EventHandler(buttonConnect_OnSelect);
                buttonConnect.BgColor = ConsoleColor.DarkBlue;
                buttonConnect.FgColor = ConsoleColor.Gray;
                buttonConnect.Show();

                // Select one at a time
                System.Net.IPAddress ip = null;
                do
                {
                    address.Focus();
                    if (!string.IsNullOrEmpty(address.Input))
                    {
                        try
                        {
                            ip = System.Net.Dns.GetHostEntry(address.Input).AddressList[0];
                        }
                        catch (System.Exception)
                        {
                            // We are not going to try to catch this as developer that used this class made something wrong if this has to be thrown.
                            try
                            {
                                ip = System.Net.IPAddress.Parse(address.Input);
                            }
                            catch { }
                        }
                    }
                } while (ip == null);
                setting.Address = address.Input;
                int p = 0;
                // Port
                do
                {
                    port.Focus();
                    try
                    {
                        p = int.Parse(port.Input);
                    }
                    catch { }
                } while (p <= 0 && p > 65535);
                setting.Port = p;

                do
                {
                    nick.Focus();
                } while (string.IsNullOrEmpty(nick.Input));
                setting.DisplayName = nick.Input;

                buttonConnect.Focus();

                setting.Protocol = "Auto";
                setting.Port = -1;
            }

            base.Show();
        }
Example #59
0
        public void Init()
        {
            Application.InitilizeAll();

            _testTimeoutLength = 20;

            UpdateBase = new FlowLib.Events.FmdcEventHandler(Downloading_In_PassiveMode_UpdateBase);

            downloadManager.DownloadCompleted += new FmdcEventHandler(downloadManager_DownloadCompleted);
            downloadManager.DownloadAdded += new FmdcEventHandler(downloadManager_DownloadAdded);
            downloadManager.SourceAdded += new FmdcEventHandler(downloadManager_SourceAdded);
            downloadManager.SegmentCompleted += new FmdcEventHandler(downloadManager_SegmentCompleted);

            _settings = new HubSetting();
            _settings.Address = "127.0.0.1";
            _settings.Port = 411;
            _settings.DisplayName = "FlowLib";
            _settings.Password = "******";
        }