gophertunnel
gophertunnel copied to clipboard
Cannot connect to Realms
When connecting to a realm (using IP:Port as Remote Address), the proxy crashes when you try to join. (Address is fine, it works in the normal Bedrock Client)
panic: runtime error: makeslic e: len out of range
goroutine 81 [running]:
github.com/sandertv/go-raknet/internal/message.(*OpenConnectionRequest1).Write(0xc00086fe84, 0xc0002f5f50)
C:/Users/RootRobo/go/pkg/mod/github.com/sandertv/[email protected]/internal/message/open_connection_request_1.go:20 +0x209
github.com/sandertv/go-raknet.(*connState).sendOpenConnectionRequest1(0xc0000acd50, 0xc00086000c, 0x4, 0x0)
C:/Users/RootRobo/go/pkg/mod/github.com/sandertv/[email protected]/dial.go:439 +0x75
github.com/sandertv/go-raknet.(*connState).discoverMTUSize.func2(0xc00027c720, 0xc0000acd50, 0xc0002f6db8, 0xc0002025a0, 0xc00021e3c0, 0xc00027c6c0, 0x917320, 0xc000380120)
C:/Users/RootRobo/go/pkg/mod/github.com/sandertv/[email protected]/dial.go:369 +0x1b5
created by github.com/sandertv/go-raknet.(*connState).discoverMTUSize
C:/Users/RootRobo/go/pkg/mod/github.com/sandertv/[email protected]/dial.go:361 +0x1f6
exit status 2
How long does it take until it crashes when you start connecting?
It takes about 20 seconds. I modified the open_connection_request_1.go file like this to display the value that's out of range:
package message
import (
"bytes"
"encoding/binary"
"fmt"
)
type OpenConnectionRequest1 struct {
Magic [16]byte
Protocol byte
MaximumSizeNotDropped int16
}
func (pk *OpenConnectionRequest1) Write(buf *bytes.Buffer) {
_ = binary.Write(buf, binary.BigEndian, IDOpenConnectionRequest1)
_ = binary.Write(buf, binary.BigEndian, unconnectedMessageSequence)
_ = binary.Write(buf, binary.BigEndian, pk.Protocol)
fmt.Printf("%v\n", pk.MaximumSizeNotDropped-int16(buf.Len()+28))
_, _ = buf.Write(make([]byte, pk.MaximumSizeNotDropped-int16(buf.Len()+28)))
}
func (pk *OpenConnectionRequest1) Read(buf *bytes.Buffer) error {
pk.MaximumSizeNotDropped = int16(buf.Len()+1) + 28
_ = binary.Read(buf, binary.BigEndian, &pk.Magic)
return binary.Read(buf, binary.BigEndian, &pk.Protocol)
}
The result when connecting is this:
1446
1406
1366
1326
1286
1246
1206
1166
1126
1086
1046
1006
966
926
886
846
806
766
726
686
646
606
566
526
486
446
406
366
326
286
246
206
166
126
86
46
6
-34
panic: runtime error: makeslice: len out of range
goroutine 99 [running]:
github.com/sandertv/go-raknet/internal/message.(*OpenConnectionRequest1).Write(0xc000837e84, 0xc000075d10)
C:/Users/RootRobo/go/pkg/mod/github.com/sandertv/[email protected]/internal/message/open_connection_request_1.go:20 +0x209
github.com/sandertv/go-raknet.(*connState).sendOpenConnectionRequest1(0xc00028fdd0, 0xc00083000c, 0x4, 0x0)
C:/Users/RootRobo/go/pkg/mod/github.com/sandertv/[email protected]/dial.go:439 +0x75
github.com/sandertv/go-raknet.(*connState).discoverMTUSize.func2(0xc0006a24e0, 0xc00028fdd0, 0xc0001d85c8, 0xc0000a3960, 0xc0000fcb40, 0xc0006a2480, 0x12e7320, 0xc000314240)
C:/Users/RootRobo/go/pkg/mod/github.com/sandertv/[email protected]/dial.go:369 +0x1b5
created by github.com/sandertv/go-raknet.(*connState).discoverMTUSize
C:/Users/RootRobo/go/pkg/mod/github.com/sandertv/[email protected]/dial.go:361 +0x1f6
exit status 2
I know why the crash happens, but 20 seconds of no response means the server is not responding, meaning there is no server running there.
The thing is, I tried connecting to the same IP using Minecraft Windows 10 Edition and it worked fine.
If the server is not responding, the proxy crashes with
panic: ping raknet: context deadline exceeded
goroutine 452 [running]:
main.handleConn(0xc0002aa480, 0xc0002c4100, 0xc0000a39f0, 0xd, 0xc0000a3a30, 0xe, 0xeb5bc0, 0xc0001a01e0)
I:/gophertunnel/main.go:95 +0x30f
created by main.main
I:/gophertunnel/main.go:84 +0x365
exit status 2
Also, the realm has a resource pack. Could that be the issue?
ya know its not a realms fault lmao. if the raknet ping didn't get responded to it probably means that realms doesn't use the same protocol as servers I might be wrong with that statement. But judging from that error it seems it took to long to respond so either the realm won't respond because it uses a different protocol or its just shitty as hell networking wise
Any chance you can send the IP so we can reproduce?
The IP changes frequently, but if you own a realm you can use the following code in the main() function to get the IP:
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
defer cancel()
xbl, _ := auth.RequestXBLToken(ctx, token, "https://pocket.realms.minecraft.net/")
req, _ := http.NewRequest("GET", "https://pocket.realms.minecraft.net/worlds/REALM ID/join", bytes.NewReader(nil))
xbl.SetAuthHeader(req)
req.Header.Set("User-Agent", "MCPE/Android")
req.Header.Set("Client-Version", protocol.CurrentVersion)
resp, _ := (&http.Client{}).Do(req)
b, _ := ioutil.ReadAll(resp.Body)
address := gjson.Get(string(b), "address").String()
log.Printf(string("Get response: " + address + "\n"))
log.Printf(string("Raw: " + string(b) + "\n"))
if string(b) == "Retry again later" {
log.Printf("Could not obtain Realm Address!\n")
os.Exit(-1)
}
config.Connection.RemoteAddress = address
You need to import: (I might have forgotten some modules just tell me if it isn't working or import the other modules yourself)
"net/http"
"context"
"time"
"github.com/tidwall/gjson"
(and yes I stole that code from issue #30)
I'm going to assume this has been fixed since, as people have been able to join realms using gophertunnel.
Please feel free to send a message here if you believe this issue was not fixed yet.