public void peerHasPiece(PEPeer peer) {
   try {
     class_mon.enter();
     // System.out.println("piece: #"+pieceNumber+" , old level:"+level+",
     // timeFirstDistributed:"+timeFirstDistributed+ "/
     // timetoreachanotherpeer:"+timeToReachAnotherPeer);
     if (level < 2) {
       // first time that somebody tells us this piece exists elsewhere
       // if peer=null, it is due to bitfield scan, so firstreceiver gets NULL
       firstReceiver = peer;
       timeFirstDistributed = SystemTime.getCurrentTime();
       // numberOfPeersWhenFirstReceived = manager.getNbPeers();
       level = 2;
     } else {
       // level=2 or 3 and we arrive here when somebody has got the piece, either BT_HAVE or
       // bitfield scan
       // if we are here due to bitfield scan, 'peer' = null --> do nothing
       // if level=2 --> mark piece redistributed, set speedstatus of firstreceiver, bump level to
       // 3
       // if level=3 --> this piece has been already seen at 3rd party earlier, do nothing
       if (peer != null && firstReceiver != null && level == 2) {
         timeToReachAnotherPeer = (int) (SystemTime.getCurrentTime() - timeFirstDistributed);
         firstReceiver.setUploadHint(timeToReachAnotherPeer);
         level = 3;
       }
     }
   } finally {
     class_mon.exit();
   }
 }
  /**
   * Perform the actual version check by connecting to the version server.
   *
   * @param data_to_send version message
   * @return version reply
   * @throws Exception if the server check connection fails
   */
  private Map performVersionCheck(
      Map data_to_send, boolean use_az_message, boolean use_http, boolean v6) throws Exception {
    Exception error = null;
    Map reply = null;

    if (use_http) {

      try {
        reply = executeHTTP(data_to_send, v6);

        reply.put("protocol_used", "HTTP");

        error = null;
      } catch (IOException e) {
        error = e;
      } catch (Exception e) {
        Debug.printStackTrace(e);
        error = e;
      }
    }

    if (reply == null && use_az_message) {

      try {
        reply = executeAZMessage(data_to_send, v6);

        reply.put("protocol_used", "AZMSG");
      } catch (IOException e) {
        error = e;
      } catch (Exception e) {
        Debug.printStackTrace(e);
        error = e;
      }
    }
    if (error != null) {

      throw (error);
    }

    if (Logger.isEnabled())
      Logger.log(
          new LogEvent(
              LOGID,
              "VersionCheckClient server "
                  + "version check successful. Received "
                  + reply.size()
                  + " reply keys."));

    if (v6) {

      last_check_time_v6 = SystemTime.getCurrentTime();

    } else {

      last_check_time_v4 = SystemTime.getCurrentTime();
    }

    return reply;
  }
  public static boolean hasFullLicence() {
    if (featman == null) {
      // Debug.out("featman null");
      Set<String> featuresInstalled = UtilitiesImpl.getFeaturesInstalled();
      return featuresInstalled.contains("dvdburn");
    }

    boolean full = false;
    FeatureDetails[] featureDetails = featman.getFeatureDetails("dvdburn");
    // if any of the feature details are still valid, we have a full
    for (FeatureDetails fd : featureDetails) {
      int state = fd.getLicence().getState();
      if (state == Licence.LS_CANCELLED || state == Licence.LS_REVOKED) {
        continue;
      }
      long now = SystemTime.getCurrentTime();
      Long lValidUntil = (Long) fd.getProperty(FeatureDetails.PR_VALID_UNTIL);
      if (lValidUntil != null && lValidUntil.longValue() >= now) {
        full = true;
        break;
      }
      Long lValidOfflineUntil = (Long) fd.getProperty(FeatureDetails.PR_OFFLINE_VALID_UNTIL);
      if (lValidOfflineUntil != null && lValidOfflineUntil.longValue() >= now) {
        full = true;
        break;
      }
    }

    return full;
  }
Example #4
0
  /**
   * Prints out the given debug message to System.out, prefixed by the calling class name, method
   * and line number, appending the stacktrace of the given exception.
   */
  public static void out(final String _debug_msg, final Throwable _exception) {
    String header = "DEBUG::";
    header = header + new Date(SystemTime.getCurrentTime()).toString() + "::";
    String className;
    String methodName;
    int lineNumber;
    String trace_trace_tail = null;

    try {
      throw new Exception();
    } catch (Exception e) {
      StackTraceElement[] st = e.getStackTrace();

      StackTraceElement first_line = st[2];
      className = first_line.getClassName() + "::";
      methodName = first_line.getMethodName() + "::";
      lineNumber = first_line.getLineNumber();

      trace_trace_tail = getCompressedStackTrace(e, 3, 200, false);
    }

    diagLoggerLogAndOut(header + className + (methodName) + lineNumber + ":", true);
    if (_debug_msg.length() > 0) {
      diagLoggerLogAndOut("  " + _debug_msg, true);
    }
    if (trace_trace_tail != null) {
      diagLoggerLogAndOut("    " + trace_trace_tail, true);
    }
    if (_exception != null) {
      diagLoggerLogAndOut(_exception);
    }
  }
Example #5
0
  public void alive() {
    last_seen = SystemTime.getCurrentTime();

    if (!online) {

      online = true;

      setDirty(false);
    }
  }
  public static void openStreamPlusWindow(final String referal) {
    String msgidPrefix;
    String buttonID;
    long plusExpiryTimeStamp = FeatureManagerUI.getPlusExpiryTimeStamp();
    if (plusExpiryTimeStamp < 0 || plusExpiryTimeStamp >= SystemTime.getCurrentTime()) {
      msgidPrefix = "dlg.stream.plus.";
      buttonID = "Button.upgrade";
    } else {
      buttonID = "Button.renew";
      msgidPrefix = "dlg.stream.plus.renew.";
      if (!MessageText.keyExistsForDefaultLocale(msgidPrefix + "text")) {
        msgidPrefix = "dlg.stream.plus.";
      }
    }
    final String f_msgidPrefix = msgidPrefix;
    final VuzeMessageBox box =
        new VuzeMessageBox(
            MessageText.getString(msgidPrefix + "title"),
            MessageText.getString(msgidPrefix + "text"),
            new String[] {
              MessageText.getString(buttonID), MessageText.getString("Button.cancel"),
            },
            0);
    box.setButtonVals(new Integer[] {BUTTON_UPGRADE, SWT.CANCEL});

    box.setSubTitle(MessageText.getString(msgidPrefix + "subtitle"));
    box.addResourceBundle(
        FeatureManagerUI.class, SkinPropertiesImpl.PATH_SKIN_DEFS, "skin3_dlg_streamplus");
    box.setIconResource("image.header.streamplus");

    box.setListener(
        new VuzeMessageBoxListener() {
          public void shellReady(Shell shell, SWTSkinObjectContainer soExtra) {
            SWTSkin skin = soExtra.getSkin();
            skin.createSkinObject("dlg.stream.plus", "dlg.stream.plus", soExtra);
            SWTSkinObject soSubText = skin.getSkinObject("trial-info", soExtra);
            if (soSubText instanceof SWTSkinObjectText) {
              ((SWTSkinObjectText) soSubText).setTextID(f_msgidPrefix + "subtext");
            }
          }
        });

    box.open(
        new UserPrompterResultListener() {
          public void prompterClosed(int result) {
            if (result == BUTTON_UPGRADE) {
              SBC_PlusFTUX.setSourceRef("dlg-stream" + (referal == null ? "" : "-" + referal));

              MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
              mdi.showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_PLUS);
            }
          }
        });
  }
Example #7
0
  public static void printStackTrace(Throwable e, Object context) {
    String header = "DEBUG::";
    header = header + new Date(SystemTime.getCurrentTime()).toString() + "::";
    String className = "?::";
    String methodName = "?::";
    int lineNumber = -1;

    try {
      throw new Exception();
    } catch (Exception f) {
      StackTraceElement[] st = f.getStackTrace();

      for (int i = 1; i < st.length; i++) {
        StackTraceElement first_line = st[i];
        className = first_line.getClassName() + "::";
        methodName = first_line.getMethodName() + "::";
        lineNumber = first_line.getLineNumber();

        // skip stuff generated by the logger

        if (className.indexOf(".logging.") != -1 || className.endsWith(".Debug::")) {

          continue;
        }

        break;
      }
    }

    diagLoggerLogAndOut(header + className + (methodName) + lineNumber + ":", true);

    try {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();

      PrintWriter pw = new PrintWriter(new OutputStreamWriter(baos));

      if (context != null) {
        pw.print("  ");
        pw.println(context);
      }
      pw.print("  ");
      e.printStackTrace(pw);

      pw.close();

      String stack = baos.toString();

      diagLoggerLogAndOut(stack, true);
    } catch (Throwable ignore) {

      e.printStackTrace();
    }
  }
 public static boolean hasFullLicence() {
   if (featman == null) {
     // Debug.out("featman null");
     Set<String> featuresInstalled = UtilitiesImpl.getFeaturesInstalled();
     return featuresInstalled.contains("dvdburn");
   }
   licenceDetails fullFeatureDetails = getFullFeatureDetails();
   long now = SystemTime.getCurrentTime();
   return fullFeatureDetails != null
       && fullFeatureDetails.expiry > now
       && fullFeatureDetails.displayedExpiry > now;
 }
  public static licenceDetails getFullFeatureDetails() {
    if (featman == null) {
      Debug.out("featman null");
      return null;
    }

    FeatureDetails[] featureDetails = featman.getFeatureDetails("dvdburn");
    // if any of the feature details are still valid, we have a full
    for (FeatureDetails fd : featureDetails) {
      long now = SystemTime.getCurrentTime();
      Long lValidUntil = (Long) fd.getProperty(FeatureDetails.PR_VALID_UNTIL);
      if (lValidUntil != null && lValidUntil.longValue() >= now) {
        return new licenceDetails(
            lValidUntil.longValue(), fd.getLicence().getKey(), fd.getLicence().getState());
      }
      Long lValidOfflineUntil = (Long) fd.getProperty(FeatureDetails.PR_OFFLINE_VALID_UNTIL);
      if (lValidOfflineUntil != null && lValidOfflineUntil.longValue() >= now) {
        return new licenceDetails(
            lValidOfflineUntil.longValue(), fd.getLicence().getKey(), fd.getLicence().getState());
      }
    }

    Licence bestLicence = null;
    Licence[] licences = featman.getLicences();
    for (Licence licence : licences) {
      FeatureDetails[] details = licence.getFeatures();
      boolean isTrial = false;
      for (FeatureDetails fd : details) {
        Object property = fd.getProperty(FeatureDetails.PR_IS_TRIAL);
        if ((property instanceof Number) && ((Number) property).intValue() == 1) {
          isTrial = true;
          break;
        }
      }
      if (isTrial) {
        continue;
      }
      int state = licence.getState();
      if (state == Licence.LS_AUTHENTICATED) {
        bestLicence = licence;
        break;
      } else {
        bestLicence = licence;
      }
    }

    if (bestLicence != null) {
      return new licenceDetails(0, bestLicence.getKey(), bestLicence.getState());
    }

    return null;
  }
 public void updateTime() {
   if (level < 2)
     // not yet distributed, no effect on speed status
     return;
   if (timeToReachAnotherPeer > 0)
     // piece has been seen elsewhere, no effect on speed status any more
     return;
   if (firstReceiver == null)
     // piece was found due to bitfield scan, no idea how it got distributed
     return;
   int timeToSend = (int) (SystemTime.getCurrentTime() - timeFirstDistributed);
   if (timeToSend > firstReceiver.getUploadHint()) firstReceiver.setUploadHint(timeToSend);
 }
  public static String appendFeatureManagerURLParams(String url) {
    long remainingUses = FeatureManagerUI.getRemaining();
    long plusExpiryTimeStamp = FeatureManagerUI.getPlusExpiryDisplayTimeStamp();
    String plusRenewalCode = FeatureManagerUI.getPlusRenewalCode();

    String newURL = url + (url.contains("?") ? "&" : "?");
    newURL += "mode=" + FeatureManagerUI.getMode();
    if (plusExpiryTimeStamp != 0) {
      newURL += "&remaining_plus=" + (plusExpiryTimeStamp - SystemTime.getCurrentTime());
    }
    newURL += "&remaining=" + remainingUses;
    if (plusRenewalCode != null) {
      newURL += "&renewal_code=" + plusRenewalCode;
    }

    return newURL;
  }
 protected void accept_loop() {
   while (isRunning()) {
     try {
       SocketChannel client_channel = server_channel.accept();
       last_accept_time = SystemTime.getCurrentTime();
       client_channel.configureBlocking(false);
       listener.newConnectionAccepted(server_channel, client_channel);
     } catch (AsynchronousCloseException e) {
       /* is thrown when stop() is called */
     } catch (Throwable t) {
       Debug.out(t);
       try {
         Thread.sleep(500);
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   }
 }
  /** Start the server and begin accepting incoming connections. */
  public void start() {
    try {
      this_mon.enter();

      if (!isRunning()) {
        try {
          server_channel = ServerSocketChannel.open();

          server_channel.socket().setReuseAddress(true);
          if (receive_buffer_size > 0)
            server_channel.socket().setReceiveBufferSize(receive_buffer_size);

          server_channel.socket().bind(bind_address, 1024);

          if (Logger.isEnabled())
            Logger.log(new LogEvent(LOGID, "TCP incoming server socket " + bind_address));

          AEThread accept_thread =
              new AEThread("VServerSelector:port" + bind_address.getPort()) {
                public void runSupport() {
                  accept_loop();
                }
              };
          accept_thread.setDaemon(true);
          accept_thread.start();
        } catch (Throwable t) {
          Debug.out(t);
          Logger.log(
              new LogAlert(
                  LogAlert.UNREPEATABLE,
                  "ERROR, unable to bind TCP incoming server socket to " + bind_address.getPort(),
                  t));
        }

        last_accept_time = SystemTime.getCurrentTime(); // init to now
      }
    } finally {

      this_mon.exit();
    }
  }
  public long getFeatureFlags() {
    long now = SystemTime.getCurrentTime();

    if (now > last_feature_flag_cache_time && now - last_feature_flag_cache_time < 60000) {

      return (last_feature_flag_cache);
    }

    Map m = getMostRecentVersionCheckData();

    long result;

    if (m == null) {

      result = 0;

    } else {

      byte[] b_feat_flags = (byte[]) m.get("feat_flags");

      if (b_feat_flags != null) {

        try {

          result = Long.parseLong(new String((byte[]) b_feat_flags));

        } catch (Throwable e) {

          result = 0;
        }
      } else {

        result = 0;
      }
    }

    last_feature_flag_cache = result;
    last_feature_flag_cache_time = now;

    return (result);
  }
Example #15
0
  private static void updateMetaData_handleReply(
      TOTorrent torrent, String hash, String replyType, Map mapHashes) {
    if (hash == null && torrent != null) {
      try {
        hash = torrent.getHashWrapper().toBase32String();
      } catch (Exception e) {
      }
    }

    GlobalManager gm = AzureusCoreFactory.getSingleton().getGlobalManager();
    DownloadManager dm = gm.getDownloadManager(new HashWrapper(Base32.decode(hash)));

    if (torrent == null && dm != null) {
      torrent = dm.getTorrent();
    }
    Map contentMap = PlatformTorrentUtils.getContentMap(torrent);

    final TOTorrent torrentFinal = torrent;

    if (replyType.equals(PlatformMessenger.REPLY_EXCEPTION)) {
      if (torrent != null) {
        // try again in a bit
        log(torrent, "Exception, retrying later");
        SimpleTimer.addEvent(
            "Update MD Retry",
            SystemTime.getCurrentTime() + RETRY_METADATA,
            new TimerEventPerformer() {
              public void perform(TimerEvent event) {
                log(torrentFinal, "retry time");
                PlatformTorrentUtils.updateMetaData(torrentFinal, 15000);
              }
            });
      }
    } else {
      Map jsonMapMetaData = hash == null ? null : (Map) mapHashes.get(hash);
      if (jsonMapMetaData != null) {
        long oldLastUpdated = getContentLastUpdated(torrent);
        long expireyMins = 0;

        for (Iterator iter = jsonMapMetaData.keySet().iterator(); iter.hasNext(); ) {
          String key = (String) iter.next();
          Object value = jsonMapMetaData.get(key);

          if (value == null || value.equals(null)) {
            contentMap.remove(key);
          } else if ((key.equals("Thumbnail") || key.endsWith(".B64")) && value instanceof String) {
            contentMap.put(key, Base64.decode((String) value));
          } else if (key.equals("expires-in-mins") && value instanceof Long) {
            expireyMins = ((Long) value).longValue();
          } else {
            contentMap.put(key, value);
          }
          writeTorrentIfExists(torrent);
        }

        // crappy way of updating the display name
        if (dm != null) {
          String title = PlatformTorrentUtils.getContentTitle(torrent);
          if (title != null
              && title.length() > 0
              && dm.getDownloadState().getDisplayName() == null) {
            dm.getDownloadState().setDisplayName(title);
          }
        }
        triggerMetaDataUpdateListeners(torrent);

        if (torrent != null) {
          // setup next refresh

          long refreshOn;
          if (expireyMins > 0) {
            refreshOn = SystemTime.getCurrentTime() + (expireyMins * 60 * 1000L);
          } else {
            long newLastUpdated = getContentLastUpdated(torrent);

            long diff = newLastUpdated - oldLastUpdated;
            log(
                torrent,
                "Last Updated: new "
                    + new Date(newLastUpdated)
                    + ";old "
                    + new Date(oldLastUpdated)
                    + ";diff="
                    + diff);
            if (diff > 0 && oldLastUpdated != 0) {
              diff *= 2;
              if (diff < MIN_MD_REFRESH_MS) {
                diff = MIN_MD_REFRESH_MS;
              } else if (diff > MAX_MD_REFRESH_MS) {
                diff = MAX_MD_REFRESH_MS;
              }
              refreshOn = SystemTime.getOffsetTime(diff);
            } else {
              refreshOn = SystemTime.getCurrentTime() + (7 * 24 * 60 * 60 * 1000L);
            }
          }

          log(torrent, "got MD. Next refresh in " + (refreshOn - SystemTime.getCurrentTime()));
          setMetaDataRefreshOn(torrent, refreshOn);
          SimpleTimer.addEvent(
              "Update MD",
              refreshOn,
              new TimerEventPerformer() {
                public void perform(TimerEvent event) {
                  PlatformTorrentUtils.updateMetaData(torrentFinal, 15000);
                }
              });
        }
      } else if (torrent != null) {
        long refreshOn = SystemTime.getCurrentTime() + (30 * 24 * 60 * 60 * 1000L);
        setMetaDataRefreshOn(torrent, refreshOn);
        log(torrent, "no hash in reply. Next refresh on " + new Date(refreshOn));
      }
    }
  }
Example #16
0
  protected void constructFixed(File _torrent_base, long _piece_length) throws TOTorrentException {

    setIgnoreList();

    setCreationDate(SystemTime.getCurrentTime() / 1000);

    setCreatedBy(Constants.AZUREUS_NAME + "/" + Constants.AZUREUS_VERSION);

    setPieceLength(_piece_length);

    report("Torrent.create.progress.piecelength", _piece_length);

    piece_count = calculateNumberOfPieces(_torrent_base, _piece_length);

    if (piece_count == 0) {

      throw (new TOTorrentException(
          "TOTorrentCreate: specified files have zero total length",
          TOTorrentException.RT_ZERO_LENGTH));
    }

    report("Torrent.create.progress.hashing");

    for (int i = 0; i < progress_listeners.size(); i++) {

      ((TOTorrentProgressListener) progress_listeners.get(i)).reportProgress(0);
    }

    boolean add_other_per_file_hashes = add_other_hashes && !getSimpleTorrent();

    file_hasher =
        new TOTorrentFileHasher(
            add_other_hashes,
            add_other_per_file_hashes,
            (int) _piece_length,
            progress_listeners.size() == 0 ? null : this);

    if (cancelled) {

      throw (new TOTorrentException(
          "TOTorrentCreate: operation cancelled", TOTorrentException.RT_CANCELLED));
    }

    if (getSimpleTorrent()) {

      long length = file_hasher.add(_torrent_base);

      setFiles(
          new TOTorrentFileImpl[] {
            new TOTorrentFileImpl(this, 0, length, new byte[][] {getName()})
          });

      setPieces(file_hasher.getPieces());

    } else {

      Vector encoded = new Vector();

      processDir(file_hasher, _torrent_base, encoded, "");

      TOTorrentFileImpl[] files = new TOTorrentFileImpl[encoded.size()];

      encoded.copyInto(files);

      setFiles(files);
    }

    setPieces(file_hasher.getPieces());

    if (add_other_hashes) {

      byte[] sha1_digest = file_hasher.getSHA1Digest();
      byte[] ed2k_digest = file_hasher.getED2KDigest();

      addAdditionalInfoProperty("sha1", sha1_digest);
      addAdditionalInfoProperty("ed2k", ed2k_digest);

      // System.out.println( "overall:sha1 = " + ByteFormatter.nicePrint( sha1_digest, true));
      // System.out.println( "overall:ed2k = " + ByteFormatter.nicePrint( ed2k_digest, true));
    }
  }
  protected Map getVersionCheckInfoSupport(
      String reason, boolean only_if_cached, boolean force, boolean v6) {
    try {
      synchronized (listeners) {
        if (REASON_UPDATE_CHECK_START.equals(reason)) {
          startCheckRan = true;
        }
        for (VersionCheckClientListener l : listeners) {
          l.versionCheckStarted(reason);
        }
      }
    } catch (Throwable t) {
      Debug.out(t);
    }
    if (v6) {

      if (enable_v6) {

        try {
          check_mon.enter();

          long time_diff = SystemTime.getCurrentTime() - last_check_time_v6;

          force = force || time_diff > CACHE_PERIOD || time_diff < 0;

          if (last_check_data_v6 == null || last_check_data_v6.size() == 0 || force) {
            // if we've never checked before then we go ahead even if the "only_if_cached"
            // flag is set as its had not chance of being cached yet!
            if (only_if_cached && last_check_data_v6 != null) {
              return (new HashMap());
            }
            try {
              last_check_data_v6 =
                  performVersionCheck(constructVersionCheckMessage(reason), true, true, true);

              if (last_check_data_v6 != null && last_check_data_v6.size() > 0) {

                COConfigurationManager.setParameter("versioncheck.cache.v6", last_check_data_v6);
              }
            } catch (SocketException t) {
              // internet is broken
              // Debug.out(t.getClass().getName() + ": " + t.getMessage());
            } catch (UnknownHostException t) {
              // dns is broken
              // Debug.out(t.getClass().getName() + ": " + t.getMessage());
            } catch (Throwable t) {
              Debug.out(t);
              last_check_data_v6 = new HashMap();
            }
          } else {
            Logger.log(
                new LogEvent(
                    LOGID,
                    "VersionCheckClient is using "
                        + "cached version check info. Using "
                        + last_check_data_v6.size()
                        + " reply keys."));
          }
        } finally {
          check_mon.exit();
        }
      }

      if (last_check_data_v6 == null) last_check_data_v6 = new HashMap();

      return last_check_data_v6;

    } else {

      try {
        check_mon.enter();

        long time_diff = SystemTime.getCurrentTime() - last_check_time_v4;

        force = force || time_diff > CACHE_PERIOD || time_diff < 0;

        if (last_check_data_v4 == null || last_check_data_v4.size() == 0 || force) {
          // if we've never checked before then we go ahead even if the "only_if_cached"
          // flag is set as its had not chance of being cached yet!
          if (only_if_cached && last_check_data_v4 != null) {
            return (new HashMap());
          }
          try {
            last_check_data_v4 =
                performVersionCheck(constructVersionCheckMessage(reason), true, true, false);

            if (last_check_data_v4 != null && last_check_data_v4.size() > 0) {

              COConfigurationManager.setParameter("versioncheck.cache.v4", last_check_data_v4);
            }

            // clear down any plugin-specific data that has successfully been sent to the version
            // server

            try {
              if (AzureusCoreFactory.isCoreAvailable()) {

                // installed plugin IDs
                PluginInterface[] plugins =
                    AzureusCoreFactory.getSingleton().getPluginManager().getPluginInterfaces();

                for (int i = 0; i < plugins.length; i++) {

                  PluginInterface plugin = plugins[i];

                  Map data =
                      plugin
                          .getPluginconfig()
                          .getPluginMapParameter("plugin.versionserver.data", null);

                  if (data != null) {

                    plugin
                        .getPluginconfig()
                        .setPluginMapParameter("plugin.versionserver.data", new HashMap());
                  }
                }
              }
            } catch (Throwable e) {
            }
          } catch (UnknownHostException t) {
            // no internet
            Debug.outNoStack(
                "VersionCheckClient - " + t.getClass().getName() + ": " + t.getMessage());
          } catch (IOException t) {
            // General connection problem.
            Debug.outNoStack(
                "VersionCheckClient - " + t.getClass().getName() + ": " + t.getMessage());
          } catch (Throwable t) {
            Debug.out(t);
            last_check_data_v4 = new HashMap();
          }
        } else {
          if (Logger.isEnabled())
            Logger.log(
                new LogEvent(
                    LOGID,
                    "VersionCheckClient is using "
                        + "cached version check info. Using "
                        + last_check_data_v4.size()
                        + " reply keys."));
        }
      } finally {
        check_mon.exit();
      }

      if (last_check_data_v4 == null) last_check_data_v4 = new HashMap();

      last_feature_flag_cache_time = 0;

      return last_check_data_v4;
    }
  }
  public long[] getTotalUsageInPeriod(int period_type) {
    if (start_of_week == -1) {

      COConfigurationManager.addAndFireParameterListeners(
          new String[] {"long.term.stats.weekstart", "long.term.stats.monthstart"},
          new ParameterListener() {
            public void parameterChanged(String name) {
              start_of_week = COConfigurationManager.getIntParameter("long.term.stats.weekstart");
              start_of_month = COConfigurationManager.getIntParameter("long.term.stats.monthstart");
            }
          });
    }

    Calendar calendar = new GregorianCalendar();

    calendar.setTimeInMillis(SystemTime.getCurrentTime());

    calendar.set(Calendar.MILLISECOND, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.HOUR_OF_DAY, 0);

    long top_time = calendar.getTimeInMillis() + DAY_IN_MILLIS - 1;

    if (period_type == PT_CURRENT_DAY) {

    } else if (period_type == PT_CURRENT_WEEK) {

      // sun = 1, mon = 2 etc

      int day_of_week = calendar.get(Calendar.DAY_OF_WEEK);

      if (day_of_week == start_of_week) {

      } else if (day_of_week > start_of_week) {

        calendar.add(Calendar.DAY_OF_WEEK, -(day_of_week - start_of_week));

      } else {

        calendar.add(Calendar.DAY_OF_WEEK, -(7 - (start_of_week - day_of_week)));
      }

    } else {

      if (start_of_month == 1) {

        calendar.set(Calendar.DAY_OF_MONTH, 1);

      } else {

        int day_of_month = calendar.get(Calendar.DAY_OF_MONTH);

        if (day_of_month == start_of_month) {

        } else if (day_of_month > start_of_month) {

          calendar.set(Calendar.DAY_OF_MONTH, start_of_month);

        } else {

          calendar.add(Calendar.MONTH, -1);

          calendar.set(Calendar.DAY_OF_MONTH, start_of_month);
        }
      }
    }

    long bottom_time = calendar.getTimeInMillis();

    return (getTotalUsageInPeriod(new Date(bottom_time), new Date(top_time)));
  }
  private void write(int record_type, long[] line_stats) {
    synchronized (this) {
      try {
        final long now = SystemTime.getCurrentTime();

        final long now_mins = now / (1000 * 60);

        String[] bits = utc_date_format.format(new Date(now)).split(",");

        String year = bits[0];
        String month = bits[1];
        String day = bits[2];

        String current_rel_file = year + File.separator + month + File.separator + day + ".dat";

        String line;

        String stats_str = "";

        if (record_type == RT_SESSION_START) {

          // absolute values

          for (int i = 0; i < line_stats.length; i++) {

            stats_str += "," + line_stats[i];

            line_stats_prev[i] = 0;
          }

          day_cache = null;

        } else {

          // relative values

          long[] diffs = new long[STAT_ENTRY_COUNT];

          for (int i = 0; i < line_stats.length; i++) {

            long diff = line_stats[i] - line_stats_prev[i];

            session_total += diff;

            diffs[i] = diff;

            stats_str += "," + diff;

            line_stats_prev[i] = line_stats[i];

            stat_averages[i].update(diff);
          }

          if (day_cache != null) {

            if (day_cache.isForDay(year, month, day)) {

              day_cache.addRecord(now_mins, diffs);
            }
          }
        }

        if (record_type != RT_SESSION_STATS) {

          line =
              (record_type == RT_SESSION_START ? "s," : "e,")
                  + VERSION
                  + ","
                  + now_mins
                  + stats_str;

        } else {

          line = stats_str.substring(1);
        }

        if (writer == null || !writer_rel_file.equals(current_rel_file)) {

          // first open of a file or file switch

          if (writer != null) {

            // file switch

            if (record_type != RT_SESSION_START) {

              writer.println(line);
            }

            writer.close();

            if (writer.checkError()) {

              writer = null;

              throw (new IOException("Write faled"));
            }

            writer = null;
          }

          // no point in opening a new file just to record the session-end

          if (record_type != RT_SESSION_END) {

            File file = new File(stats_dir, current_rel_file);

            file.getParentFile().mkdirs();

            writer = new PrintWriter(new FileWriter(file, true));

            writer_rel_file = current_rel_file;

            if (record_type == RT_SESSION_START) {

              writer.println(line);

            } else {

              // first entry in a new file, files always start with a session-start so they
              // can be processed in isolation so reset the session data and start a new one

              st_p_sent += line_stats[0];
              st_d_sent += line_stats[1];
              st_p_received += line_stats[2];
              st_d_received += line_stats[3];
              st_dht_sent += line_stats[4];
              st_dht_received += line_stats[5];

              ss_p_sent += line_stats[0];
              ss_d_sent += line_stats[1];
              ss_p_received += line_stats[2];
              ss_d_received += line_stats[3];
              ss_dht_sent += line_stats[4];
              ss_dht_received += line_stats[5];

              stats_str = "";

              long[] st_stats =
                  new long[] {
                    st_p_sent, st_d_sent, st_p_received, st_d_received, st_dht_sent, st_dht_received
                  };

              for (int i = 0; i < st_stats.length; i++) {

                stats_str += "," + st_stats[i];

                line_stats_prev[i] = 0;
              }

              line = "s," + VERSION + "," + now_mins + stats_str;

              writer.println(line);
            }
          }
        } else {

          writer.println(line);
        }

      } catch (Throwable e) {

        Debug.out("Failed to write long term stats", e);

      } finally {

        if (writer != null) {

          if (record_type == RT_SESSION_END) {

            writer.close();
          }

          if (writer.checkError()) {

            Debug.out("Failed to write long term stats");

            writer.close();

            writer = null;

          } else {

            if (record_type == RT_SESSION_END) {

              writer = null;
            }
          }
        }
      }
    }

    if (record_type != RT_SESSION_END) {

      final List<LongTermStatsListener> to_fire = new ArrayList<LongTermStatsListener>();

      for (Object[] entry : listeners) {

        long diff = session_total - (Long) entry[2];

        if (diff >= (Long) entry[1]) {

          entry[2] = session_total;

          to_fire.add((LongTermStatsListener) entry[0]);
        }
      }

      if (to_fire.size() > 0) {

        dispatcher.dispatch(
            new AERunnable() {
              @Override
              public void runSupport() {
                for (LongTermStatsListener l : to_fire) {

                  try {
                    l.updated(LongTermStatsImpl.this);

                  } catch (Throwable e) {

                    Debug.out(e);
                  }
                }
              }
            });
      }
    }
  }
Example #20
0
 public static void outNoStack(String str, boolean stderr) {
   diagLoggerLogAndOut(
       "DEBUG::" + new Date(SystemTime.getCurrentTime()).toString() + "  " + str, stderr);
 }
  public long[] getTotalUsageInPeriod(Date start_date, Date end_date) {
    synchronized (this) {
      long[] result = new long[STAT_ENTRY_COUNT];

      long start_millis = start_date.getTime();
      long end_millis = end_date.getTime();

      long now = SystemTime.getCurrentTime();

      long now_day = (now / DAY_IN_MILLIS) * DAY_IN_MILLIS;

      if (end_millis > now) {

        end_millis = now;
      }

      long start_day = (start_millis / DAY_IN_MILLIS) * DAY_IN_MILLIS;
      long end_day = (end_millis / DAY_IN_MILLIS) * DAY_IN_MILLIS;

      if (start_day > end_day) {

        return (result);
      }

      long start_offset = start_millis - start_day;

      start_offset = start_offset / MIN_IN_MILLIS;

      boolean offset_cachable = start_offset % 60 == 0;

      System.out.println(
          "start="
              + debug_utc_format.format(start_date)
              + ", end="
              + debug_utc_format.format(end_date)
              + ", offset="
              + start_offset);

      MonthCache month_cache = null;

      for (long this_day = start_day; this_day <= end_day; this_day += DAY_IN_MILLIS) {

        String[] bits = utc_date_format.format(new Date(this_day)).split(",");

        String year_str = bits[0];
        String month_str = bits[1];
        String day_str = bits[2];

        int year = Integer.parseInt(year_str);
        int month = Integer.parseInt(month_str);
        int day = Integer.parseInt(day_str);

        if (month_cache == null || !month_cache.isForMonth(year_str, month_str)) {

          if (month_cache != null && month_cache.isDirty()) {

            month_cache.save();
          }

          month_cache = getMonthCache(year_str, month_str);
        }

        boolean can_cache =
            this_day != now_day
                && (this_day > start_day || (this_day == start_day && offset_cachable))
                && this_day < end_day;

        long cache_offset = this_day == start_day ? start_offset : 0;

        if (can_cache) {

          long[] cached_totals = month_cache.getTotals(day, cache_offset);

          if (cached_totals != null) {

            for (int i = 0; i < cached_totals.length; i++) {

              result[i] += cached_totals[i];
            }

            continue;
          }
        } else {

          if (this_day == now_day) {

            if (day_cache != null) {

              if (day_cache.isForDay(year_str, month_str, day_str)) {

                long[] cached_totals = day_cache.getTotals(cache_offset);

                if (cached_totals != null) {

                  for (int i = 0; i < cached_totals.length; i++) {

                    result[i] += cached_totals[i];
                  }

                  continue;
                }

              } else {

                day_cache = null;
              }
            }
          }
        }

        String current_rel_file =
            bits[0] + File.separator + bits[1] + File.separator + bits[2] + ".dat";

        File stats_file = new File(stats_dir, current_rel_file);

        if (!stats_file.exists()) {

          if (can_cache) {

            month_cache.setTotals(day, cache_offset, new long[0]);
          }
        } else {

          LineNumberReader lnr = null;

          try {
            System.out.println("Reading " + stats_file);

            lnr = new LineNumberReader(new FileReader(stats_file));

            long file_start_time = 0;

            long[] file_totals = null;

            long[] file_result_totals = new long[STAT_ENTRY_COUNT];

            long[] session_start_stats = null;
            long session_start_time = 0;
            long session_time = 0;

            while (true) {

              String line = lnr.readLine();

              if (line == null) {

                break;
              }

              // System.out.println( line );

              String[] fields = line.split(",");

              if (fields.length < 6) {

                continue;
              }

              String first_field = fields[0];

              if (first_field.equals("s")) {

                session_start_time = Long.parseLong(fields[2]) * MIN_IN_MILLIS;

                if (file_totals == null) {

                  file_totals = new long[STAT_ENTRY_COUNT];

                  file_start_time = session_start_time;
                }

                session_time = session_start_time;

                session_start_stats = new long[STAT_ENTRY_COUNT];

                for (int i = 3; i < 9; i++) {

                  session_start_stats[i - 3] = Long.parseLong(fields[i]);
                }
              } else if (session_start_time > 0) {

                session_time += MIN_IN_MILLIS;

                int field_offset = 0;

                if (first_field.equals("e")) {

                  field_offset = 3;
                }

                long[] line_stats = new long[STAT_ENTRY_COUNT];

                for (int i = 0; i < 6; i++) {

                  line_stats[i] = Long.parseLong(fields[i + field_offset]);

                  file_totals[i] += line_stats[i];
                }

                if (session_time >= start_millis && session_time <= end_millis) {

                  for (int i = 0; i < 6; i++) {

                    result[i] += line_stats[i];

                    file_result_totals[i] += line_stats[i];
                  }
                }

                // System.out.println( getString( line_stats ));
              }
            }

            System.out.println(
                "File total: start="
                    + debug_utc_format.format(file_start_time)
                    + ", end="
                    + debug_utc_format.format(session_time)
                    + " - "
                    + getString(file_totals));

            if (can_cache) {

              month_cache.setTotals(day, cache_offset, file_result_totals);

              if (cache_offset != 0) {

                month_cache.setTotals(day, 0, file_totals);
              }
            } else {

              if (this_day == now_day) {

                if (day_cache == null) {

                  System.out.println("Creating day cache");

                  day_cache = new DayCache(year_str, month_str, day_str);
                }

                day_cache.setTotals(cache_offset, file_result_totals);

                if (cache_offset != 0) {

                  day_cache.setTotals(0, file_totals);
                }
              }
            }

          } catch (Throwable e) {

            Debug.out(e);

          } finally {

            if (lnr != null) {

              try {
                lnr.close();

              } catch (Throwable e) {
              }
            }
          }
        }
      }

      if (month_cache != null && month_cache.isDirty()) {

        month_cache.save();
      }

      System.out.println("    -> " + getString(result));

      return (result);
    }
  }
  public static licenceDetails getFullFeatureDetails() {
    if (featman == null) {
      Debug.out("featman null");
      return null;
    }

    TreeMap<Long, Object[]> mapOrder = new TreeMap<Long, Object[]>(Collections.reverseOrder());
    FeatureDetails[] featureDetails = featman.getFeatureDetails("dvdburn");
    // if any of the feature details are still valid, we have a full
    for (FeatureDetails fd : featureDetails) {
      Licence licence = fd.getLicence();
      int state = licence.getState();
      if (state == Licence.LS_ACTIVATION_DENIED) {
        mapOrder.put(-1L, new Object[] {licence, Long.valueOf(0)});
        continue;
      } else if (state == Licence.LS_CANCELLED) {
        mapOrder.put(-2L, new Object[] {licence, Long.valueOf(0)});
        continue;
      } else if (state == Licence.LS_INVALID_KEY) {
        mapOrder.put(-3L, new Object[] {licence, Long.valueOf(0)});
        continue;
      } else if (state == Licence.LS_REVOKED) {
        mapOrder.put(-4L, new Object[] {licence, Long.valueOf(0)});
        continue;
      } else if (state == Licence.LS_PENDING_AUTHENTICATION) {
        mapOrder.put(-6L, new Object[] {licence, Long.valueOf(0)});
        continue;
      }

      long now = SystemTime.getCurrentTime();
      Long lValidUntil = (Long) fd.getProperty(FeatureDetails.PR_VALID_UNTIL);
      Long lValidOfflineUntil = (Long) fd.getProperty(FeatureDetails.PR_OFFLINE_VALID_UNTIL);

      if (lValidUntil == null && lValidOfflineUntil == null) {
        continue;
      }

      long minValidUntil = -1;
      long maxValidUntil = -1;
      if (lValidUntil != null) {
        minValidUntil = maxValidUntil = lValidUntil.longValue();
        if (minValidUntil < now) {
          mapOrder.put(minValidUntil, new Object[] {licence, Long.valueOf(minValidUntil)});
          continue;
        }
      }
      if (lValidOfflineUntil != null) {
        long validOfflineUntil = lValidOfflineUntil.longValue();
        if (validOfflineUntil < now) {
          mapOrder.put(validOfflineUntil, new Object[] {licence, Long.valueOf(maxValidUntil)});
          continue;
        }
        if (maxValidUntil == -1 || validOfflineUntil > maxValidUntil) {
          maxValidUntil = validOfflineUntil;
        }
      }

      mapOrder.put(maxValidUntil, new Object[] {licence, minValidUntil});
    }

    if (mapOrder.size() == 0) {
      return null;
    }

    Long firstKey = mapOrder.firstKey();
    Object[] objects = mapOrder.get(firstKey);
    Licence licence = (Licence) objects[0];
    return new licenceDetails(firstKey.longValue(), ((Long) objects[1]).longValue(), licence);
  }
Example #23
0
    public void run() {
      while (true) {

        synchronized (currentLock) {
          try {
            target.run();

          } catch (Throwable e) {

            DebugLight.printStackTrace(e);

          } finally {

            target = null;

            debug = null;

            currentLock.released = true;

            currentLock.notifyAll();
          }
        }

        if (isInterrupted() || !Thread.currentThread().isDaemon()) {

          break;

        } else {

          synchronized (daemon_threads) {
            last_active_time = SystemTime.getCurrentTime();

            if (last_active_time < last_timeout_check
                || last_active_time - last_timeout_check > THREAD_TIMEOUT_CHECK_PERIOD) {

              last_timeout_check = last_active_time;

              while (daemon_threads.size() > 0 && daemon_threads.size() > MIN_RETAINED) {

                threadWrapper thread = (threadWrapper) daemon_threads.getFirst();

                long thread_time = thread.last_active_time;

                if (last_active_time < thread_time
                    || last_active_time - thread_time > THREAD_TIMEOUT) {

                  daemon_threads.removeFirst();

                  thread.retire();

                } else {

                  break;
                }
              }
            }

            if (daemon_threads.size() >= MAX_RETAINED) {

              return;
            }

            daemon_threads.addLast(this);

            setName("AEThread2:parked[" + daemon_threads.size() + "]");

            // System.out.println( "AEThread2: queue=" + daemon_threads.size() + ",creates=" +
            // total_creates + ",starts=" + total_starts );
          }

          sem.reserve();

          if (target == null) {

            break;
          }
        }
      }
    }
  /**
   * Construct the default version check message.
   *
   * @return message to send
   */
  public static Map constructVersionCheckMessage(String reason) {

    // only send if anonymous-check flag is not set

    boolean send_info = COConfigurationManager.getBooleanParameter("Send Version Info");

    Map message = new HashMap();

    // always send
    message.put("appid", SystemProperties.getApplicationIdentifier());
    message.put("appname", SystemProperties.getApplicationName());
    message.put("version", Constants.AZUREUS_VERSION);

    String sub_ver = Constants.AZUREUS_SUBVER;

    if (sub_ver.length() > 0) {
      message.put("subver", sub_ver);
    }

    if (COConfigurationManager.getBooleanParameter("Beta Programme Enabled")) {

      message.put("beta_prog", "true");
    }

    message.put("ui", COConfigurationManager.getStringParameter("ui", "unknown"));
    message.put("os", Constants.OSName);
    message.put("os_version", System.getProperty("os.version"));
    message.put(
        "os_arch", System.getProperty("os.arch")); // see http://lopica.sourceforge.net/os.html

    boolean using_phe =
        COConfigurationManager.getBooleanParameter("network.transport.encrypted.require");
    message.put("using_phe", using_phe ? new Long(1) : new Long(0));

    // swt stuff
    try {
      Class c = Class.forName("org.eclipse.swt.SWT");

      String swt_platform =
          (String) c.getMethod("getPlatform", new Class[] {}).invoke(null, new Object[] {});
      message.put("swt_platform", swt_platform);

      Integer swt_version =
          (Integer) c.getMethod("getVersion", new Class[] {}).invoke(null, new Object[] {});
      message.put("swt_version", new Long(swt_version.longValue()));

      if (send_info) {
        c = Class.forName("org.gudy.azureus2.ui.swt.mainwindow.MainWindow");
        if (c != null) {
          c.getMethod("addToVersionCheckMessage", new Class[] {Map.class})
              .invoke(null, new Object[] {message});
        }
      }
    } catch (ClassNotFoundException e) {
      /* ignore */
    } catch (NoClassDefFoundError er) {
      /* ignore */
    } catch (InvocationTargetException err) {
      /* ignore */
    } catch (Throwable t) {
      t.printStackTrace();
    }

    int last_send_time = COConfigurationManager.getIntParameter("Send Version Info Last Time", -1);
    int current_send_time = (int) (SystemTime.getCurrentTime() / 1000);
    COConfigurationManager.setParameter("Send Version Info Last Time", current_send_time);

    String id = COConfigurationManager.getStringParameter("ID", null);

    if (id != null && send_info) {
      message.put("id", id);

      try {
        byte[] id2 = CryptoManagerFactory.getSingleton().getSecureID();

        message.put("id2", id2);

      } catch (Throwable e) {
      }

      if (last_send_time != -1 && last_send_time < current_send_time) {
        // time since last
        message.put("tsl", new Long(current_send_time - last_send_time));
      }

      message.put("reason", reason);

      String java_version = System.getProperty("java.version");
      if (java_version == null) {
        java_version = "unknown";
      }
      message.put("java", java_version);

      String java_vendor = System.getProperty("java.vm.vendor");
      if (java_vendor == null) {
        java_vendor = "unknown";
      }
      message.put("javavendor", java_vendor);

      long max_mem = Runtime.getRuntime().maxMemory() / (1024 * 1024);
      message.put("javamx", new Long(max_mem));

      String java_rt_name = System.getProperty("java.runtime.name");
      if (java_rt_name != null) {
        message.put("java_rt_name", java_rt_name);
      }

      String java_rt_version = System.getProperty("java.runtime.version");
      if (java_rt_version != null) {
        message.put("java_rt_version", java_rt_version);
      }

      OverallStats stats = StatsFactory.getStats();

      if (stats != null) {

        // long total_bytes_downloaded 	= stats.getDownloadedBytes();
        // long total_bytes_uploaded		= stats.getUploadedBytes();
        long total_uptime = stats.getTotalUpTime();

        // removed due to complaints about anonymous stats collection
        // message.put( "total_bytes_downloaded", new Long( total_bytes_downloaded ) );
        // message.put( "total_bytes_uploaded", new Long( total_bytes_uploaded ) );
        message.put("total_uptime", new Long(total_uptime));
        // message.put( "dlstats", stats.getDownloadStats());
      }

      try {
        NetworkAdminASN current_asn = NetworkAdmin.getSingleton().getCurrentASN();

        String as = current_asn.getAS();

        message.put("ip_as", current_asn.getAS());

        String asn = current_asn.getASName();

        if (asn.length() > 64) {

          asn = asn.substring(0, 64);
        }

        message.put("ip_asn", asn);

      } catch (Throwable e) {

        Debug.out(e);
      }

      // send locale, so we can determine which languages need attention
      message.put("locale", Locale.getDefault().toString());
      String originalLocale =
          System.getProperty("user.language") + "_" + System.getProperty("user.country");
      String variant = System.getProperty("user.variant");
      if (variant != null && variant.length() > 0) {
        originalLocale += "_" + variant;
      }
      message.put("orig_locale", originalLocale);

      // We may want to reply differently if the user is in Beginner mode vs Advanced
      message.put("user_mode", COConfigurationManager.getIntParameter("User Mode", -1));

      Set<String> features = UtilitiesImpl.getFeaturesInstalled();

      if (features.size() > 0) {

        String str = "";

        for (String f : features) {
          str += (str.length() == 0 ? "" : ",") + f;
        }

        message.put("vzfeatures", str);
      }

      try {
        if (AzureusCoreFactory.isCoreAvailable()) {

          // installed plugin IDs
          PluginInterface[] plugins =
              AzureusCoreFactory.getSingleton().getPluginManager().getPluginInterfaces();

          List pids = new ArrayList();

          List vs_data = new ArrayList();

          for (int i = 0; i < plugins.length; i++) {

            PluginInterface plugin = plugins[i];

            String pid = plugin.getPluginID();

            String info = plugin.getPluginconfig().getPluginStringParameter("plugin.info");

            // filter out built-in and core ones
            if ((info != null && info.length() > 0)
                || (!pid.startsWith("<")
                    && !pid.startsWith("azbp")
                    && !pid.startsWith("azupdater")
                    && !pid.startsWith("azplatform")
                    && !pids.contains(pid))) {

              if (info != null && info.length() > 0) {

                if (info.length() < 256) {

                  pid += ":" + info;

                } else {

                  Debug.out("Plugin '" + pid + "' reported excessive info string '" + info + "'");
                }
              }

              pids.add(pid);
            }

            Map data =
                plugin.getPluginconfig().getPluginMapParameter("plugin.versionserver.data", null);

            if (data != null) {

              Map payload = new HashMap();

              byte[] data_bytes = BEncoder.encode(data);

              if (data_bytes.length > 16 * 1024) {

                Debug.out(
                    "Plugin '"
                        + pid
                        + "' reported excessive version server data (length="
                        + data_bytes.length
                        + ")");

                payload.put("error", "data too long: " + data_bytes.length);

              } else {

                payload.put("data", data_bytes);
              }

              payload.put("id", pid);
              payload.put("version", plugin.getPluginVersion());

              vs_data.add(payload);
            }
          }
          message.put("plugins", pids);

          if (vs_data.size() > 0) {

            message.put("plugin_data", vs_data);
          }
        }
      } catch (Throwable e) {

        Debug.out(e);
      }
    }

    return message;
  }