Java 类net.minecraft.network.packet.Packet252SharedKey 实例源码

项目:RuneCraftery    文件:NetClientHandler.java   
public void handleServerAuthData(Packet253ServerAuthData par1Packet253ServerAuthData)
{
    String s = par1Packet253ServerAuthData.getServerId().trim();
    PublicKey publickey = par1Packet253ServerAuthData.getPublicKey();
    SecretKey secretkey = CryptManager.createNewSharedKey();

    if (!"-".equals(s))
    {
        String s1 = (new BigInteger(CryptManager.getServerIdHash(s, publickey, secretkey))).toString(16);
        String s2 = this.sendSessionRequest(this.mc.getSession().getUsername(), this.mc.getSession().getSessionID(), s1);

        if (!"ok".equalsIgnoreCase(s2))
        {
            this.netManager.networkShutdown("disconnect.loginFailedInfo", new Object[] {s2});
            return;
        }
    }

    this.addToSendQueue(new Packet252SharedKey(secretkey, publickey, par1Packet253ServerAuthData.getVerifyToken()));
}
项目:BetterNutritionMod    文件:NetClientHandler.java   
public void handleServerAuthData(Packet253ServerAuthData par1Packet253ServerAuthData)
{
    String s = par1Packet253ServerAuthData.getServerId().trim();
    PublicKey publickey = par1Packet253ServerAuthData.getPublicKey();
    SecretKey secretkey = CryptManager.createNewSharedKey();

    if (!"-".equals(s))
    {
        String s1 = (new BigInteger(CryptManager.getServerIdHash(s, publickey, secretkey))).toString(16);
        String s2 = this.sendSessionRequest(this.mc.getSession().getUsername(), this.mc.getSession().getSessionID(), s1);

        if (!"ok".equalsIgnoreCase(s2))
        {
            this.netManager.networkShutdown("disconnect.loginFailedInfo", new Object[] {s2});
            return;
        }
    }

    this.addToSendQueue(new Packet252SharedKey(secretkey, publickey, par1Packet253ServerAuthData.getVerifyToken()));
}
项目:RuneCraftery    文件:TcpConnection.java   
private boolean func_74447_i() {
   boolean var1 = false;

   try {
      Packet var2 = Packet.func_73272_a(this.field_98215_i, this.field_74477_k, this.field_74485_r.func_72489_a(), this.field_74479_i);
      if(var2 != null) {
         if(var2 instanceof Packet252SharedKey && !this.field_74465_f) {
            if(this.field_74485_r.func_72489_a()) {
               this.field_74488_z = ((Packet252SharedKey)var2).func_73303_a(this.field_74463_A);
            }

            this.func_74448_j();
         }

         int[] var10000 = field_74470_c;
         int var10001 = var2.func_73281_k();
         var10000[var10001] += var2.func_73284_a() + 1;
         if(!this.field_74484_s) {
            if(var2.func_73277_a_() && this.field_74485_r.func_72469_b()) {
               this.field_74490_x = 0;
               var2.func_73279_a(this.field_74485_r);
            } else {
               this.field_74473_o.add(var2);
            }
         }

         var1 = true;
      } else {
         this.func_74424_a("disconnect.endOfStream", new Object[0]);
      }

      return var1;
   } catch (Exception var3) {
      if(!this.field_74472_n) {
         this.func_74455_a(var3);
      }

      return false;
   }
}
项目:RuneCraftery    文件:NetLoginHandler.java   
public void func_72513_a(Packet252SharedKey p_72513_1_) {
   PrivateKey var2 = this.field_72534_f.func_71250_E().getPrivate();
   this.field_72542_k = p_72513_1_.func_73303_a(var2);
   if(!Arrays.equals(this.field_72536_d, p_72513_1_.func_73302_b(var2))) {
      this.func_72527_a("Invalid client reply");
   }

   this.field_72538_b.func_74429_a(new Packet252SharedKey());
}
项目:RuneCraftery    文件:NetClientHandler.java   
public void func_72470_a(Packet253ServerAuthData p_72470_1_) {
   String var2 = p_72470_1_.func_73377_d().trim();
   PublicKey var3 = p_72470_1_.func_73376_f();
   SecretKey var4 = CryptManager.func_75890_a();
   if(!"-".equals(var2)) {
      String var5 = (new BigInteger(CryptManager.func_75895_a(var2, var3, var4))).toString(16);
      String var6 = this.func_72550_a(this.field_72563_h.func_110432_I().func_111285_a(), this.field_72563_h.func_110432_I().func_111286_b(), var5);
      if(!"ok".equalsIgnoreCase(var6)) {
         this.field_72555_g.func_74424_a("disconnect.loginFailedInfo", new Object[]{var6});
         return;
      }
   }

   this.func_72552_c(new Packet252SharedKey(var4, var3, p_72470_1_.func_73378_g()));
}
项目:RuneCraftery    文件:NetLoginHandler.java   
public void handleSharedKey(Packet252SharedKey par1Packet252SharedKey)
{
    PrivateKey privatekey = this.mcServer.getKeyPair().getPrivate();
    this.sharedKey = par1Packet252SharedKey.getSharedKey(privatekey);

    if (!Arrays.equals(this.verifyToken, par1Packet252SharedKey.getVerifyToken(privatekey)))
    {
        this.raiseErrorAndDisconnect("Invalid client reply");
    }

    this.myTCPConnection.addToSendQueue(new Packet252SharedKey());
}
项目:BetterNutritionMod    文件:NetLoginHandler.java   
public void handleSharedKey(Packet252SharedKey par1Packet252SharedKey)
{
    PrivateKey privatekey = this.mcServer.getKeyPair().getPrivate();
    this.sharedKey = par1Packet252SharedKey.getSharedKey(privatekey);

    if (!Arrays.equals(this.verifyToken, par1Packet252SharedKey.getVerifyToken(privatekey)))
    {
        this.raiseErrorAndDisconnect("Invalid client reply");
    }

    this.myTCPConnection.addToSendQueue(new Packet252SharedKey());
}
项目:forge_world_downloader    文件:WDLNetClientHandler.java   
@Override
public void handleSharedKey(Packet252SharedKey par1Packet252SharedKey)
{
    nch.handleSharedKey(par1Packet252SharedKey);

}
项目:RuneCraftery    文件:TcpConnection.java   
private boolean func_74459_h() {
   boolean var1 = false;

   try {
      Packet var2;
      int var10001;
      int[] var10000;
      if(this.field_74468_e == 0 || !this.field_74487_p.isEmpty() && MinecraftServer.func_130071_aq() - ((Packet)this.field_74487_p.get(0)).field_73295_m >= (long)this.field_74468_e) {
         var2 = this.func_74460_a(false);
         if(var2 != null) {
            Packet.func_73266_a(var2, this.field_74474_l);
            if(var2 instanceof Packet252SharedKey && !this.field_74466_g) {
               if(!this.field_74485_r.func_72489_a()) {
                  this.field_74488_z = ((Packet252SharedKey)var2).func_73304_d();
               }

               this.func_74446_k();
            }

            var10000 = field_74467_d;
            var10001 = var2.func_73281_k();
            var10000[var10001] += var2.func_73284_a() + 1;
            var1 = true;
         }
      }

      if(this.field_74464_B-- <= 0 && (this.field_74468_e == 0 || !this.field_74486_q.isEmpty() && MinecraftServer.func_130071_aq() - ((Packet)this.field_74486_q.get(0)).field_73295_m >= (long)this.field_74468_e)) {
         var2 = this.func_74460_a(true);
         if(var2 != null) {
            Packet.func_73266_a(var2, this.field_74474_l);
            var10000 = field_74467_d;
            var10001 = var2.func_73281_k();
            var10000[var10001] += var2.func_73284_a() + 1;
            this.field_74464_B = 0;
            var1 = true;
         }
      }

      return var1;
   } catch (Exception var3) {
      if(!this.field_74472_n) {
         this.func_74455_a(var3);
      }

      return false;
   }
}
项目:RuneCraftery    文件:NetHandler.java   
public void func_72513_a(Packet252SharedKey p_72513_1_) {
   this.func_72509_a(p_72513_1_);
}
项目:RuneCraftery    文件:NetClientHandler.java   
public void func_72513_a(Packet252SharedKey p_72513_1_) {
   this.func_72552_c(new Packet205ClientCommand(0));
}
项目:RuneCraftery    文件:TcpConnection.java   
/**
 * Sends a data packet if there is one to send, or sends a chunk data packet if there is one and the counter is up,
 * or does nothing.
 */
private boolean sendPacket()
{
    boolean flag = false;

    try
    {
        Packet packet;
        int i;
        int[] aint;

        if (this.field_74468_e == 0 || !this.dataPackets.isEmpty() && MinecraftServer.getSystemTimeMillis() - ((Packet)this.dataPackets.get(0)).creationTimeMillis >= (long)this.field_74468_e)
        {
            packet = this.func_74460_a(false);

            if (packet != null)
            {
                Packet.writePacket(packet, this.socketOutputStream);

                if (packet instanceof Packet252SharedKey && !this.isOutputEncrypted)
                {
                    if (!this.theNetHandler.isServerHandler())
                    {
                        this.sharedKeyForEncryption = ((Packet252SharedKey)packet).getSharedKey();
                    }

                    this.encryptOuputStream();
                }

                aint = field_74467_d;
                i = packet.getPacketId();
                aint[i] += packet.getPacketSize() + 1;
                flag = true;
            }
        }

        if (this.chunkDataPacketsDelay-- <= 0 && (this.field_74468_e == 0 || !this.chunkDataPackets.isEmpty() && MinecraftServer.getSystemTimeMillis() - ((Packet)this.chunkDataPackets.get(0)).creationTimeMillis >= (long)this.field_74468_e))
        {
            packet = this.func_74460_a(true);

            if (packet != null)
            {
                Packet.writePacket(packet, this.socketOutputStream);
                aint = field_74467_d;
                i = packet.getPacketId();
                aint[i] += packet.getPacketSize() + 1;
                this.chunkDataPacketsDelay = 0;
                flag = true;
            }
        }

        return flag;
    }
    catch (Exception exception)
    {
        if (!this.isTerminating)
        {
            this.onNetworkError(exception);
        }

        return false;
    }
}
项目:RuneCraftery    文件:TcpConnection.java   
/**
 * Reads a single packet from the input stream and adds it to the read queue. If no packet is read, it shuts down
 * the network.
 */
private boolean readPacket()
{
    boolean flag = false;

    try
    {
        Packet packet = Packet.readPacket(this.tcpConLogAgent, this.socketInputStream, this.theNetHandler.isServerHandler(), this.networkSocket);

        if (packet != null)
        {
            if (packet instanceof Packet252SharedKey && !this.isInputBeingDecrypted)
            {
                if (this.theNetHandler.isServerHandler())
                {
                    this.sharedKeyForEncryption = ((Packet252SharedKey)packet).getSharedKey(this.field_74463_A);
                }

                this.decryptInputStream();
            }

            int[] aint = field_74470_c;
            int i = packet.getPacketId();
            aint[i] += packet.getPacketSize() + 1;

            if (!this.isServerTerminating)
            {
                if (packet.canProcessAsync() && this.theNetHandler.canProcessPacketsAsync())
                {
                    this.field_74490_x = 0;
                    packet.processPacket(this.theNetHandler);
                }
                else
                {
                    this.readPackets.add(packet);
                }
            }

            flag = true;
        }
        else
        {
            this.networkShutdown("disconnect.endOfStream", new Object[0]);
        }

        return flag;
    }
    catch (Exception exception)
    {
        if (!this.isTerminating)
        {
            this.onNetworkError(exception);
        }

        return false;
    }
}
项目:RuneCraftery    文件:NetClientHandler.java   
public void handleSharedKey(Packet252SharedKey par1Packet252SharedKey)
{
    this.addToSendQueue(FMLNetworkHandler.getFMLFakeLoginPacket());
    this.addToSendQueue(new Packet205ClientCommand(0));
}
项目:BetterNutritionMod    文件:TcpConnection.java   
/**
 * Sends a data packet if there is one to send, or sends a chunk data packet if there is one and the counter is up,
 * or does nothing.
 */
private boolean sendPacket()
{
    boolean flag = false;

    try
    {
        Packet packet;
        int i;
        int[] aint;

        if (this.field_74468_e == 0 || !this.dataPackets.isEmpty() && MinecraftServer.getSystemTimeMillis() - ((Packet)this.dataPackets.get(0)).creationTimeMillis >= (long)this.field_74468_e)
        {
            packet = this.func_74460_a(false);

            if (packet != null)
            {
                Packet.writePacket(packet, this.socketOutputStream);

                if (packet instanceof Packet252SharedKey && !this.isOutputEncrypted)
                {
                    if (!this.theNetHandler.isServerHandler())
                    {
                        this.sharedKeyForEncryption = ((Packet252SharedKey)packet).getSharedKey();
                    }

                    this.encryptOuputStream();
                }

                aint = field_74467_d;
                i = packet.getPacketId();
                aint[i] += packet.getPacketSize() + 1;
                flag = true;
            }
        }

        if (this.chunkDataPacketsDelay-- <= 0 && (this.field_74468_e == 0 || !this.chunkDataPackets.isEmpty() && MinecraftServer.getSystemTimeMillis() - ((Packet)this.chunkDataPackets.get(0)).creationTimeMillis >= (long)this.field_74468_e))
        {
            packet = this.func_74460_a(true);

            if (packet != null)
            {
                Packet.writePacket(packet, this.socketOutputStream);
                aint = field_74467_d;
                i = packet.getPacketId();
                aint[i] += packet.getPacketSize() + 1;
                this.chunkDataPacketsDelay = 0;
                flag = true;
            }
        }

        return flag;
    }
    catch (Exception exception)
    {
        if (!this.isTerminating)
        {
            this.onNetworkError(exception);
        }

        return false;
    }
}
项目:BetterNutritionMod    文件:TcpConnection.java   
/**
 * Reads a single packet from the input stream and adds it to the read queue. If no packet is read, it shuts down
 * the network.
 */
private boolean readPacket()
{
    boolean flag = false;

    try
    {
        Packet packet = Packet.readPacket(this.tcpConLogAgent, this.socketInputStream, this.theNetHandler.isServerHandler(), this.networkSocket);

        if (packet != null)
        {
            if (packet instanceof Packet252SharedKey && !this.isInputBeingDecrypted)
            {
                if (this.theNetHandler.isServerHandler())
                {
                    this.sharedKeyForEncryption = ((Packet252SharedKey)packet).getSharedKey(this.field_74463_A);
                }

                this.decryptInputStream();
            }

            int[] aint = field_74470_c;
            int i = packet.getPacketId();
            aint[i] += packet.getPacketSize() + 1;

            if (!this.isServerTerminating)
            {
                if (packet.canProcessAsync() && this.theNetHandler.canProcessPacketsAsync())
                {
                    this.field_74490_x = 0;
                    packet.processPacket(this.theNetHandler);
                }
                else
                {
                    this.readPackets.add(packet);
                }
            }

            flag = true;
        }
        else
        {
            this.networkShutdown("disconnect.endOfStream", new Object[0]);
        }

        return flag;
    }
    catch (Exception exception)
    {
        if (!this.isTerminating)
        {
            this.onNetworkError(exception);
        }

        return false;
    }
}
项目:BetterNutritionMod    文件:NetClientHandler.java   
public void handleSharedKey(Packet252SharedKey par1Packet252SharedKey)
{
    this.addToSendQueue(FMLNetworkHandler.getFMLFakeLoginPacket());
    this.addToSendQueue(new Packet205ClientCommand(0));
}