+ // If FieldOptions is set, then the client IP is banned in addition to disconnected.
+ // 00 01 = temporary ban
+ // 00 02 = permanent ban
+ if t.GetField(FieldOptions).Data != nil {
+ switch t.GetField(FieldOptions).Data[1] {
+ case 1:
+ // send message: "You are temporarily banned on this server"
+ cc.logger.Info("Disconnect & temporarily ban " + string(clientConn.UserName))
+
+ res = append(res, *NewTransaction(
+ TranServerMsg,
+ clientConn.ID,
+ NewField(FieldData, []byte("You are temporarily banned on this server")),
+ NewField(FieldChatOptions, []byte{0, 0}),
+ ))
+
+ banUntil := time.Now().Add(tempBanDuration)
+ cc.Server.banList[strings.Split(clientConn.RemoteAddr, ":")[0]] = &banUntil
+ case 2:
+ // send message: "You are permanently banned on this server"
+ cc.logger.Info("Disconnect & ban " + string(clientConn.UserName))
+
+ res = append(res, *NewTransaction(
+ TranServerMsg,
+ clientConn.ID,
+ NewField(FieldData, []byte("You are permanently banned on this server")),
+ NewField(FieldChatOptions, []byte{0, 0}),
+ ))
+
+ cc.Server.banList[strings.Split(clientConn.RemoteAddr, ":")[0]] = nil
+ }
+
+ err := cc.Server.writeBanList()
+ if err != nil {
+ return res, err
+ }