mirror of
https://gitea.tendokyu.moe/CharaLol/Yukiotoko.git
synced 2026-09-22 22:38:05 +03:00
Implement banlist
This commit is contained in:
@@ -116,7 +116,7 @@ app.post('/MatchingServer/:api', async (req, res) => {
|
||||
service: 'Yukiotoko Matching',
|
||||
message: `BeginMatching`,
|
||||
})
|
||||
return res.json(await beginMatching(body))
|
||||
return res.json(await beginMatching(body, req.ip))
|
||||
} else
|
||||
if (mEndMatchingApi.includes(api)){
|
||||
log.info({
|
||||
|
||||
@@ -14,7 +14,45 @@ export const pingMatching = () => {
|
||||
return { returnCode: 1 }
|
||||
}
|
||||
|
||||
export const beginMatching = async body => {
|
||||
export const beginMatching = async (body, ip) => {
|
||||
//Check if user is banned
|
||||
const banList = await db.chusanGameBanlist.findMany()
|
||||
var banResult: any
|
||||
banList.forEach(banEntry =>{
|
||||
switch (banEntry.type){
|
||||
//Keychip Ban
|
||||
case 1: {
|
||||
if (body.matchingMemberInfo.clientId == banEntry.value) {
|
||||
banResult = {
|
||||
message: "Cabinet Is Banned."
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
//UserID + Name ban
|
||||
case 2: {
|
||||
if (body.matchingMemberInfo.userId == banEntry.value && convertIso88591ToUtf8(body.matchingMemberInfo.userName) == banEntry.value2) {
|
||||
banResult = {
|
||||
message: "User Is Banned."
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
//IP Ban
|
||||
case 3: {
|
||||
if (ip == banEntry.value) {
|
||||
banResult = {
|
||||
message: "User Is Banned."
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
default:
|
||||
}
|
||||
})
|
||||
if (banResult != null){
|
||||
return banResult
|
||||
}
|
||||
var matchingrooms = await db.chusanUserMatching.findMany()
|
||||
matchingrooms.forEach(async (room) => {
|
||||
var olddate = new Date(room.updatedAt)
|
||||
|
||||
@@ -25,7 +25,14 @@ model ChusanUserMatching {
|
||||
allowAnybody Boolean
|
||||
updatedAt DateTime
|
||||
mergedRoom Int?
|
||||
|
||||
}
|
||||
|
||||
model ChusanGameBanlist {
|
||||
id String @id @default(cuid())
|
||||
type Int
|
||||
value String
|
||||
value2 String?
|
||||
note String?
|
||||
}
|
||||
|
||||
model ChusanUserRooms {
|
||||
|
||||
Reference in New Issue
Block a user