Skip to content
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

自己部署 puppet service的时候为什么还要公网? #2666

Open
monotone opened this issue Apr 9, 2024 · 3 comments
Open

自己部署 puppet service的时候为什么还要公网? #2666

monotone opened this issue Apr 9, 2024 · 3 comments

Comments

@monotone
Copy link

monotone commented Apr 9, 2024

🚨 The issue tracker is not for questions 🚨

If you have a question, please ask it on https://stackoverflow.com/questions/tagged/wechaty

[question]

抱歉我看到了上面的提示说问题应该去 stackoverflow 询问,但是我觉得我的这个问题应该很多人有疑问,所以在这里发一下更方便别人看到。

在我差不多扫完全部文档之后。大概理解了为什么会有 puppet service 这个东西存在,我的理解是它是一个 grpc 服务端,为了提供多语言的客户端来与他通信,从而达到实际的 puppet 只要实现一种语言的效果。

我看了 go 语言的介绍,使用的时候必须使用 token 的方式,token 可以使用 puppet service 来生成,按照 all-in-one 的脚本我在本机上启动了这个容器,发现的问题有:

  1. 文档中提示明确要求要是公网?我的客户端(就是使用go-wechaty 这个 sdk 的项目)为什么不能直接与容器通信,这样在我本地就能实现完整的流程呢?我的理解微信web 的协议 hook 是 puppet-wechat 插件实现的,已经集成在 wechaty/wechaty 容器里了呀。这个问题我没搜到很明确的答案,望解答。
  2. token 的具体作用是什么呢?目前看出来似乎 token 是 wechaty容器启动后向 api.chatie.io 注册自己,但是注册是为了做什么呢?

烦请解答

Copy link

dosubot bot commented Apr 9, 2024

Hey there, @monotone! Good to see you back with another insightful question. Let's dive into this.

Thank you for your detailed questions. I'll try to provide some clarity on the points you've raised.

  1. The requirement for a public network is to ensure that the Wechaty Puppet Service (WPS) is accessible from anywhere on the internet. This is crucial as Wechaty clients may be running in diverse environments and need to connect to the puppet service without network restrictions. The requirement for a public network is explicitly mentioned in the code comments regarding the port configuration: "This port MUST be public accessible via the internet." You can find this in the src/cli/gateway.ts file.

  2. The token serves as a credential for clients to access the WPS. It's used for authentication and authorization, ensuring that only clients with the correct token can access the puppet service. This provides a layer of security against unauthorized use. The token is either specified by the user or automatically generated if not provided. This token is then used in the service discovery process and must be set in the environment variables for Wechaty programs to authenticate with the DIY token provided by the gateway. You can see this process in the same src/cli/gateway.ts file.

The process for the Wechaty container to register itself with api.chatie.io using the token involves several steps, including token generation or specification, port selection, puppet provider specification, puppet token specification, Wechaty instance creation, IoClient initialization, and a service registration loop. The key part of the registration process with api.chatie.io is handled by the WechatyToken.discover method, which is called in a loop until a successful service discovery and registration is confirmed by receiving a service address.

I hope this helps clarify your questions. If you have any further queries, feel free to ask.

Sources

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@monotone
Copy link
Author

monotone commented Apr 9, 2024

2. serves

  1. 如果 api.chatie.io只是为了提供服务发现。那么当我在本地测试的时候,我的 client 是不是可以直接配置使用容器的服务地址,而无需依赖 api.chatie.io?
  2. 我现在遇到的问题是,按照 all-in-one 介绍的步骤启动了容器之后,我本地的 client 无法连上它,我不知道是不是因为非公网问题导致的

@dosubot 你可以继续回答吗

@monotone
Copy link
Author

monotone commented Apr 9, 2024

此外,我发现容器启动之后就直接提供了一个扫码登录的图片在 wechaty.js.org 上,我好奇的是此时我并没有启动客户端啊。看起来是 wechaty 容器本身也启动了一个客户端去触发 wechat 的登录流程?用途何在呢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant