refactor: move trackerUrls to its own file
This commit is contained in:
parent
d277820961
commit
8cd2ce3f45
@ -4,6 +4,7 @@ import Box from '@mui/material/Box'
|
|||||||
import Divider from '@mui/material/Divider'
|
import Divider from '@mui/material/Divider'
|
||||||
|
|
||||||
import { rtcConfig } from 'config/rtcConfig'
|
import { rtcConfig } from 'config/rtcConfig'
|
||||||
|
import { trackerUrls } from 'config/trackerUrls'
|
||||||
import { ShellContext } from 'contexts/ShellContext'
|
import { ShellContext } from 'contexts/ShellContext'
|
||||||
import { usePeerRoom, usePeerRoomAction } from 'hooks/usePeerRoom'
|
import { usePeerRoom, usePeerRoomAction } from 'hooks/usePeerRoom'
|
||||||
import { PeerActions } from 'models/network'
|
import { PeerActions } from 'models/network'
|
||||||
@ -34,9 +35,7 @@ export function Room({
|
|||||||
const peerRoom = usePeerRoom(
|
const peerRoom = usePeerRoom(
|
||||||
{
|
{
|
||||||
appId,
|
appId,
|
||||||
trackerUrls: process.env.REACT_APP_TRACKER_URL
|
trackerUrls,
|
||||||
? [process.env.REACT_APP_TRACKER_URL]
|
|
||||||
: undefined,
|
|
||||||
rtcConfig,
|
rtcConfig,
|
||||||
},
|
},
|
||||||
roomId
|
roomId
|
||||||
|
25
src/config/trackerUrls.ts
Normal file
25
src/config/trackerUrls.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
let trackerUrls: string[] | undefined = [
|
||||||
|
// If you would like to host your own Chitchatter instance with alternative
|
||||||
|
// WebTorrent trackers to connect peers, add them to this array. This array
|
||||||
|
// gets provided to Trystero as the `trackerUrls` configuration option:
|
||||||
|
// https://github.com/dmotz/trystero#joinroomconfig-namespace
|
||||||
|
//
|
||||||
|
// See the default tracker list for examples of what to use:
|
||||||
|
// https://github.com/dmotz/trystero/blob/694f49974974cc9df8b621db09215d6df10fad09/src/torrent.js#L27-L33
|
||||||
|
]
|
||||||
|
|
||||||
|
// If a tracker URL has been provided via the REACT_APP_TRACKER_URL environment
|
||||||
|
// variable, prioritize using it. This is mainly relevant for local development
|
||||||
|
// when using the `npm run dev` script. If you are hosting your own Chitchatter
|
||||||
|
// instance, consider populating the trackerUrls above instead.
|
||||||
|
if (process.env.REACT_APP_TRACKER_URL) {
|
||||||
|
trackerUrls.unshift(process.env.REACT_APP_TRACKER_URL)
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no tracker URL overrides have been provided, set trackerUrls to undefined
|
||||||
|
// to allow Trystero to use the default list (linked above).
|
||||||
|
if (!trackerUrls.length) {
|
||||||
|
trackerUrls = undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
export { trackerUrls }
|
Loading…
Reference in New Issue
Block a user