Skip to content

Commit cb82188

Browse files
committed
add addPing query param for testing
1 parent d0d5234 commit cb82188

File tree

4 files changed

+5
-2
lines changed

4 files changed

+5
-2
lines changed

README.MD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ Server specific:
176176
- `?lockConnect=true` - Only works then `ip` parameter is set. Disables cancel/save buttons and all inputs in the connect screen already set as parameters. Useful for integrates iframes.
177177
- `?autoConnect=true` - Only works then `ip` and `version` parameters are set and `allowAutoConnect` is `true` in config.json! Directly connects to the specified server. Useful for integrates iframes.
178178
- `?serversList=<list_or_url>` - `<list_or_url>` can be a list of servers in the format `ip:version,ip` or a url to a json file with the same format (array) or a txt file with line-delimited list of server IPs.
179+
- `?addPing=<ping>` - Add a latency to both sides of the connection. Useful for testing ping issues. For example `?addPing=100` will add 200ms to your ping.
179180

180181
Single player specific:
181182

src/appParams.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export type AppQsParams = {
4747
connectText?: string
4848
freezeSettings?: string
4949
testIosCrash?: string
50+
addPing?: string
5051

5152
// Replay params
5253
replayFilter?: string

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ export async function connect (connectOptions: ConnectOptions) {
305305

306306
if (connectOptions.server && !connectOptions.viewerWsConnect && !parsedServer.isWebSocket) {
307307
console.log(`using proxy ${proxy.host}:${proxy.port || location.port}`)
308-
net['setProxy']({ hostname: proxy.host, port: proxy.port, headers: { Authorization: `Bearer ${new URLSearchParams(location.search).get('token') ?? ''}` } })
308+
net['setProxy']({ hostname: proxy.host, port: proxy.port, headers: { Authorization: `Bearer ${new URLSearchParams(location.search).get('token') ?? ''}` }, artificialDelay: appQueryParams.addPing ? Number(appQueryParams.addPing) : undefined })
309309
}
310310

311311
const renderDistance = singleplayer ? renderDistanceSingleplayer : multiplayerRenderDistance

src/mineflayer/mc-protocol.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ export const setProxy = (proxyParams: ProxyParams) => {
130130
net['setProxy']({
131131
hostname: proxy.host,
132132
port: proxy.port,
133-
headers: proxyParams.headers
133+
headers: proxyParams.headers,
134+
artificialDelay: appQueryParams.addPing ? Number(appQueryParams.addPing) : undefined
134135
})
135136
return {
136137
proxy

0 commit comments

Comments
 (0)