当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript tls.connect函数代码示例

本文整理汇总了TypeScript中tls.connect函数的典型用法代码示例。如果您正苦于以下问题:TypeScript connect函数的具体用法?TypeScript connect怎么用?TypeScript connect使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了connect函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: connect

function connect() {
  if (socket != null) return;

  statusChatTab.addInfo(`Connecting to ${ircNetwork.host}:${ircNetwork.port}...`);
  for (const name in channelChatTabs) channelChatTabs[name].addInfo("Connecting...");
  for (const name in privateChatTabs) privateChatTabs[name].addInfo("Connecting...");

  socket = tls.connect({ host: ircNetwork.host, port: ircNetwork.port, rejectUnauthorized: false }) as any as net.Socket;
  socket.on("error", onSocketError);

  irc = SlateIRC(socket);
  irc.on("welcome", onWelcome);
  irc.on("motd", onMOTD);
  irc.on("join", onJoin);
  irc.on("part", onPart);
  irc.on("nick", onNick);
  irc.on("away", onAway);
  irc.on("quit", onQuit);
  irc.on("data", onData);
  irc.on("message", onMessage);
  irc.on("notice", onNotice);
  irc.on("disconnect", onDisconnect);

  irc.nick(settings.nickname);
  irc.user(settings.nickname, settings.nickname);
}
开发者ID:AgileJoshua,项目名称:superpowers-app,代码行数:26,代码来源:index.ts

示例2: function

      _this.resolve(endpoint, function (err, resolved) {
        if (!_this.connecting) {
          callback(new Error(CONNECTION_CLOSED_ERROR_MSG))
          return
        }
        if (resolved) {
          debug('resolved: %s:%s', resolved.host, resolved.port)
          if (_this.options.enableTLSForSentinelMode && _this.options.tls) {
            Object.assign(resolved, _this.options.tls)
            _this.stream = createTLSConnection(resolved)
          } else {
            _this.stream = createConnection(resolved)
          }
          _this.sentinelIterator.reset(true)
          callback(null, _this.stream)
        } else {
          const endpointAddress = endpoint.host + ':' + endpoint.port
          const errorMsg = err
            ? 'failed to connect to sentinel ' + endpointAddress + ' because ' + err.message
            : 'connected to sentinel ' + endpointAddress + ' successfully, but got an invalid reply: ' + resolved

          debug(errorMsg)

          eventEmitter('sentinelError', new Error(errorMsg))

          if (err) {
            lastError = err
          }
          connectToNext()
        }
      })
开发者ID:luin,项目名称:ioredis,代码行数:31,代码来源:index.ts

示例3: connect

  connect(): void {
    process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';

    this.socket = tls.connect({
      host: this.options.host,
      port: this.options.port,
      rejectUnauthorized: false
    }, () => {
      console.log('Connected to ' + this.options.host + ':' + this.options.port);
    });

    if (this.interval) {
      clearInterval(this.interval);
      this.interval = null;
    }

    this.interval = setInterval(() => {
      this.emit(new TimerEvent(this));
    }, 1000);

    this.socket.on('data', (data) => {
      var inputString = data.toString().trim();

      if (!this.connected) {
        console.log('Connecting as ' + this.options.username);
        this.sendln('co ' + this.options.username + ' ' + this.options.password);
        this.connected = true;
        this.emit(new ConnectEvent(this));
        return;
      }

      let input = new Input(this, inputString);

      try {
        for (var i = 0; i < this.pipes.length; ++i) {
          let result = this.pipes[i].pipe(input);
          if (result == PipeAction.ABORT) {
            return;
          } else if (result == PipeAction.STOP) {
            break;
          }
        }
      } catch (e) {
        console.error(e);
        return;
      }

      this.emit(new InputEvent(this, input));
    });

    this.socket.on('end', () => {
      if (this.interval) {
        clearInterval(this.interval);
        this.interval = null;
      }
      this.emit(new DisconnectEvent(this));
      console.log('Disconnected from server');
    });
  }
开发者ID:herrevilkitten,项目名称:mux-per-ass,代码行数:59,代码来源:mush-client.ts

示例4: clearTimeout

 req.on('connect', (res, socket, head) => {
   clearTimeout(timer);
   const stream: TLSSocket = connect(
     { socket, servername: this.options.servername },
     () => next(null, stream)
   );
   stream.on('error', error => {
     next(error);
   });
 });
开发者ID:fangwd,项目名称:yareq,代码行数:10,代码来源:https-agent.ts

示例5: Promise

 return new Promise((resolve, reject) => {
     const socket = tls.connect({
         host: query.hostname,
         port: query.port
     }, () => {
         const peerCertificate = socket.getPeerCertificate();
         const validTo = Date.parse(peerCertificate.valid_to);
         socket.end();
         resolve((validTo - Date.now()) / (24 * 3600 * 1000));
     });
     socket.on('error', reject);
 });
开发者ID:wiktor-k,项目名称:infrastructure-tests,代码行数:12,代码来源:queries.ts

示例6: callback

    process.nextTick(() => {
      if (!this.connecting) {
        callback(new Error(CONNECTION_CLOSED_ERROR_MSG))
        return
      }

      let stream: Socket | TLSSocket
      try {
        if (options.tls) {
          stream = createTLSConnection(connectionOptions)
        } else {
          stream = createConnection(connectionOptions)
        }
      } catch (err) {
        callback(err)
        return
      }
  
      this.stream = stream
      callback(null, stream)
    })
开发者ID:luin,项目名称:ioredis,代码行数:21,代码来源:StandaloneConnector.ts

示例7:

//////////////////////////////////////////////////
/// TLS tests : http://nodejs.org/api/tls.html ///
//////////////////////////////////////////////////

namespace tls_tests {
    var ctx: tls.SecureContext = tls.createSecureContext({
        key: "NOT REALLY A KEY",
        cert: "SOME CERTIFICATE",
    });
    var blah = ctx.context;

    var connOpts: tls.ConnectionOptions = {
        host: "127.0.0.1",
        port: 55
    };
    var tlsSocket = tls.connect(connOpts);
}

////////////////////////////////////////////////////
/// Http tests : http://nodejs.org/api/http.html ///
////////////////////////////////////////////////////

namespace http_tests {
    {
        // Status codes
        var codeMessage = http.STATUS_CODES['400'];
        var codeMessage = http.STATUS_CODES[400];
    }

    {
        var agent: http.Agent = new http.Agent({
开发者ID:Crevil,项目名称:DefinitelyTyped,代码行数:31,代码来源:node-tests.ts

示例8: function

////////////////////////////////////////////////////
/// TLS tests : http://nodejs.org/api/tls.html
////////////////////////////////////////////////////

var ctx: tls.SecureContext = tls.createSecureContext({
    key: "NOT REALLY A KEY",
    cert: "SOME CERTIFICATE",
});
var blah = ctx.context;

var tlsOpts: tls.TlsOptions = {
	host: "127.0.0.1",
	port: 55
};
var tlsSocket = tls.connect(tlsOpts);


////////////////////////////////////////////////////

// Make sure .listen() and .close() retuern a Server instance
http.createServer().listen(0).close().address();
net.createServer().listen(0).close().address();

var request = http.request('http://0.0.0.0');
request.once('error', function () {});
request.setNoDelay(true);
request.abort();

////////////////////////////////////////////////////
/// Http tests : http://nodejs.org/api/http.html
开发者ID:Cyr1l,项目名称:DefinitelyTyped,代码行数:30,代码来源:node-tests.ts

示例9: createSecureContext

import { createSecureContext, SecureContext, ConnectionOptions, connect, getCiphers, DEFAULT_ECDH_CURVE, createServer, TLSSocket } from "tls";
import * as fs from "fs";

{
    const ctx: SecureContext = createSecureContext({
        key: "NOT REALLY A KEY",
        cert: "SOME CERTIFICATE",
    });
    const blah = ctx.context;

    const connOpts: ConnectionOptions = {
        host: "127.0.0.1",
        port: 55
    };
    const tlsSocket = connect(connOpts);

    const ciphers: string[] = getCiphers();
    const curve: string = DEFAULT_ECDH_CURVE;
}

{
    const _server = createServer();

    _server.addContext("example", {
        cert: fs.readFileSync("cert_filepath"),
        key: fs.readFileSync("key_filepath")
    });
}

{
    let _server = createServer({});
开发者ID:ChaosinaCan,项目名称:DefinitelyTyped,代码行数:31,代码来源:tls.ts


注:本文中的tls.connect函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。