blob: 00d97b187a55b379e90db2b2dba9baf6de8a74f3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
package proxy
import (
"net"
"github.com/HimbeerserverDE/mt"
)
// Kick sends mt.ToCltKick with the specified custom reason
// and closes the ClientConn.
func (cc *ClientConn) Kick(reason string) {
go func() {
ack, _ := cc.SendCmd(&mt.ToCltKick{
Reason: mt.Custom,
Custom: reason,
})
select {
case <-cc.Closed():
case <-ack:
cc.Close()
}
}()
}
// Ban disconnects the ClientConn and prevents the underlying
// network address from connecting again.
func (cc *ClientConn) Ban() error {
cc.Kick("Banned by proxy.")
ip := cc.RemoteAddr().(*net.UDPAddr).IP.String()
return DefaultAuth().Ban(ip, cc.name)
}
|