-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #383 from ulixee/rtc
feat(plugins): mask public ip in webrtc
- Loading branch information
Showing
17 changed files
with
297 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import IHttpSocketConnectOptions from './IHttpSocketConnectOptions'; | ||
import IHttpSocketWrapper from './IHttpSocketWrapper'; | ||
|
||
export default interface IHttpSocketAgent { | ||
createSocketConnection(options: IHttpSocketConnectOptions): Promise<IHttpSocketWrapper>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export default interface IHttpSocketConnectOptions { | ||
host: string; | ||
port: string; | ||
isSsl: boolean; | ||
keepAlive?: boolean; | ||
debug?: boolean; | ||
servername?: string; | ||
isWebsocket?: boolean; | ||
keylogPath?: string; | ||
proxyUrl?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import * as net from 'net'; | ||
|
||
export default interface IHttpSocketWrapper { | ||
id: number; | ||
alpn: string; | ||
socket: net.Socket; | ||
dnsResolvedIp: string; | ||
remoteAddress: string; | ||
localAddress: string; | ||
serverName: string; | ||
|
||
createTime: Date; | ||
dnsLookupTime: Date; | ||
connectTime: Date; | ||
errorTime: Date; | ||
closeTime: Date; | ||
|
||
isConnected: boolean; | ||
isClosing: boolean; | ||
|
||
isHttp2(): boolean; | ||
close(): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
plugins/default-browser-emulator/injected-scripts/webrtc.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const maskLocalIp = args.localIp; | ||
const replacementIp = args.proxyIp; | ||
|
||
if ('RTCIceCandidate' in self && RTCIceCandidate.prototype) { | ||
proxyGetter(RTCIceCandidate.prototype, 'candidate', function () { | ||
const result = ReflectCached.apply(...arguments); | ||
return result.replace(maskLocalIp, replacementIp); | ||
}); | ||
if ('address' in RTCIceCandidate.prototype) { | ||
// @ts-ignore | ||
proxyGetter(RTCIceCandidate.prototype, 'address', function () { | ||
const result: string = ReflectCached.apply(...arguments); | ||
return result.replace(maskLocalIp, replacementIp); | ||
}); | ||
} | ||
proxyFunction(RTCIceCandidate.prototype, 'toJSON', function () { | ||
const json = ReflectCached.apply(...arguments); | ||
if ('address' in json) json.address = json.address.replace(maskLocalIp, replacementIp); | ||
if ('candidate' in json) json.candidate = json.candidate.replace(maskLocalIp, replacementIp); | ||
return json; | ||
}); | ||
} | ||
|
||
if ('RTCSessionDescription' in self && RTCSessionDescription.prototype) { | ||
proxyGetter(RTCSessionDescription.prototype, 'sdp', function () { | ||
let result = ReflectCached.apply(...arguments); | ||
while (result.indexOf(maskLocalIp) !== -1) { | ||
result = result.replace(maskLocalIp, replacementIp); | ||
} | ||
return result; | ||
}); | ||
} |
Oops, something went wrong.