xssnick / tonutils-go

TON SDK Library in pure Golang for interacting with The Open Network ecosystem using native protocols, such as ADNL, RLDP and etc.
Apache License 2.0
464 stars 95 forks source link

Accessing validator-engine-console with ADNL client #194

Closed Szymongib closed 3 months ago

Szymongib commented 3 months ago

I am trying to use ConnectionPool for accessing validator-engine-console with more or less the following code:

tl.Register(ValidatorStats{}, "engine.validator.getStats = engine.validator.Stats")
...
client := liteclient.NewConnectionPool()

// Read key files etc...

err = client.AddConnection(
    context.Background(),
    "NODE_IP:PORT",
    serverKeyPubB64,
    clinetKeyFull,
)
if err != nil {
    panic(err)
}
fmt.Println("Connected to server")

var resp tl.Serializable
err = client.QueryADNL(context.Background(), ValidatorStats{}, &resp)
if err != nil {
    panic(err)
}
...

What I am getting in response is engine.validator.ControlQueryError with Code:602 Message:forbidden.

Running validator-engine-console against the same host with the same keys works fine.

So my question is if it is possible to use the library to access validator-engine-console, or is it strictly specific to lite server? If so if you could point me to some resources to understand the specificity I would be very grateful (I am not proficient enough in c++ to figure it out quickly from Ton codebase).

xssnick commented 3 months ago

Hi, it is possible to use with any ADNL client/server. Regarding the forbidden error, see this node's method it also checks source ADNL key and some port, try to compare port and client key with what you have for validator-engine-console, maybe it is different?

xssnick commented 3 months ago

Also maybe you need to use your client key in NewConnectionPoolWithAuth as auth, instead of using NewConnectionPool

Szymongib commented 3 months ago

Also maybe you need to use your client key in NewConnectionPoolWithAuth as auth, instead of using NewConnectionPool

Thanks, I was able to connect with NewConnectionPoolWithAuth, although now I am facing different issues with failed to parse validator query, but that is probably me doing something wrong with the query itself.