puppet-service icon indicating copy to clipboard operation
puppet-service copied to clipboard

[RFC] Support customize private host for wechaty-puppet-service server

Open windmemory opened this issue 4 years ago • 2 comments

I am wondering how does wechaty-puppet-serivce server register its host address? Is it possible that we can manually change the host address to a private ip address? So the client can connect to the server within private network to save some traffic, and make the system more secure?

windmemory avatar Feb 05 '21 10:02 windmemory

Thanks for creating this feature request.

I believe it's a scenario we should support.

A RFC will be welcome to start writing the request down in details and designing it.

huan avatar Feb 05 '21 10:02 huan

Since the current design for wechaty-puppet-service is using a websocket to register the server, how about we add one more parameter when we initialize the connection? I checked the code that create the connection with api.chatie.io, here is the code:

    if (!this.options.apihost) {
      throw new Error('no apihost')
    }
    let endpoint = 'wss://' + this.options.apihost + '/v0/websocket'

    if (!/api\.chatie\.io/.test(this.options.apihost)) {
      endpoint = 'ws://' + this.options.apihost + '/v0/websocket'
    }

    const ws = this.ws = new WebSocket(endpoint, this.protocol, { headers })

If we put a customize host into the header, this information will be passed to the discovery server, then the discovery server could use this customize ip.

windmemory avatar Feb 05 '21 12:02 windmemory