Discuz! Board

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2499|回复: 0
打印 上一主题 下一主题

账号配置向导

[复制链接]

388

主题

602

帖子

2218

积分

金牌会员

Rank: 6Rank: 6

积分
2218
跳转到指定楼层
楼主
发表于 2016-3-27 22:28:08 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
const UNKNOWN = -1;
const IMAP = 0;
const POP = 1;
const SMTP = 2;


// Security Types
const NONE = 0; // no encryption
//1 would be "TLS if available"
const TLS = 3; // STARTTLS
const SSL = 2; // SSL / TLS



2014-12-23 09:24:59        mail.wizard        INFO        doing auto detect for protocol 1, domain pop3.sgcc.com.cn, (exactly: true), port 995, ssl 2

2014-12-23 09:24:59        mail.wizard        INFO        poking at pop3.sgcc.com.cn port 995 ssl 2 protocol pop3

2014-12-23 09:24:59        mail.wizard        INFO        progress callback host pop3.sgcc.com.cn port 995 type pop3


const CMDS = {}
CMDS[IMAP] = ["1 CAPABILITY\r\n", "2 LOGOUT\r\n"];
CMDS[POP] = ["CAPA\r\n", "QUIT\r\n"];
// CMDS[SMTP] = ["EHLO we-guess.mozilla.org\r\n", "QUIT\r\n"];

// only say hello?
CMDS[SMTP] = ["EHLO richinfo.cn\r\n", "QUIT\r\n"];
  1. function guessConfig(domain, progressCallback, successCallback, errorCallback,
  2.                      resultConfig, which)
  3. {
  4. incomingHostDetector = new IncomingHostDetector(progress, incomingSuccess,
  5.                                                   incomingError);

  6. if (which == "incoming" || which == "both")
  7.   {
  8.     incomingHostDetector.start(resultConfig.incoming.hostname ?
  9.             resultConfig.incoming.hostname : domain,
  10.         !!resultConfig.incoming.hostname, resultConfig.incoming.type,
  11.         resultConfig.incoming.port, resultConfig.incoming.socketType);
  12.   }

  13. }

  14. function IncomingHostDetector(
  15.   progressCallback, successCallback, errorCallback)
  16. {
  17.   HostDetector.call(this, progressCallback, successCallback, errorCallback);
  18. }
  19. IncomingHostDetector.prototype =
  20. {
  21.   _hostnamesToTry : function(protocol, domain)
  22.   {
  23.     var hostnamesToTry = [];
  24.     if (protocol != POP)
  25.       hostnamesToTry.push("imap." +  domain);
  26.     if (protocol != IMAP)
  27.     {
  28.       hostnamesToTry.push("pop3." +  domain);
  29.       hostnamesToTry.push("pop." +  domain);
  30.     }
  31.    // hostnamesToTry.push("mail." + domain);
  32.    // hostnamesToTry.push(domain);
  33.     return hostnamesToTry;
  34.   },
  35.   _portsToTry : getIncomingTryOrder,
  36. }
  37. extend(IncomingHostDetector, HostDetector);

  38. function HostDetector(progressCallback, successCallback, errorCallback)
  39. {
  40. }
  41. HostDetector.prototype =
  42. {
  43. start : function(domain, hostIsPrecise, type, port, socketType)
  44.   {
  45. this._log.info("doing auto detect for protocol " + protocol +
  46.         ", domain " + domain + ", (exactly: " + hostIsPrecise +
  47.         "), port " + port + ", ssl " + ssl);
  48.    this._tryAll();
  49.   }
  50. }
  51. _tryAll : function()
  52.   {
  53. this._log.info("poking at " + thisTry.hostname + " port " +
  54.           thisTry.port + " ssl "+ thisTry.ssl + " protocol " +
  55.           protocolToString(thisTry.protocol));

  56.     this.mProgressCallback(thisTry);
  57.     thisTry.abortable = SocketUtil(
  58.           thisTry.hostname, thisTry.port, thisTry.ssl,
  59.           thisTry.commands, TIMEOUT,
  60.           new SSLErrorHandler(thisTry, this._log),
  61.           function(wiredata) // result callback
  62.           {/*  ----------使用无效的证书后,返回的wiredata为空,虽然抓包有数据返回------
  63. imap.sgcc.com.cn:993 使用了无效的安全证书。
  64. 该证书因为其自签名而不被信任。该证书对任意服务器名均无效。(错误码: sec_error_untrusted_issuer)


  65. */
  66.             if (me._cancel)
  67.               return; // don't use response anymore
  68.             me.mProgressCallback(thisTry);
  69.             me._processResult(thisTry, wiredata);
  70.             me._checkFinished();
  71.           },
  72.           function(e) // error callback
  73.           {
  74.             if (me._cancel)
  75.               return; // who set cancel to true already called mErrorCallback()
  76.             me._log.warn(e);
  77.             thisTry.status = kFailed;
  78.             me._checkFinished();
  79.           });
  80. }
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|firemail ( 粤ICP备15085507号-1 )

GMT+8, 2024-11-26 03:55 , Processed in 0.057218 second(s), 19 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表