-
-
Notifications
You must be signed in to change notification settings - Fork 124
Add support for NETHERNET_JSONRPC Realms
#735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yntha
wants to merge
41
commits into
PrismarineJS:master
Choose a base branch
from
yntha:nethernet-jsonrpc
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
57f1b3d
Implement Nethernet spec
LucienHH 3611fc8
Add WebSocket signalling channel
LucienHH ff60244
Add Nethernet ping advertisement
LucienHH fbb490e
Add Session handling
LucienHH a5f1a68
Add nethernet transport
LucienHH f7b6873
Fix tests
LucienHH 9128997
Correctly build credentials
LucienHH d64d420
Use active broadcast address
LucienHH e622abc
Fix signalling handling
LucienHH 8663b31
Downgrade to werift v0.19.9
LucienHH bee7e2f
Lint
LucienHH dac29d0
Remove unnecessary ping
LucienHH beb436f
Remove debug logs
LucienHH d3746db
Send initial discovery request
LucienHH a30b7ef
Rename `Signal` to `NethernetSignal`
LucienHH 5f4ed39
Compression, batching and protocol fixes
LucienHH 0349567
Use correct buffer
LucienHH 4e5ef2a
Update to latest pauth API
LucienHH c9bc0c1
Use static arguments
LucienHH 552fc8b
Linting
LucienHH 4b082fc
Move protocol to `node-nethernet`
LucienHH d24817f
Fix connecting via signalling
LucienHH 7a73902
Move nethernet properties under .nethernet.*
LucienHH 6c048a7
Create nethernet_local.js
LucienHH 60c7ff9
Remove node-fetch
LucienHH 6bf0c1f
Rename rta to session
LucienHH f3230cf
Implement ServerData
LucienHH 508a15c
Cleanup unused methods
LucienHH c754c0c
Lint
LucienHH 71ecfee
Update to support PrismarineJS/nethernet
LucienHH 5fc6377
Update Nethernet signalling support and update advertisement
LucienHH e301fc7
Update auth
LucienHH a3e7bff
fix(nethernet): get ICE before offer and disable trickle candidates
yntha 0f2b0dc
feat(signal): add jsonrpc protocol support and fix endpoint
yntha 478bde5
feat(auth): handle NETHERNET_JSONRPC realm join in realmAuthenticate
yntha 1ba2ccb
feat(signal): automatically fall back to jsonrpc if legacy signalling…
yntha bd09b87
feat(client): pass signalling host from realmAuthenticate to Netherne…
yntha c0305ef
fix(auth): use raw join endpoint and set options for NETHERNET_JSONRPC
yntha 672b718
fix(client): init nethernet early and pass signalling protocol option
yntha c29bad7
fix(createClient): read skipPing from client.options
yntha f841a0c
feat(signal): rewrite NethernetSignal for JSON-RPC signalling API
yntha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,45 @@ | ||
| process.env.DEBUG = 'minecraft-protocol' | ||
|
|
||
| const readline = require('readline') | ||
| const { createClient } = require('bedrock-protocol') | ||
|
|
||
| async function pickSession (availableSessions) { | ||
| return new Promise((resolve) => { | ||
| const rl = readline.createInterface({ | ||
| input: process.stdin, | ||
| output: process.stdout | ||
| }) | ||
|
|
||
| console.log('Available Sessions:') | ||
|
|
||
| availableSessions.forEach((session, index) => console.log(`${index + 1}. ${session.customProperties.hostName} ${session.customProperties.worldName} (${session.customProperties.version})`)) | ||
|
|
||
| rl.question('Please select a session by number: ', (answer) => { | ||
| const sessionIndex = parseInt(answer) - 1 | ||
|
|
||
| if (sessionIndex >= 0 && sessionIndex < availableSessions.length) { | ||
| const selectedSession = availableSessions[sessionIndex] | ||
| console.log(`You selected: ${selectedSession.customProperties.hostName} ${selectedSession.customProperties.worldName} (${selectedSession.customProperties.version})`) | ||
| resolve(selectedSession) | ||
| } else { | ||
| console.log('Invalid selection. Please try again.') | ||
| resolve(pickSession()) | ||
| } | ||
|
|
||
| rl.close() | ||
| }) | ||
| }) | ||
| } | ||
|
|
||
| const client = createClient({ | ||
| transport: 'nethernet', // Use the Nethernet transport | ||
| world: { | ||
| pickSession | ||
| } | ||
| }) | ||
|
|
||
| let ix = 0 | ||
| client.on('packet', (args) => { | ||
| console.log(`Packet ${ix} recieved`) | ||
| ix++ | ||
| }) |
This file contains hidden or 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,22 @@ | ||
| process.env.DEBUG = 'minecraft-protocol' | ||
|
|
||
| const { Client } = require('node-nethernet') | ||
| const { createClient } = require('bedrock-protocol') | ||
|
|
||
| const c = new Client(0n) | ||
|
|
||
| c.once('pong', (pong) => { | ||
| c.close() | ||
|
|
||
| const client = createClient({ | ||
| transport: 'nethernet', // Use the Nethernet transport | ||
| networkId: pong.sender_id, | ||
| useSignalling: false | ||
| }) | ||
|
|
||
| let ix = 0 | ||
| client.on('packet', (args) => { | ||
| console.log(`Packet ${ix} recieved`) | ||
| ix++ | ||
| }) | ||
| }) | ||
This file contains hidden or 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,24 @@ | ||
| process.env.DEBUG = 'minecraft-protocol' | ||
|
|
||
| const { createClient } = require('bedrock-protocol') | ||
|
|
||
| const client = createClient({ | ||
| transport: 'nethernet', // Use the Nethernet transport | ||
| useSignalling: true, | ||
| networkId: '<guid>', | ||
| skipPing: true | ||
| }) | ||
|
|
||
| client.on('text', (packet) => { // Listen for chat messages and echo them back. | ||
| if (packet.source_name !== client.username) { | ||
| client.queue('text', { | ||
| type: 'chat', | ||
| needs_translation: false, | ||
| source_name: client.username, | ||
| xuid: '', | ||
| platform_chat_id: '', | ||
| filtered_message: '', | ||
| message: `${packet.source_name} said: ${packet.message} on ${new Date().toLocaleString()}` | ||
| }) | ||
| } | ||
| }) |
This file contains hidden or 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,20 @@ | ||
| /* eslint-disable */ | ||
| process.env.DEBUG = 'minecraft-protocol' | ||
|
|
||
| const bedrock = require('bedrock-protocol') | ||
|
|
||
| const server = bedrock.createServer({ | ||
| transport: 'nethernet', | ||
| useSignalling: true, // disable for LAN connections only | ||
| motd: { | ||
| motd: 'Funtime Server', | ||
| levelName: 'Wonderland' | ||
| } | ||
| }) | ||
|
|
||
| server.on('connect', client => { | ||
| client.on('join', () => { // The client has joined the server. | ||
| const date = new Date() // Once client is in the server, send a colorful kick message | ||
| client.disconnect(`Good ${date.getHours() < 12 ? '§emorning§r' : '§3afternoon§r'}\n\nMy time is ${date.toLocaleString()} !`) | ||
| }) | ||
| }) |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -22,16 +22,20 @@ | |
| "license": "MIT", | ||
| "dependencies": { | ||
| "debug": "^4.3.1", | ||
| "json-bigint": "^1.0.0", | ||
| "jsonwebtoken": "^9.0.0", | ||
| "jsp-raknet": "^2.1.3", | ||
| "minecraft-data": "^3.0.0", | ||
| "minecraft-folder-path": "^1.2.0", | ||
| "node-nethernet": "github:LucienHH/node-nethernet#protocol", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need a PR for this?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to do a release of node-nethernet but there are some further changes that need to be merged still |
||
| "prismarine-auth": "^3.0.0", | ||
| "prismarine-nbt": "^2.0.0", | ||
| "prismarine-realms": "^1.1.0", | ||
| "protodef": "^1.14.0", | ||
| "raknet-native": "^1.0.3", | ||
| "uuid-1345": "^1.0.2" | ||
| "uuid-1345": "^1.0.2", | ||
| "ws": "^8.18.0", | ||
| "xbox-rta": "^2.1.0" | ||
| }, | ||
| "optionalDependencies": { | ||
| "raknet-node": "^0.5.0" | ||
|
|
@@ -53,4 +57,4 @@ | |
| "url": "https://github.com/PrismarineJS/bedrock-protocol/issues" | ||
| }, | ||
| "homepage": "https://github.com/PrismarineJS/bedrock-protocol#readme" | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
networkId and useSignalling seem poorly named from API standpoint.
Can you explain these? It seems these options can be put into something like
xboxSession: { ...props }to be clearerThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
networkId is the identifier used to connect to the target server. Normally can be found from the discovery packet but for example in Realms the API returns the networkId in the response which you can then use the signalling channel to connect.
useSignalling is a flag that determines whether the signalling server should be contacted to create a connection, when it's false it will only do discovery over LAN
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ok from internal standpoint but not useful configuration jargon for people trying to connect to a server
If this is for connecting to LAN or Realm servers we should have better named options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey team, I managed to get rid of this in commit 478bde5. In the example I provided, you don't need to pass any extra options at all; the client handles it in the backend.