blinksocks/lib/transports/defs.js
2017-09-21 09:33:02 +08:00

1 line
1.3 KiB
JavaScript

'use strict';Object.defineProperty(exports,'__esModule',{value:true});exports.Outbound=exports.Inbound=undefined;var _events=require('events');var _events2=_interopRequireDefault(_events);var _core=require('../core');function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}class Bound extends _events2.default{get bufferSize(){return 0}get writable(){return true}onBroadcast(){}write(buffer){}destroy(){}setPresets(callback){}}class Inbound extends Bound{constructor({context,pipe}){super();this._outbound=null;this._pipe=null;this._pipe=pipe;this._remoteHost=context.remoteAddress;this._remotePort=context.remotePort}get remote(){return`${this._remoteHost}:${this._remotePort}`}get remoteHost(){return this._remoteHost}get remotePort(){return this._remotePort}setOutbound(outbound){this._outbound=outbound}broadcast(action){!this._pipe.destroyed&&this._pipe.broadcast('pipe',action)}}exports.Inbound=Inbound;class Outbound extends Bound{constructor({inbound,pipe}){super();this._inbound=null;this._pipe=null;this._dnsCache=null;this._inbound=inbound;this._pipe=pipe;this._dnsCache=new _core.DNSCache({expire:__DNS_EXPIRE__})}get remote(){return this._inbound.remote}broadcast(action){!this._pipe.destroyed&&this._pipe.broadcast('pipe',action)}}exports.Outbound=Outbound;