fanux / lhttp

go websocket, a better way to buid your IM server
MIT License
691 stars 141 forks source link

请问如何能阻断用户发言? 在 authfilter 里面如何处理? #13

Closed gamegrd closed 6 years ago

gamegrd commented 6 years ago

比如用户并没有验证通过,需要强制断开 又比如说用户消息含有攻击性言论,需要屏蔽

fanux commented 6 years ago

可以开发一个自定义的首部顾虑模块 https://github.com/fanux/lhttp/blob/master/doc/DEVELOP.md 这个模块专门做一些处理。

gamegrd commented 6 years ago

已经做了 authfilter 但是消息是一直向下传递的,且 wsHandler 没有提供清空消息的函数

gamegrd commented 6 years ago

也就是即使写了 filter 消息最后还是会传到 mqHeadFilter 被发布出去

fanux commented 6 years ago

确实应该提供一个丢弃包的方式。设计缺陷,只想了首部过滤模块对包进行处理而没有定义包接下来要怎么走。 https://github.com/fanux/lhttp/blob/master/wsHandler.go#L221 我有时间会修复这块设计,大概方法是给首部过滤模块函数定义返回码,框架根据返回码决定要不要再继续往下走。 这样首部过滤模块的顺序就比较重要了。