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

Support handshake data validator #69

Merged
merged 5 commits into from
Dec 10, 2020
Merged

Conversation

NicholasChan1025
Copy link
Contributor

@NicholasChan1025 NicholasChan1025 commented Dec 8, 2020

What problem does this PR solve?

Fix: #68
解决issue68 自定义握手数据验证,验证失败则握手失败

添加握手验证hook
processPacket ,添加校验握手数据
新增WithHandshakeValidator 方法
修正‘=’缺失
Copy link
Owner

@lonng lonng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please format your code.

@lonng lonng changed the title 新增自定义handshake数据验证方式 Support handshake data validator Dec 8, 2020
@@ -252,6 +252,12 @@ func (h *LocalHandler) handle(conn net.Conn) {
func (h *LocalHandler) processPacket(agent *agent, p *packet.Packet) error {
switch p.Type {
case packet.Handshake:

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the blank line.

Comment on lines 53 to 54


Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add two blank lines.

@@ -38,6 +38,7 @@ var (
CheckOrigin func(*http.Request) bool // check origin when websocket enabled
Debug bool // enable Debug
WSPath string // WebSocket path(eg: ws://127.0.0.1/WSPath)
HandshakeValidator func([]byte) error // When you need to verify the custom data of the handshake request
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Format code.

Serializer = protobuf.NewSerializer()

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the blank line.

@NicholasChan1025
Copy link
Contributor Author

Format Code Success

@lonng
Copy link
Owner

lonng commented Dec 10, 2020

@NicholasChan1025 Thanks for your contribution.

Copy link
Owner

@lonng lonng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lonng lonng merged commit e51e7f3 into lonng:master Dec 10, 2020
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

Successfully merging this pull request may close these issues.

Handshake Package 中如何自定义握手数据验证
2 participants