SendPacket() public method

public SendPacket ( DeOps.Implementation.Protocol.G2Packet packet ) : int
packet DeOps.Implementation.Protocol.G2Packet
return int
Example #1
0
        public static int SendtoAddress(DhtNetwork network, RudpAddress target, RudpPacket packet)
        {
            Debug.Assert(packet.Payload != null || packet.PacketType == RudpPacketType.LightAck);

            int sentBytes = 0;

            // same code used in rudpSocket
            if (network.Core.Firewall != FirewallType.Blocked && target.LocalProxy == null)
            {
                sentBytes = network.SendPacket(target.Address, packet);
            }

            else if (target.Address.TunnelClient != null)
            {
                sentBytes = network.SendTunnelPacket(target.Address, packet);
            }

            else
            {
                packet.ToAddress = target.Address;

                TcpConnect proxy = network.TcpControl.GetProxy(target.LocalProxy);

                if (proxy != null)
                {
                    sentBytes = proxy.SendPacket(packet);
                }
                else
                {
                    sentBytes = network.TcpControl.SendRandomProxy(packet);
                }
            }

            return(sentBytes);
        }
Example #2
0
        public void SendPacket(RudpPacket packet, RudpAddress target)
        {
            Debug.Assert(packet.Payload != null);

            // sending syn  to (tracked target) through (address target) udp / tcp

            /*string log = "Sending " + tracked.Packet.PacketType.ToString();
             * if (tracked.Packet.Ident != 0) log  += ", ID " + tracked.Packet.Ident.ToString();
             * log +=  " to " + Utilities.IDtoBin(tracked.Packet.TargetID).Substring(0, 10);
             * log += " target address " + target.Address.ToString();*/

            int sentBytes = 0;

            // same code used in lightComm
            if (Core.Firewall != FirewallType.Blocked && target.LocalProxy == null)
            {
                sentBytes = Network.SendPacket(target.Address, packet);
            }

            else if (target.Address.TunnelClient != null)
            {
                sentBytes = Network.SendTunnelPacket(target.Address, packet);
            }

            else
            {
                packet.ToAddress = target.Address;

                TcpConnect proxy = Network.TcpControl.GetProxy(target.LocalProxy);

                if (proxy != null)
                {
                    sentBytes = proxy.SendPacket(packet);
                }
                else
                {
                    sentBytes = Network.TcpControl.SendRandomProxy(packet);
                }

                //log += " proxied by local tcp";
            }

            Bandwidth.OutPerSec += sentBytes;

            //Session.Log(log);
        }
Example #3
0
        public int SendRandomProxy(G2Packet packet)
        {
            TcpConnect socket = GetRandomProxy();

            return((socket != null) ? socket.SendPacket(packet) : 0);
        }