blinksocks/src/transports/defs.js

101 lines
1.2 KiB
JavaScript
Raw Normal View History

/* eslint-disable no-unused-vars */
import EventEmitter from 'events';
2018-06-24 05:30:56 +00:00
// .on('_error')
// .on('data')
// .on('close')
class Bound extends EventEmitter {
_config = null;
2018-06-24 05:30:56 +00:00
_source = null;
_conn = null;
_destroyed = false;
2018-06-24 05:30:56 +00:00
constructor({ config, source, conn }) {
super();
this._config = config;
2018-06-24 05:30:56 +00:00
this._source = source;
this._conn = conn;
}
get remoteHost() {
2018-06-24 05:30:56 +00:00
return this._source.host;
}
get remotePort() {
2018-06-24 05:30:56 +00:00
return this._source.port;
}
get remote() {
return `${this.remoteHost}:${this.remotePort}`;
}
get bufferSize() {
return 0;
}
get writable() {
return true;
}
get destroyed() {
return this._destroyed;
}
onBroadcast() {
}
write(buffer) {
}
close() {
}
}
export class Inbound extends Bound {
_outbound = null; // set by relay
2018-07-05 10:27:47 +00:00
get name() {
return 'inbound';
}
setOutbound(outbound) {
this._outbound = outbound;
}
getOutbound() {
return this._outbound;
}
}
export class Outbound extends Bound {
_inbound = null; // set by relay
2018-07-05 10:27:47 +00:00
get name() {
return 'outbound';
}
setInbound(inbound) {
this._inbound = inbound;
}
getInbound() {
return this._inbound;
}
2018-06-24 05:30:56 +00:00
async connect() {
}
}