Example #1
0
        private void AddtoArrays(double[] inBytes, double[] outBytes, BandwidthLog bandwidth)
        {
            for (int i = 0; i < bandwidth.In.Length; i++)
                inBytes[i] += bandwidth.In[i];

            for (int i = 0; i < bandwidth.Out.Length; i++)
                outBytes[i] += bandwidth.Out[i];
        }
Example #2
0
        // inbound
        public TcpConnect(TcpHandler control)
        {
            TcpControl = control;
            Network    = TcpControl.Network;
            Core       = TcpControl.Core;

            Bandwidth = new BandwidthLog(Core.RecordBandwidthSeconds);
        }
Example #3
0
        public UdpHandler(DhtNetwork network)
        {
            Network = network;
            Core    = network.Core;

            Bandwidth = new BandwidthLog(Core.RecordBandwidthSeconds);

            Initialize();
        }
Example #4
0
        public UdpHandler(DhtNetwork network)
        {
            Network = network;
            Core = network.Core;

            Bandwidth = new BandwidthLog(Core.RecordBandwidthSeconds);

            Initialize();
        }
Example #5
0
        private void AddtoArrays(double[] inBytes, double[] outBytes, BandwidthLog bandwidth)
        {
            for (int i = 0; i < bandwidth.In.Length; i++)
            {
                inBytes[i] += bandwidth.In[i];
            }

            for (int i = 0; i < bandwidth.Out.Length; i++)
            {
                outBytes[i] += bandwidth.Out[i];
            }
        }
Example #6
0
        public RudpSocket(RudpSession session, bool listening)
        {
            Session = session;
            Core    = session.Core;
            Network = Session.Network;

            Bandwidth = new BandwidthLog(Core.RecordBandwidthSeconds);

            Listening = listening;

            PeerID = (ushort)Core.RndGen.Next(1, ushort.MaxValue);

            lock (Session.RudpControl.SocketMap)
                Session.RudpControl.SocketMap[PeerID] = this;
        }
Example #7
0
        // outbound
        public TcpConnect(TcpHandler control, DhtAddress address, ushort tcpPort)
        {
            Debug.Assert(address.UserID != 0);

            TcpControl = control;
            Network    = TcpControl.Network;
            Core       = TcpControl.Core;

            Bandwidth = new BandwidthLog(Core.RecordBandwidthSeconds);

            Outbound = true;

            RemoteIP = address.IP;
            TcpPort  = tcpPort;
            UdpPort  = address.UdpPort;
            UserID   = address.UserID;

            try
            {
                IPEndPoint endpoint = new IPEndPoint(RemoteIP, TcpPort);

                if (Core.Sim != null)
                {
                    Core.Sim.Internet.SendPacket(SimPacketType.TcpConnect, Network, null, endpoint, this);
                    return;
                }

                TcpSocket = new Socket(address.IP.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
                TcpSocket.BeginConnect((EndPoint)endpoint, new AsyncCallback(Socket_Connect), TcpSocket);
            }
            catch (Exception ex)
            {
                LogException("TcpSocket", ex.Message);
                Disconnect();
            }
        }
Example #8
0
        // outbound
        public TcpConnect(TcpHandler control, DhtAddress address, ushort tcpPort)
        {
            Debug.Assert(address.UserID != 0);

            TcpControl = control;
            Network = TcpControl.Network;
            Core = TcpControl.Core;

            Bandwidth = new BandwidthLog(Core.RecordBandwidthSeconds);

            Outbound = true;

            RemoteIP = address.IP;
            TcpPort  = tcpPort;
            UdpPort  = address.UdpPort;
            UserID    = address.UserID;

            try
            {
                IPEndPoint endpoint = new IPEndPoint(RemoteIP, TcpPort);

                if (Core.Sim != null)
                {
                    Core.Sim.Internet.SendPacket(SimPacketType.TcpConnect, Network, null, endpoint, this);
                    return;
                }

                TcpSocket = new Socket(address.IP.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
                TcpSocket.BeginConnect((EndPoint)endpoint, new AsyncCallback(Socket_Connect), TcpSocket);
            }
            catch (Exception ex)
            {
                LogException("TcpSocket", ex.Message);
                Disconnect();
            }
        }
Example #9
0
        // inbound
        public TcpConnect(TcpHandler control)
        {
            TcpControl = control;
            Network    = TcpControl.Network;
            Core       = TcpControl.Core;

            Bandwidth = new BandwidthLog(Core.RecordBandwidthSeconds);
        }
Example #10
0
File: OpCore.cs Project: swax/DeOps
        // initializing lookup network (from the settings of a loaded operation)
        public OpCore(DeOpsContext context)
        {
            Context = context;
            Sim = context.Sim;

            StartTime = TimeNow;
            GuiProtocol = new G2Protocol();

            Network = new DhtNetwork(this, true);

            // for each core, re-load the lookup cache items
            Context.Cores.LockReading(() =>
            {
                foreach (OpCore core in Context.Cores)
                    core.User.Load(LoadModeType.LookupCache);
            });

            ServiceBandwidth[DhtServiceID] = new BandwidthLog(RecordBandwidthSeconds);

            // get cache from all loaded cores
            AddService(new LookupService(this));

            if (Sim != null)
                Sim.Internet.RegisterAddress(this);

            CoreThread = new Thread(RunCore);
            CoreThread.Name = "Lookup Thread";

            if (Sim == null || Sim.Internet.TestCoreThread)
                CoreThread.Start();
        }
Example #11
0
File: OpCore.cs Project: swax/DeOps
        // initializing operation network
        public OpCore(DeOpsContext context, string userPath, string pass)
        {
            Context = context;
            Sim = context.Sim;

            StartTime = TimeNow;
            GuiProtocol = new G2Protocol();

            User = new OpUser(userPath, pass, this);
            User.Load(LoadModeType.Settings);

            Network = new DhtNetwork(this, false);

            TunnelID = (ushort)RndGen.Next(1, ushort.MaxValue);

            Test test = new Test(); // should be empty unless running a test

            User.Load(LoadModeType.AllCaches);

            // delete data dirs if frsh start indicated
            if (Sim != null && Sim.Internet.FreshStart)
                for (int service = 1; service < 20; service++ ) // 0 is temp folder, cleared on startup
                {
                    string dirpath = User.RootPath + Path.DirectorySeparatorChar + "Data" + Path.DirectorySeparatorChar + service.ToString();
                    if (Directory.Exists(dirpath))
                        Directory.Delete(dirpath, true);
                }

            if (Sim != null) KeyMax = 32;

            Context.KnownServices[DhtServiceID] = "Dht";
            ServiceBandwidth[DhtServiceID] = new BandwidthLog(RecordBandwidthSeconds);

            // permanent - order is important here
            AddService(new TransferService(this));
            AddService(new LocationService(this));
            AddService(new LocalSync(this));
            AddService(new BuddyService(this));
            AddService(new UpdateService(this));

            if (!User.Settings.GlobalIM)
                AddService(new TrustService(this));

            // optional
            AddService(new IMService(this));
            AddService(new ChatService(this));
            AddService(new ShareService(this));

            if (Type.GetType("Mono.Runtime") == null)
                AddService(new VoiceService(this));

            if (!User.Settings.GlobalIM)
            {
                AddService(new ProfileService(this));
                AddService(new MailService(this));
                AddService(new BoardService(this));
                AddService(new PlanService(this));
                AddService(new StorageService(this));
            }

            if (Sim != null)
                Sim.Internet.RegisterAddress(this);

            CoreThread = new Thread(RunCore);
            CoreThread.Name = User.Settings.Operation + " Thread";

            if (Sim == null || Sim.Internet.TestCoreThread)
                CoreThread.Start();

            #if DEBUG
            DebugWindowsActive = true;
            #endif
        }
Example #12
0
        public RudpSocket(RudpSession session, bool listening)
        {
            Session = session;
            Core = session.Core;
            Network = Session.Network;

            Bandwidth = new BandwidthLog(Core.RecordBandwidthSeconds);

            Listening = listening;

            PeerID = (ushort)Core.RndGen.Next(1, ushort.MaxValue);

            lock (Session.RudpControl.SocketMap)
                Session.RudpControl.SocketMap[PeerID] = this;
        }