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 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 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(); }
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 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); }
protected virtual void DoUPnPExternalRecieveAccess() { try { tcpListener = new TcpConnectionListener(Port); tcpListener.Update += new FmdcEventHandler(DoUPnPExternalRecieveAccess_Update); tcpListener.Start(); // Don't do this if we don't have external ip if ( (Functions.UPnPDevices & Success) == Functions.UPnPDevices && (Functions.UPnPIGD & Success) == Functions.UPnPIGD && (Functions.UPnPExternalIp & Success) == Functions.UPnPExternalIp && (Functions.UPnPAddMapping & Success) == Functions.UPnPAddMapping && (Functions.UPnPGetMapping & Success) == Functions.UPnPGetMapping && (Functions.UPnPDeleteMapping & Success) == Functions.UPnPDeleteMapping ) { bool hasAddPortMapping = false; if (hasAddPortMapping = wanipService.AddPortMapping(this, mapping)) { //Transfer transfer = new Transfer(ExternalIPUPnP.ToString(), Port); Transfer transfer = new Transfer(ExternalIP.ToString(), Port); UserInfo me = new UserInfo(); me.DisplayName = "upnp"; me.TagInfo.Version = "FlowLibPowered"; transfer.Share = new Share("temp"); transfer.Me = me; transfer.Source = new Source(ExternalIP.ToString(), "upnp"); transferManager.AddTransferReq(new TransferRequest("upnp", null, new UserInfo())); transfer.Protocol = new TransferNmdcProtocol(transfer); transferManager.StartTransfer(transfer); // Wait 60 seconds before continue int i = 0; do { Thread.Sleep(50); } while (((Functions.UPnPExternalRecieveAccess & Success) != Functions.UPnPExternalRecieveAccess) && i++ > 1200); // clean; wanipService.DeletePortMapping(this, mapping); } } tcpListener.Update -= DoUPnPExternalRecieveAccess_Update; tcpListener.End(); tcpListener = null; } finally { Progress = Functions.End; } }
protected virtual void DoInternalListenRecieveAccess() { try { tcpListener = new TcpConnectionListener(Port); tcpListener.Update += new FmdcEventHandler(DoInternalListenAccess_Update); tcpListener.Start(); try { // TODO: We shouldn't limit ourself to IPv4. Transfer transfer = new Transfer("127.0.0.1", Port); UserInfo me = new UserInfo(); me.DisplayName = "loopback"; me.TagInfo.Version = "FlowLibPowered"; transfer.Share = new Share("temp"); transfer.Me = me; // TODO: We shouldn't limit ourself to IPv4. transfer.Source = new Source("127.0.0.1", "loopback"); transferManager.AddTransferReq(new TransferRequest("loopback", null, new UserInfo())); transfer.Protocol = new TransferNmdcProtocol(transfer); transferManager.StartTransfer(transfer); Success |= Functions.InternalListenAccess; } catch { // We do not have InternalListenAccess. Success = Success & ~Functions.InternalListenAccess; } // Wait 10 seconds before continue int i = 0; do { Thread.Sleep(50); } while (((Functions.InternalRecieveAccess & Success) != Functions.InternalRecieveAccess) && i++ > 200); // clean; tcpListener.Update -= DoInternalListenAccess_Update; tcpListener.End(); tcpListener = null; } finally { Progress = Functions.ExternalIp; } }
protected virtual void DoExternalRecieveAccess() { try { tcpListener = new TcpConnectionListener(Port); tcpListener.Update += new FmdcEventHandler(DoExternalRecieveAccess_Update); tcpListener.Start(); // Don't do this if we don't have external ip if ((Functions.ExternalIp & Success) == Functions.ExternalIp) { Transfer transfer = new Transfer(ExternalIP.ToString(), Port); UserInfo me = new UserInfo(); me.DisplayName = "external"; me.TagInfo.Version = "FlowLibPowered"; transfer.Share = new Share("temp"); transfer.Me = me; transfer.Source = new Source(ExternalIP.ToString(), "external"); transferManager.AddTransferReq(new TransferRequest("external", null, new UserInfo())); transfer.Protocol = new TransferNmdcProtocol(transfer); transferManager.StartTransfer(transfer); } // Wait 30 seconds before continue int i = 0; do { Thread.Sleep(50); } while (((Functions.ExternalRecieveAccess & Success) != Functions.ExternalRecieveAccess) && i++ > 600); // clean; tcpListener.Update -= DoExternalRecieveAccess_Update; tcpListener.End(); tcpListener = null; } finally { if ((Functions.ExternalRecieveAccess & Success) == Functions.ExternalRecieveAccess) { Progress = Functions.End; } else { Progress = Functions.UPnPDevices; } } }