mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 10:49:28 +02:00
Support proxies for PeerTube (#4346)
* Updated with latest code * Updated Support proxies for PeerTube * Support Proxies for PeerTube (Updated with change request) * Cleanup proxy PR Co-authored-by: Chocobozzz <me@florianbigard.com>
This commit is contained in:
parent
fdec51e384
commit
8729a87024
7 changed files with 191 additions and 3 deletions
27
shared/extra-utils/mock-servers/mock-proxy.ts
Normal file
27
shared/extra-utils/mock-servers/mock-proxy.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
|
||||
import { createServer, Server } from 'http'
|
||||
import * as proxy from 'proxy'
|
||||
import { randomInt } from '@shared/core-utils'
|
||||
|
||||
class MockProxy {
|
||||
private server: Server
|
||||
|
||||
initialize () {
|
||||
return new Promise<number>(res => {
|
||||
const port = 42501 + randomInt(1, 100)
|
||||
|
||||
this.server = proxy(createServer())
|
||||
this.server.listen(port, () => res(port))
|
||||
})
|
||||
}
|
||||
|
||||
terminate () {
|
||||
if (this.server) this.server.close()
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
MockProxy
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue