|
@@ -103,9 +103,14 @@ export class MetaGateway
|
|
|
});
|
|
|
|
|
|
this.peer.onLocalCandidate((candidate, mid) => {
|
|
|
+ if (/172\./.test(candidate) || /192.168\./.test(candidate)) {
|
|
|
+ console.error('private Ip process');
|
|
|
+ // 过滤非 192.168.0.x 测试网段
|
|
|
+ if (!/192.168.0\./.test(candidate)) {
|
|
|
+ console.warn('不是192.168.0.测试网段');
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- if (/172\./.test(candidate)) {
|
|
|
- console.error('private Ip');
|
|
|
if (candidate.includes(process.env.PRIVATE_IP)) {
|
|
|
console.error('PRIVATE_IP', process.env.PRIVATE_IP);
|
|
|
candidate = candidate.replace(
|
|
@@ -117,13 +122,13 @@ export class MetaGateway
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (/192.168\./.test(candidate)) {
|
|
|
- // const all_ips = Array.from(process.env.ALL_IPS);
|
|
|
- if (!/192.168.0\./.test(candidate)) {
|
|
|
- console.warn('不是192.168.0.测试网段');
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
+ // if (/192.168\./.test(candidate)) {
|
|
|
+ // // const all_ips = Array.from(process.env.ALL_IPS);
|
|
|
+ // if (!/192.168.0\./.test(candidate)) {
|
|
|
+ // console.warn('不是192.168.0.测试网段');
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
console.warn('onLocalCandidate Candidate:', candidate);
|
|
|
const iceRes = {
|
|
|
candidate,
|
|
@@ -168,6 +173,9 @@ export class MetaGateway
|
|
|
console.log('channel is open');
|
|
|
clearInterval(this.timer);
|
|
|
|
|
|
+ const peers = this.peer.getSelectedCandidatePair();
|
|
|
+ console.log('配对成功', peers);
|
|
|
+
|
|
|
let i = 1;
|
|
|
const paths = path.join(__dirname, '../ws/video/v11');
|
|
|
console.error('__dirname', __dirname);
|
|
@@ -213,7 +221,6 @@ export class MetaGateway
|
|
|
heartPack.setUint32(0, 2009889916);
|
|
|
this._webrtcInterval = setInterval(() => {
|
|
|
if (channel.isOpen()) {
|
|
|
- console.log('gameChanel', channel);
|
|
|
channel.sendMessageBinary(Buffer.from(heartPack.buffer));
|
|
|
}
|
|
|
}, 1e3);
|