Package net.md_5.bungee.api

Examples of net.md_5.bungee.api.ServerPing$Protocol


              if(socket != null){
                socket.dispose();
              }
            }
            byte[] buffer = socket.receive(p.getSessionID(), currUserCount);
            Protocol result = Protocol.fromBytes(buffer,socket.isRights(),socket.getDESKey());
            if (this.state == ServerState.Testing) {
                relive();
            }
            return result;
        } catch (IOException ex) {
View Full Code Here


         
        //----发送客户端公钥去服务器端、并获取服务器端公钥--start---------------------
        SecureKey sk = new SecureKey();//生成客户端公/私 钥     
        ServiceProxy proxy = ServiceProxy.getProxy(serviceConfig.getServicename());
        HandclaspProtocol handclaspProtocol = new HandclaspProtocol("1",sk.getStringPublicKey());
        Protocol publicKeyProtocol = proxy.createProtocol(handclaspProtocol);
         
        try {
          scoket.registerRec(publicKeyProtocol.getSessionID());
          scoket.send(publicKeyProtocol.toBytes());//过程2
          logger.info("send client publicKey sucess!");
        } finally {
          //scoket.dispose();
        }
           
        handclaspProtocol = null;
        /**
        * 过程3,接收服务器端生成公钥
        */
        byte[] receivePublicBuffer = scoket.receive(publicKeyProtocol.getSessionID(), server.getCurrUserCount());
        if(null == receivePublicBuffer){
          logger.warn("获取服务器公钥失败!");
            return false;
        }
           
        Protocol serverPublicProtocol = publicKeyProtocol.fromBytes(receivePublicBuffer);
        HandclaspProtocol _handclaspProtocol = null;
           
        if (serverPublicProtocol.getSDPType() == SDPType.Handclasp) {
          _handclaspProtocol = (HandclaspProtocol)serverPublicProtocol.getSdpEntity();
            logger.debug("get server publicKey time:" + (System.currentTimeMillis() - startTime) + "ms");
               
        } else if (serverPublicProtocol.getSDPType() == SDPType.Exception) {
            ExceptionProtocol ep = (ExceptionProtocol)serverPublicProtocol.getSdpEntity();
            throw ThrowErrorHelper.throwServiceError(ep.getErrorCode(), ep.getErrorMsg());
        } else if(serverPublicProtocol.getSDPType() == SDPType.Reset){
          throw new RebootException("this server is reboot!");
        } else {
            throw new Exception("userdatatype error!");
        }
           
        logger.info("receive server publicKey sucess!");
        publicKeyProtocol = null;
           
        String keyInfo = serviceConfig.getSecureKey().getInfo();//授权文件
        if(null == keyInfo || "".equals(keyInfo)){
          logger.warn("获取授权文件失败!");
           return false;
        }
           
        String ciphertext = sk.encryptByPublicKeyString(keyInfo, _handclaspProtocol.getData());
        _handclaspProtocol = null;
        serverPublicProtocol = null;
        //----发送客户端公钥去服务器端、并获取服务器端公钥--end---------------------
        //---发送授权文件到服务器端认证--------------------start-------------------------------
        HandclaspProtocol handclaspProtocol_ = new HandclaspProtocol("2",ciphertext);
        Protocol protocol_mw = proxy.createProtocol(handclaspProtocol_);
         
        try {
          scoket.registerRec(protocol_mw.getSessionID());
          scoket.send(protocol_mw.toBytes());//过程4
          logger.info("send keyInfo sucess!");
        } finally {
            //scoket.dispose();
        }
           
        handclaspProtocol_ = null;
        /**
         * 过程5
         * 获取由客户端公钥加密后的DES密钥
         */
        byte [] receiveDESKey = scoket.receive(protocol_mw.getSessionID(), server.getCurrUserCount());
        if(null == receiveDESKey){
          logger.warn("获取DES密钥失败!");
          return false;
        }
        logger.info("receive DESKey sucess!");
          
        HandclaspProtocol handclaspProtocol_mw = null;
        Protocol serverDesKeyProtocol = Protocol.fromBytes(receiveDESKey);
        if (serverDesKeyProtocol.getSDPType() == SDPType.Handclasp) {
          handclaspProtocol_mw = (HandclaspProtocol)serverDesKeyProtocol.getSdpEntity();
        } else if (serverDesKeyProtocol.getSDPType() == SDPType.Exception) {
          ExceptionProtocol ep = (ExceptionProtocol)serverDesKeyProtocol.getSdpEntity();
            throw ThrowErrorHelper.throwServiceError(ep.getErrorCode(), ep.getErrorMsg());
        } else if(serverDesKeyProtocol.getSDPType() == SDPType.Reset){
          throw new RebootException("this server is reboot!");
        } else {
          throw new Exception("userdatatype error!");
        }
       
View Full Code Here

      }
     
      if(desKeyStr != null){
        desKeyByte = desKeyStr.getBytes("utf-8");
      }
      Protocol protocol = Protocol.fromBytes(context.getGaeaRequest().getRequestBuffer(),global.getGlobalSecureIsRights(),desKeyByte);
      context.getGaeaRequest().setProtocol(protocol);
      /**
       * 服务重启直接返回
       */ 
      if(Global.getSingleton().getServerState() == ServerStateType.Reboot && protocol.getPlatformType() == PlatformType.Java){
        GaeaResponse response = new GaeaResponse();
        ResetProtocol rp = new ResetProtocol();
        rp.setMsg("This server is reboot!");
        protocol.setSdpEntity(rp);
        response.setResponseBuffer(protocol.toBytes(global.getGlobalSecureIsRights(),desKeyByte));
        context.setGaeaResponse(response);
        context.setExecFilter(ExecFilterType.None);
        context.setDoInvoke(false);
      }
    }
View Full Code Here

        GaeaContext gaeaContext = new GaeaContext();
        gaeaContext.setServerType(ServerType.HTTP);
        gaeaContext.setServerHandler(this);
        gaeaContext.setChannel(new GaeaChannel(e.getChannel()));
      /**协议*/
      Protocol protocol = new Protocol();
      RequestProtocol request = new RequestProtocol();
      request.setLookup(action.getLookup());
      request.setMethodName(action.getMethodName());
      request.setParaKVList(paraKVList);
      protocol.setSdpEntity(request);
      gaeaContext.getGaeaRequest().setProtocol(protocol);
      /**HttpContext 上下文*/
      com.bj58.spat.gaea.server.contract.http.HttpContext httpcontext = new com.bj58.spat.gaea.server.contract.http.HttpContext();
      com.bj58.spat.gaea.server.contract.http.HttpRequest httpRequest = new com.bj58.spat.gaea.server.contract.http.HttpRequest();
      httpRequest.setContent(httpContext.getContentBuffer());
View Full Code Here

                c = message.charAt( i );
                if ( c >= 'A' && c <= 'Z' )
                {
                    c += 32;
                }
                ChatColor format = ChatColor.getByChar( c );
                if ( format == null )
                {
                    continue;
                }
                if ( builder.length() > 0 )
View Full Code Here

    }

    @Override
    public void handle(LegacyPing ping) throws Exception
    {
        ServerPing legacy = new ServerPing( new ServerPing.Protocol( bungee.getName() + " " + bungee.getGameVersion(), bungee.getProtocolVersion() ),
                new ServerPing.Players( listener.getMaxPlayers(), bungee.getOnlineCount(), null ), listener.getMotd(), (Favicon) null );

        Callback<ProxyPingEvent> callback = new Callback<ProxyPingEvent>()
        {
            @Override
            public void done(ProxyPingEvent result, Throwable error)
            {
                if ( ch.isClosed() )
                {
                    return;
                }

                ServerPing ping = result.getResponse();

                String kickMessage = ChatColor.DARK_BLUE
                        + "\00" + 127
                        + "\00" + ping.getVersion().getName()
                        + "\00" + ping.getDescription()
                        + "\00" + ping.getPlayers().getOnline()
                        + "\00" + ping.getPlayers().getMax();

                ch.getHandle().writeAndFlush( kickMessage );
                ch.close();
            }
        };
View Full Code Here

            @Override
            public void done(ServerPing result, Throwable error)
            {
                if ( error != null )
                {
                    result = new ServerPing();
                    result.setDescription( bungee.getTranslation( "ping_cannot_connect" ) );
                    bungee.getLogger().log( Level.WARNING, "Error pinging remote server", error );
                }

                Callback<ProxyPingEvent> callback = new Callback<ProxyPingEvent>()
                {
                    @Override
                    public void done(ProxyPingEvent pingResult, Throwable error)
                    {
                        BungeeCord.getInstance().getConnectionThrottle().unthrottle( getAddress().getAddress() );
                        Gson gson = handshake.getProtocolVersion() == ProtocolConstants.MINECRAFT_1_7_2 ? BungeeCord.getInstance().gsonLegacy : BungeeCord.getInstance().gson;
                        unsafe.sendPacket( new StatusResponse( gson.toJson( pingResult.getResponse() ) ) );
                    }
                };

                bungee.getPluginManager().callEvent( new ProxyPingEvent( InitialHandler.this, result, callback ) );
            }
        };

        if ( forced != null && listener.isPingPassthrough() )
        {
            ( (BungeeServerInfo) forced ).ping( pingBack, handshake.getProtocolVersion() );
        } else
        {
            int protocol = ( Protocol.supportedVersions.contains( handshake.getProtocolVersion() ) ) ? handshake.getProtocolVersion() : bungee.getProtocolVersion();
            pingBack.done( new ServerPing(
                    new ServerPing.Protocol( bungee.getName() + " " + bungee.getGameVersion(), protocol ),
                    new ServerPing.Players( listener.getMaxPlayers(), bungee.getOnlineCount(), null ),
                    motd, BungeeCord.getInstance().config.getFaviconObject() ),
                    null );
        }
View Full Code Here

                    int count = server.getPlayers().size();
                    serverTextComponent.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT,
                            new ComponentBuilder( count + ( count == 1 ? " player" : " players" ) + "\n" )
                            .append( "Click to connect to the server" ).italic( true )
                            .create() ) );
                    serverTextComponent.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, "/server " + server.getName() ) );
                    serverList.addExtra( serverTextComponent );
                    first = false;
                }
            }
            player.sendMessage( serverList );
View Full Code Here

        //Events
        if ( object.has( "clickEvent" ) )
        {
            JsonObject event = object.getAsJsonObject( "clickEvent" );
            component.setClickEvent( new ClickEvent(
                    ClickEvent.Action.valueOf( event.get( "action" ).getAsString().toUpperCase() ),
                    event.get( "value" ).getAsString() ) );
        }
        if ( object.has( "hoverEvent" ) )
        {
View Full Code Here

                if ( server.canAccess( player ) )
                {
                    TextComponent serverTextComponent = new TextComponent( first ? server.getName() : ", " + server.getName() );
                    int count = server.getPlayers().size();
                    serverTextComponent.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT,
                            new ComponentBuilder( count + ( count == 1 ? " player" : " players" ) + "\n" )
                            .append( "Click to connect to the server" ).italic( true )
                            .create() ) );
                    serverTextComponent.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, "/server " + server.getName() ) );
                    serverList.addExtra( serverTextComponent );
                    first = false;
View Full Code Here

TOP

Related Classes of net.md_5.bungee.api.ServerPing$Protocol

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.