Exemplo n.º 1
0
 public override int ReadPayload(MemoryStream stream, int length)
 {
     //Debug.Assert(length == NodeAddress.LEN + sizeof(short), "G2PacketD : supposed to read " + (NodeAddress.LEN + sizeof(short)) + " but has to read " + length);
     Node = NodeAddress.ReadNodeAddress(stream);
     length = (short)BinaryUtils.getVariableIntLE(stream, 2);
     return NodeAddress.LEN + 2;
 }
Exemplo n.º 2
0
        /** G2Peer will parse the packet itself to get the relevant info
         * **/
        public static G2Peer ParseG2Peer(G2PacketQH2 resultPacket)
        {
            NodeAddress node = getAddressFromQueryHit(resultPacket);

            if (node == null)
            {
                return(null);
            }
            string nickname = getNickFromQueryHit(resultPacket);
            GUID   g        = ((G2PacketGU)(resultPacket.getFirstChildPacket(G2PacketType.GU))).nodeGuid;
            G2Peer peer     = new G2Peer(node.ipv4.ToString(), BitConverter.ToString(g.bytes), node.port, nickname);

            peer.Browsable      = resultPacket.getFirstChildPacket(G2PacketType.BH) == null ? false : true;
            peer.Firewalled     = resultPacket.getFirstChildPacket(G2PacketType.FW) == null ? false : true;
            peer.VendorCode     = resultPacket.getStringFromChildType(G2PacketType.V);
            peer.DNSName        = resultPacket.getStringFromChildType(G2PacketType.DNS);
            peer.AlternatePeers = getAlternateLocationsFromQueryHit(resultPacket);

            return(peer);
        }
Exemplo n.º 3
0
 public G2PacketD(NodeAddress n,short leafC)
 {
     this.Node = n;
     this.leafCount = leafC;
 }
Exemplo n.º 4
0
        public override int ReadPayload(MemoryStream stream, int length)
        {
            int timestampLength = (int)(length - NodeAddress.LEN);
            //Debug.Assert(timestampLength == 4 || timestampLength == 0, "G2PacketS  : timestamp 0 or 4 bytes but here has to read " + timestampLength);
            Node = NodeAddress.ReadNodeAddress(stream);
            if (timestampLength == 4)
            {
                Timestamp = (int)BinaryUtils.getVariableIntLE(stream, timestampLength);
            }

            return length;
        }
Exemplo n.º 5
0
 public G2PacketS(Header h)
     : base(h)
 {
     this.type = G2PacketType.S;
     Node = null;
     Timestamp = -1;
 }
Exemplo n.º 6
0
 public G2PacketD(Header h)
     : base(h)
 {
     this.type = G2PacketType.D;
     Node = null;
 }
Exemplo n.º 7
0
        public static G2PacketLNI SmartLNIPacket()
        {
            G2PacketLNI root = new G2PacketLNI();
            G2PacketGU guid = new G2PacketGU(GUID.generateGuid());
            root.AddChild(guid);

            NodeAddress self = new NodeAddress(G2Network.Instance.SelfAddress, G2Network.Instance.SelfPort);
            G2PacketNA na = new G2PacketNA(self);
            root.AddChild(na);

            G2PacketV v = new G2PacketV ("RAZA");
            root.AddChild (v);

            root.FinalizePacket();
            return root;
        }
Exemplo n.º 8
0
 public override int ReadPayload(System.IO.MemoryStream stream, int length)
 {
     //Debug.Assert(NodeAddress.LEN == length, "G2PacketUDP supposed to read " + NodeAddress.LEN + " but has to read " + length);
     EndPoint = NodeAddress.ReadNodeAddress (stream);
     return 6;
 }
Exemplo n.º 9
0
 public G2PacketUDP(NodeAddress addr)
     : base()
 {
     EndPoint = addr;
 }
Exemplo n.º 10
0
 /**
  * Constructor used by browse search , not registered in the cache
  * */
 public NodePeer(NodeAddress addr, bool isHub_)
 {
     Initialize(addr.ipv4, addr.port);
     lastSeen_  = DateTime.Now;
     this.isHub = isHub_;
 }
Exemplo n.º 11
0
 public G2PacketSNA(NodeAddress a)
     : base(a)
 {
     this.type = G2PacketType.SNA;
 }
Exemplo n.º 12
0
 public override int ReadPayload(MemoryStream stream, int length)
 {
     //Debug.Assert(NodeAddress.LEN == length, "G2PacketNA supposed to read " + NodeAddress.LEN + " but have to read " + length);
     node = NodeAddress.ReadNodeAddress(stream);
     if (node == null) return 0;
     return NodeAddress.LEN;
 }
Exemplo n.º 13
0
 public G2PacketNA(NodeAddress n)
     : base()
 {
     type = G2PacketType.NA;
     node = n;
 }
Exemplo n.º 14
0
 public G2PacketNA(Header h)
     : base(h)
 {
     type = G2PacketType.NA;
     node = null;
 }