public DrpTester2(VisionChannel visionChannel) { _visionChannel = visionChannel; _visionChannel.VisiblePeersDelegate = () => { return(VisiblePeers.ToList()); }; for (int i = 0; i < NumberOfEPs; i++) { var ep = new DrpPeerEngine(new DrpPeerEngineConfiguration { InsecureRandomSeed = _insecureRandom.Next(), LocalPort = (ushort)(EpLocalPort + i), VisionChannel = visionChannel, VisionChannelSourceId = $"EP{i}", ForcedPublicIpApiProviderResponse = IPAddress.Loopback, SandboxModeOnly_DisablePoW = true, SandboxModeOnly_EnableInsecureLogs = true, SandboxModeOnly_NumberOfDimensions = NumberOfDimensions });; var epLocalDrpPeerConfig = LocalDrpPeerConfiguration.Create(ep.CryptoLibrary, NumberOfDimensions); epLocalDrpPeerConfig.MinDesiredNumberOfNeighbors = null; epLocalDrpPeerConfig.AbsoluteMaxNumberOfNeighbors = null; epLocalDrpPeerConfig.SoftMaxNumberOfNeighbors = null; epLocalDrpPeerConfig.MinDesiredNumberOfNeighborsSatisfied_WorstNeighborDestroyIntervalS = null; _epList.Add(new DrpTesterPeerApp(ep, epLocalDrpPeerConfig)); } epList_BeginCreateLocalPeer(0); }
public DrpTester5(VisionChannel visionChannel) { _visionChannel = visionChannel; _visionChannel.VisiblePeersDelegate = () => { return(VisiblePeers.ToList()); }; RemoteEpEndPointsString = "192.99.160.225:12000;195.154.173.208:12000;5.135.179.50:12000"; LocalUser = PredefinedUsers[0]; RemoteUser = PredefinedUsers[1]; }
public Logger(DrpPeerEngine engine, IVisiblePeer localPeer, object req, string moduleName) { Engine = engine; _visionChannel = engine.Configuration.VisionChannel; _visionChannelSourceId = engine.Configuration.VisionChannelSourceId; _localPeer = localPeer; _req = req; ModuleName = moduleName; }
public UserAppEngine(UserAppConfiguration configuration, VisionChannel visionChannel) { Configuration = configuration; _visionChannel = visionChannel; _visionChannel.ClearModules(); _visionChannel.RegisterVisibleModule(VisionChannelSourceId, "UA", this); _drpPeerEngine = new DrpPeerEngine(new DrpPeerEngineConfiguration { VisionChannel = _visionChannel, VisionChannelSourceId = VisionChannelSourceId }); _db = new UserAppDatabase(_drpPeerEngine.CryptoLibrary, configuration.DatabaseKeyProvider, _visionChannel, VisionChannelSourceId, configuration.DatabaseBasePathNullable); LocalUsers = new Dictionary <int, LocalUser>(); var userRegistrationIDs = _db.GetUserRegistrationIDs(); foreach (var u in _db.GetUsers(true)) { var rootUserKeys = _db.GetRootUserKeys(u.Id); if (rootUserKeys != null) { var localUser = new LocalUser { User = u, RootUserKeys = rootUserKeys, }; if (!userRegistrationIDs.TryGetValue(u.Id, out localUser.UserRegistrationIDs)) { localUser.UserRegistrationIDs = new List <UserRegistrationID>(); } LocalUsers.Add(u.Id, localUser); localUser.CreateLocalDrpPeers(this); } } WriteToLog_deepDetail($"loaded {LocalUsers.Count} local users"); foreach (var contactUser in _db.GetUsers(false)) { if (LocalUsers.TryGetValue(contactUser.OwnerLocalUserId, out var localUser)) { var contact = new Contact { User = contactUser }; if (!userRegistrationIDs.TryGetValue(contact.User.Id, out contact.RegistrationIDs)) { contact.RegistrationIDs = new List <UserRegistrationID>(); } localUser.Contacts.Add(contact.User.Id, contact); } } }
public LocalPeer(LocalPeerConfiguration configuration) { if (configuration.VisionChannel == null) { throw new ArgumentNullException(nameof(configuration.VisionChannel)); } if (configuration.Extensions == null) { configuration.Extensions = new ILocalPeerExtension[0]; } VisionChannel = configuration.VisionChannel; VisionChannelSourceId = configuration.VisionChannelSourceId; Configuration = configuration; if (configuration.RoleAsUser) { // client if (configuration.RoleAsSharedPassive || configuration.RoleAsCoordinator) { throw new ArgumentException(nameof(configuration.RoleAsUser)); } if (configuration.Coordinators == null || configuration.Coordinators.Length < 1) { throw new ArgumentException("Please enter coordinator server(s) details: IP addresses and ports"); } // if (configuration.SubtUserTargetBandwidthBps == null) throw new ArgumentException(nameof(configuration.SubtUserTargetBandwidthBps)); } else if (configuration.RoleAsCoordinator) { // server if (configuration.LocalUdpPortRangeStart == null) { throw new ArgumentException(nameof(configuration.LocalUdpPortRangeStart)); } } else if (configuration.RoleAsSharedPassive) { } else { throw new Exception("no roles"); } if (configuration.SocketsCount <= 0 || configuration.SocketsCount > 2000) { throw new ArgumentException(nameof(configuration.SocketsCount)); } ExtensionsById = configuration.Extensions.ToDictionary(ext => ext.ExtensionId, ext => ext); Initialize(); if (_instance != null) { throw new InvalidOperationException(); } _instance = this; }
public UserAppDatabase(ICryptoLibrary cryptoLibrary, IDatabaseKeyProvider keyProvider, VisionChannel visionChannel, string visionChannelSourceId, string basePathNullable) { _keyProvider = keyProvider; _cryptoLibrary = cryptoLibrary; _visionChannel = visionChannel; _visionChannelSourceId = visionChannelSourceId; if (basePathNullable == null) { basePathNullable = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); } var mainDatabaseFileName = Path.Combine(basePathNullable, "dcomms_main.db"); WriteToLog_deepDetail($"basePath={basePathNullable}, databaseFileName={mainDatabaseFileName}"); _db_main = new SQLiteConnection(mainDatabaseFileName); _db_main.CreateTable <User>(CreateFlags.None); _db_main.CreateTable <RootUserKeys>(CreateFlags.None); _db_main.CreateTable <UserRegistrationID>(CreateFlags.None); WriteToLog_deepDetail($"initialized sqlite database"); }
public SandboxTester1(VisionChannel visionChannel) { _visionChannel = visionChannel; }
public DrpTester4(VisionChannel visionChannel) { _visionChannel = visionChannel; }
public NatUtility(VisionChannel visionChannel, string visionChannelSourceId) { _visionChannel = visionChannel; _visionChannelSourceId = visionChannelSourceId; }
public DrpTester3(VisionChannel visionChannel) { _visionChannel = visionChannel; _visionChannel.VisiblePeersDelegate = () => { return(VisiblePeers.ToList()); }; RemoteEpEndPointsString = "192.99.160.225:12000;195.154.173.208:12000"; }
public DrpTester1(VisionChannel visionChannel, Action cb = null) { _visionChannel = visionChannel; _ep = new DrpPeerEngine(new DrpPeerEngineConfiguration { InsecureRandomSeed = _insecureRandom.Next(), LocalPort = EpLocalPort, VisionChannel = visionChannel, VisionChannelSourceId = "EP", ForcedPublicIpApiProviderResponse = IPAddress.Loopback, SandboxModeOnly_NumberOfDimensions = NumberOfDimensions }); var epLocalDrpPeerConfig = LocalDrpPeerConfiguration.Create(_ep.CryptoLibrary, NumberOfDimensions); _ep.BeginCreateLocalPeer(epLocalDrpPeerConfig, new DrpTesterPeerApp(_ep, epLocalDrpPeerConfig), (rpLocalPeer) => { _a = new DrpPeerEngine(new DrpPeerEngineConfiguration { InsecureRandomSeed = _insecureRandom.Next(), VisionChannel = visionChannel, ForcedPublicIpApiProviderResponse = IPAddress.Loopback, VisionChannelSourceId = "A", SandboxModeOnly_NumberOfDimensions = NumberOfDimensions }); var aLocalDrpPeerConfig = LocalDrpPeerConfiguration.Create(_a.CryptoLibrary, NumberOfDimensions); aLocalDrpPeerConfig.EntryPeerEndpoints = new[] { new IPEndPoint(IPAddress.Loopback, EpLocalPort) }; _x = new DrpPeerEngine(new DrpPeerEngineConfiguration { InsecureRandomSeed = _insecureRandom.Next(), VisionChannel = visionChannel, ForcedPublicIpApiProviderResponse = IPAddress.Loopback, VisionChannelSourceId = "X", SandboxModeOnly_NumberOfDimensions = NumberOfDimensions }); _retryx: var xLocalDrpPeerConfig = LocalDrpPeerConfiguration.Create(_x.CryptoLibrary, NumberOfDimensions); var distance_eptoa = epLocalDrpPeerConfig.LocalPeerRegistrationId.GetDistanceTo(_x.CryptoLibrary, aLocalDrpPeerConfig.LocalPeerRegistrationId, NumberOfDimensions); var distance_xtoa = xLocalDrpPeerConfig.LocalPeerRegistrationId.GetDistanceTo(_x.CryptoLibrary, aLocalDrpPeerConfig.LocalPeerRegistrationId, NumberOfDimensions); if (distance_xtoa.IsGreaterThan(distance_eptoa)) { goto _retryx; } xLocalDrpPeerConfig.EntryPeerEndpoints = new[] { new IPEndPoint(IPAddress.Loopback, EpLocalPort) }; _n = new DrpPeerEngine(new DrpPeerEngineConfiguration { InsecureRandomSeed = _insecureRandom.Next(), VisionChannel = visionChannel, ForcedPublicIpApiProviderResponse = IPAddress.Loopback, VisionChannelSourceId = "N", SandboxModeOnly_NumberOfDimensions = NumberOfDimensions }); _retryn: var nLocalDrpPeerConfig = LocalDrpPeerConfiguration.Create(_n.CryptoLibrary, NumberOfDimensions); var distance_ntoa = nLocalDrpPeerConfig.LocalPeerRegistrationId.GetDistanceTo(_n.CryptoLibrary, aLocalDrpPeerConfig.LocalPeerRegistrationId, NumberOfDimensions); if (distance_ntoa.IsGreaterThan(distance_xtoa)) { goto _retryn; } nLocalDrpPeerConfig.EntryPeerEndpoints = new[] { new IPEndPoint(IPAddress.Loopback, EpLocalPort) }; var distance_xton = xLocalDrpPeerConfig.LocalPeerRegistrationId.GetDistanceTo(_n.CryptoLibrary, nLocalDrpPeerConfig.LocalPeerRegistrationId, NumberOfDimensions); var distance_epton = epLocalDrpPeerConfig.LocalPeerRegistrationId.GetDistanceTo(_n.CryptoLibrary, nLocalDrpPeerConfig.LocalPeerRegistrationId, NumberOfDimensions); if (distance_xton.IsGreaterThan(distance_epton)) { goto _retryn; } _xUser = new DrpTesterPeerApp(_x, xLocalDrpPeerConfig); var swX = Stopwatch.StartNew(); _x.BeginRegister(xLocalDrpPeerConfig, _xUser, (xLocalPeer) => { _visionChannel.Emit(_x.Configuration.VisionChannelSourceId, DrpTesterVisionChannelModuleName, AttentionLevel.guiActivity, $"registration complete in {(int)swX.Elapsed.TotalMilliseconds}ms"); _xLocalDrpPeer = xLocalPeer; var swN = Stopwatch.StartNew(); _n.BeginRegister(nLocalDrpPeerConfig, new DrpTesterPeerApp(_n, nLocalDrpPeerConfig), (nLocalPeer) => { _visionChannel.Emit(_n.Configuration.VisionChannelSourceId, DrpTesterVisionChannelModuleName, AttentionLevel.guiActivity, $"registration complete in {(int)swN.Elapsed.TotalMilliseconds}ms"); _nLocalDrpPeer = nLocalPeer; _aUser = new DrpTesterPeerApp(_a, aLocalDrpPeerConfig); var swA = Stopwatch.StartNew(); _a.BeginRegister(aLocalDrpPeerConfig, _aUser, (aLocalPeer) => { _visionChannel.Emit(_a.Configuration.VisionChannelSourceId, DrpTesterVisionChannelModuleName, AttentionLevel.guiActivity, $"registration complete in {(int)swA.Elapsed.TotalMilliseconds}ms"); _aLocalDrpPeer = aLocalPeer; if (cb != null) { cb(); } }); }); }); }); }