core,transports: improve log

This commit is contained in:
Micooz 2018-02-06 17:30:08 +08:00
parent b2ec6ccaf9
commit 326eb29771
3 changed files with 8 additions and 8 deletions

@ -120,7 +120,7 @@ export class MuxRelay extends Relay {
// when mux relay destroyed, all sub relays should be destroyed as well.
muxRelay.addSubRelay(relay);
logger.debug(`[mux-${muxRelay.id}] create sub connection(cid=${relay.id}), total: ${muxRelay.getSubRelays().size}`);
logger.info(`[mux-${muxRelay.id}] create sub connection(cid=${relay.id}), total: ${muxRelay.getSubRelays().size}`);
return relay;
} else {
logger.warn(`[mux-${muxRelay.id}] cannot create new sub connection due to no mux connection are available`);

@ -165,13 +165,14 @@ export class Relay extends EventEmitter {
onBroadcast(action) {
const type = action.type;
if (__MUX__ && this._transport !== 'udp') {
if (__IS_CLIENT__ && type === CONNECT_TO_REMOTE) {
const remote = `${this._remoteInfo.host}:${this._remoteInfo.port}`;
const target = `${action.payload.host}:${action.payload.port}`;
logger.info(`[relay] [${remote}] request over mux(id=${this._ctx.muxRelay.id}): ${target}`);
if (type === CONNECT_TO_REMOTE) {
const remote = `${this._remoteInfo.host}:${this._remoteInfo.port}`;
const target = `${action.payload.host}:${action.payload.port}`;
if (__MUX__ && __IS_CLIENT__ && this._transport !== 'udp') {
logger.info(`[relay] [${remote}] request over mux-${this._ctx.muxRelay.id}: ${target}`);
return;
}
logger.info(`[relay] [${remote}] request: ${target}`);
}
if (type === CHANGE_PRESET_SUITE) {
this.onChangePresetSuite(action);

@ -322,7 +322,6 @@ export class TcpOutbound extends Outbound {
await this.connect({host, port});
}
if (__IS_CLIENT__) {
logger.info(`[${this.name}] [${this.remote}] request: ${host}:${port}`);
await this.connect({host: __SERVER_HOST__, port: __SERVER_PORT__});
}
this._socket.on('connect', () => {
@ -370,7 +369,7 @@ export class TcpOutbound extends Outbound {
async _connect({host, port}) {
const ip = await DNSCache.get(host);
logger.info(`[${this.name}] [${this.remote}] connecting to tcp://${host}:${port} resolve=${ip}`);
logger.info(`[${this.name}] [${this.remote}] connecting to tcp://${host}:${port} resolved=${ip}`);
return net.connect({host: ip, port});
}