blob: d10661d6d71358645783b97a4c6095ab7b86beb6 (
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
33
34
35
36
37
38
39
40
41
42
|
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.")
return authIface.Ban(cc.RemoteAddr().(*net.UDPAddr).IP.String(), cc.name)
}
// Unban removes a player from the ban list. It accepts both
// network addresses and player names.
func Unban(id string) error {
return authIface.Unban(id)
}
// Banned reports whether a network address is banned.
func Banned(addr *net.UDPAddr) bool {
return authIface.Banned(addr)
}
|