public LocalInterProcessEvent(string name) { _name = name; _readerWriterLock = MutextHelper.AttachToMutex(_name + "Peer2Peer.ReaderWriter"); _me = new LocalPeer(name); _eventWaitersRegistry = new MemoryMappedFileChannel(_name + "Peer2Peer.Registry", MAX_BYTES); _eventData = new MemoryMappedFileChannel(_name + "Peer2Peer.Data", MAX_BYTES); }
public readonly string[] ExtensionIds; // nullable // not null only for requests /// <summary> /// creates packet for transmission to peer /// </summary> /// <param name="connectedPeer">destination</param> /// <param name="stream">destination</param> public PeerHelloPacket(LocalPeer localPeer, ConnectedPeer connectedPeer, ConnectedPeerStream stream, PeerHelloRequestStatus status) { LibraryVersion = CompilationInfo.CompilationDateTimeUtc_uint32; ProtocolVersion = P2ptpCommon.ProtocolVersion; FromPeerId = localPeer.LocalPeerId; ExtensionIds = localPeer.Configuration.Extensions?.Select(x => x.ExtensionId).ToArray(); StreamId = stream.StreamId; ToPeerId = connectedPeer.RemotePeerId; Status = status; RequestTime32 = localPeer.Time32; RoleFlags = localPeer.Configuration.RoleAsUser ? (byte)0x01 : (byte)0x00; }
public void CircAuth() { m_LocalPeer = new LocalPeer { user = "******" }; LMS_Main.Instance.ShowPopup(1, "Authentication Succeeded\nWelcome " + m_LocalPeer.user, "Success", Color.green, (res, popup) => { if (res == E_PopupCallback.OK) { LMS_Main.Instance.ShowScreen(0); } }); }
/// <summary> /// Tworzy modul zarzadzajacy polaczeniami /// </summary> /// <param name = "netModule"></param> public NetworkManager(NetworkModule netModule) { _netModule = netModule; _netQueue = netModule.netQueue; _loopback = new LocalPeer(_netModule); //_loopback.ObjectReceived += ObjectReceived; _userConnectionMap = new UserConnectionMap(_netModule); _connectThread = new ConnectThread(); // _netQueue.Register(typeof (NetworkSend), HandleNetworkSend); _networkConnectTimer = new Timer(NextConnect, null, Timeout.Infinite, Timeout.Infinite); }
public static void Main() { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); XDocument xdoc = null; try { xdoc = XDocument.Load("http://localhost/pure/update/update.xml"); } catch { } if (xdoc != null) { Version version = Assembly.GetExecutingAssembly().GetName().Version; Version minimum = Version.Parse(xdoc.Element("update").Attribute("minimum").Value); if (version < minimum) { //using (UpdateDialog dialog = new UpdateDialog(xdoc)) //{ // dialog.ShowDialog(); //} return; } } //if (!InstallCertificate()) return; const string PeerStatePath = "peers.dat"; if (File.Exists(PeerStatePath)) { using (FileStream fs = new FileStream(PeerStatePath, FileMode.Open, FileAccess.Read, FileShare.Read)) { LocalPeer.LoadState(fs); } } //using (Blockchain.RegisterBlockchain(new LevelDBBlockchain("chain"))) using (LocalNode = new LocalPeer()) { LocalNode.UpnpEnabled = true; Application.Run(MainForm = new MainForm(xdoc)); } using (FileStream fs = new FileStream(PeerStatePath, FileMode.Create, FileAccess.Write, FileShare.None)) { LocalPeer.SaveState(fs); } }
public void Dispose() { if (Interlocked.Exchange(ref _disposeSignaled, 1) != 0) { return; } _me.Waiter.Set(); _me.Dispose(); _eventWaitersRegistry.Dispose(); _eventData.Dispose(); _readerWriterLock.Dispose(); _me = null; _eventWaitersRegistry = null; _eventData = null; _readerWriterLock = null; }
static void Main(string[] args) { var coordinatorServerIp1 = IPAddress.Parse("163.172.210.13"); //neth3 var coordinatorServerIp2 = IPAddress.Parse("195.154.173.208"); //fra2 var subtLocalPeer = new SubtLocalPeer(new SubtLocalPeerConfiguration { SenderThreadsCount = 4, BandwidthTarget = 1000000, }); var node = new LocalPeer(new LocalPeerConfiguration { RoleAsUser = true, LocalPeerUser = new User(), LocalUdpPortRangeStart = null, SocketsCount = 4, Coordinators = new IPEndPoint[] { new IPEndPoint(coordinatorServerIp1, 10000), new IPEndPoint(coordinatorServerIp1, 10001), new IPEndPoint(coordinatorServerIp1, 10002), //new IPEndPoint(coordinatorServerIp1, 10003), //new IPEndPoint(coordinatorServerIp1, 10004), //new IPEndPoint(coordinatorServerIp1, 10005), //new IPEndPoint(coordinatorServerIp1, 10006), //new IPEndPoint(coordinatorServerIp1, 10007), //new IPEndPoint(coordinatorServerIp1, 9000), //new IPEndPoint(coordinatorServerIp1, 9001), //new IPEndPoint(coordinatorServerIp1, 9002), //new IPEndPoint(coordinatorServerIp1, 9003), //new IPEndPoint(coordinatorServerIp2, 9000), //new IPEndPoint(coordinatorServerIp2, 9001), //new IPEndPoint(coordinatorServerIp2, 9002), //new IPEndPoint(coordinatorServerIp2, 9003), }, Extensions = new[] { subtLocalPeer } }); subtLocalPeer.MeasurementsHistory.OnMeasured += MeasurementsHistory_OnAddedNewMeasurement; Console.WriteLine("running test..."); Console.WriteLine($"target bandwidth: {subtLocalPeer.Configuration.BandwidthTarget.BandwidthToString()}"); Console.ReadLine(); node.Dispose(); }
} // not null if FlagIshareMyIpLocation == true /// <summary> /// creates request, for transmission to peer /// </summary> /// <param name="connectedPeer">destination</param> /// <param name="stream">destination</param> public PeerHelloPacket(LocalPeer localPeer, ConnectedPeer connectedPeer, ConnectedPeerStream stream, PeerHelloRequestStatus status, bool requestIpLocation) { LibraryVersion = MiscProcedures.CompilationDateTimeUtc_uint32Seconds; ProtocolVersion = P2ptpCommon.ProtocolVersion; FromPeerId = localPeer.LocalPeerId; ExtensionIds = localPeer.Configuration.Extensions?.Select(x => x.ExtensionId).ToArray(); StreamId = stream.StreamId; ToPeerId = connectedPeer.RemotePeerId; Status = status; RequestTime32 = localPeer.Time32; if (localPeer.Configuration.RoleAsUser) { Flags |= (byte)0x01; } if (requestIpLocation) { Flags |= (byte)0x04; } }
public Aquarium(string id) { // if no id defined - generate one. if (string.IsNullOrEmpty(id)) { this.Id = Environment.MachineName + "|" + Guid.NewGuid(); } else { this.Id = id; } localPeer = new LocalPeer(this.Id); localPeer.NewFish += NewFish; localPeer.FishSent += FishSent; Trace.WriteLine("Starting Aquarium Version " + localPeer.Version); localPeer.Start(); this.Properties = new AquariumProperties(this.localPeer.PeerProperties); this.store = IocContainer.Get <IAquariumStore>(); }
public static void Main(string[] args) { RudelNetwork serverNetwork = new RudelNetwork(); byte serverReliableChannel = serverNetwork.AddChannel(ChannelType.ReliableSequenced); RudelNetwork clientNetwork = new RudelNetwork(); byte clientReliableChannel = clientNetwork.AddChannel(ChannelType.ReliableSequenced); serverNetwork.Start(); clientNetwork.Start(); LocalPeer server = serverNetwork.CreateLocalPeer(); server.StartListening(new IPEndPoint(IPAddress.Any, 4343)); LocalPeer client = clientNetwork.CreateLocalPeer(); client.StartListening(new IPEndPoint(IPAddress.Any, 3434)); // Don't actually need this. You will get it in the connect event RemotePeer clientServerPeer = client.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 4343)); // TODO: Poll for messages while (true) { NetworkEvent serverEvent = server.Poll(); if (serverEvent != null) { Console.WriteLine("@Server: " + serverEvent.EventType); } NetworkEvent clientEvent = client.Poll(); if (clientEvent != null) { Console.WriteLine("@Client: " + clientEvent.EventType); } } }
public void TestConnection() { RudelNetwork network = new RudelNetwork(); network.Start(); LocalPeer server = new LocalPeer(network); server.StartListening(new IPEndPoint(IPAddress.Any, 5057)); LocalPeer client = new LocalPeer(network); client.StartListening(new IPEndPoint(IPAddress.Any, 5058)); RemotePeer remotePeer = client.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 5057)); while (true) { Debug.Print(remotePeer.ConnectionState.ToString()); } }
internal void WriteToLog_deepDetail(string message) { LocalPeer.WriteToLog_deepDetail(this, message); }
void FetchPeerInfo(string json) { m_LocalPeer = JsonMapper.ToObject <LocalPeer>(json); }
static DateTime VersionDateTimeUtc => new DateTime(2019, 12, 15); // todo get it somehow automatically in both windows and linux static void Main(string[] args) { Console.WriteLine("usage: StarTrinity.ContinuousSpeedTest.CLI target 1000000\r\n" + "where 1000000=1M is target bandwidth, in bits per second\r\n" + "any questions/problems/suggestions - email to [email protected]"); var bandwidthBps = 1000000; if (args[0] == "target") { bandwidthBps = int.Parse(args[1]); } MiscProcedures.Initialize(VersionDateTimeUtc); var coordinatorServerIp1 = IPAddress.Parse("163.172.210.13"); //neth3 var coordinatorServerIp2 = IPAddress.Parse("195.154.173.208"); //fra2 var subtLocalPeer = new SubtLocalPeer(new SubtLocalPeerConfiguration { SenderThreadsCount = 4, BandwidthTarget = bandwidthBps, }); var visionChannel = new VisionChannel1() { ClearLog_MessagesCount = 1000 }; visionChannel.SevereMessageEmitted += (msg) => { Console.WriteLine(msg.Message); }; var node = new LocalPeer(new LocalPeerConfiguration { RoleAsUser = true, VisionChannel = visionChannel, LocalUdpPortRangeStart = null, SocketsCount = 4, Coordinators = new IPEndPoint[] { new IPEndPoint(coordinatorServerIp1, 10000), new IPEndPoint(coordinatorServerIp1, 10001), new IPEndPoint(coordinatorServerIp1, 10002), //new IPEndPoint(coordinatorServerIp1, 10003), //new IPEndPoint(coordinatorServerIp1, 10004), //new IPEndPoint(coordinatorServerIp1, 10005), //new IPEndPoint(coordinatorServerIp1, 10006), //new IPEndPoint(coordinatorServerIp1, 10007), //new IPEndPoint(coordinatorServerIp1, 9000), //new IPEndPoint(coordinatorServerIp1, 9001), //new IPEndPoint(coordinatorServerIp1, 9002), //new IPEndPoint(coordinatorServerIp1, 9003), //new IPEndPoint(coordinatorServerIp2, 9000), //new IPEndPoint(coordinatorServerIp2, 9001), //new IPEndPoint(coordinatorServerIp2, 9002), //new IPEndPoint(coordinatorServerIp2, 9003), }, Extensions = new[] { subtLocalPeer } }); subtLocalPeer.MeasurementsHistory.OnMeasured += MeasurementsHistory_OnAddedNewMeasurement; Console.WriteLine("running test..."); Console.WriteLine($"target bandwidth: {subtLocalPeer.Configuration.BandwidthTarget.BandwidthToString()}"); Console.ReadLine(); node.Dispose(); }
internal void HandleException(Exception exc) { LocalPeer.HandleException(this, exc); }
/// <summary> /// Runs the given RPC method on the remote peer as soon as possible /// and returns the result or throws an <see cref="RpcException"/>. /// </summary> protected Task <T> ExecuteOnRemotePeer <T>(string methodName, params object[] methodParameters) => LocalPeer.ExecuteOnRemotePeer <T>(RemotePeerID, methodName, methodParameters);
internal void WriteToLog(string message) { LocalPeer.WriteToLog(this, message); }
internal void WriteToLog_lightPain(string message) { LocalPeer.WriteToLog_lightPain(this, message); }