修复bug
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
4aedaea646
commit
95b30485ea
|
@ -9,7 +9,7 @@ import { config } from './config.js'
|
||||||
export const server = fastify({
|
export const server = fastify({
|
||||||
logger: {
|
logger: {
|
||||||
prettyPrint: true,
|
prettyPrint: true,
|
||||||
level: 'error'
|
// level: 'error'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ export const setup = async () => {
|
||||||
|
|
||||||
server.route(SessionServerRoutings.join)
|
server.route(SessionServerRoutings.join)
|
||||||
server.route(SessionServerRoutings.hasJoined)
|
server.route(SessionServerRoutings.hasJoined)
|
||||||
|
server.route(SessionServerRoutings.profile)
|
||||||
|
|
||||||
config.custom.postRouting(server)
|
config.custom.postRouting(server)
|
||||||
|
|
||||||
|
@ -90,4 +91,4 @@ export const shutdown = async () => {
|
||||||
await setup()
|
await setup()
|
||||||
await launch()
|
await launch()
|
||||||
}
|
}
|
||||||
})
|
})()
|
|
@ -1,6 +1,6 @@
|
||||||
import { getOverrideHandler, getOverridePreHandler } from '../config.js'
|
import { getOverrideHandler, getOverridePreHandler } from '../config.js'
|
||||||
import { toSymboUUID } from '../generator'
|
import { toSymboUUID } from '../generator.js'
|
||||||
import { getPlayerSerialization, PlayerSeriliazationSchema } from '../models/player'
|
import { getPlayerSerialization, PlayerSeriliazationSchema } from '../models/player.js'
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Key: string Username
|
Key: string Username
|
||||||
|
@ -45,7 +45,7 @@ export const join = {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const session = await this.models.Session.findOne({ token: accessToken })
|
const session = await this.models.Token.findOne({ token: accessToken })
|
||||||
if (!session) {
|
if (!session) {
|
||||||
return await rep.code(401).send({
|
return await rep.code(401).send({
|
||||||
error: "IllegalArgumentException",
|
error: "IllegalArgumentException",
|
||||||
|
@ -63,9 +63,9 @@ export const join = {
|
||||||
}
|
}
|
||||||
|
|
||||||
joinServerRequest.set(session.uuid, {
|
joinServerRequest.set(session.uuid, {
|
||||||
accessToken,
|
accessToken: accessToken,
|
||||||
serverId,
|
serverId: serverId,
|
||||||
ip: req.headers['x-forwarded-for'] || req.info.remoteAddress
|
ip: req.headers['x-forwarded-for'] || req.ip
|
||||||
})
|
})
|
||||||
|
|
||||||
await rep.code(204).send()
|
await rep.code(204).send()
|
||||||
|
@ -98,9 +98,21 @@ export const hasJoined = {
|
||||||
preHandler: getOverridePreHandler('/sessionserver/session/minecraft/hasJoined'),
|
preHandler: getOverridePreHandler('/sessionserver/session/minecraft/hasJoined'),
|
||||||
handler: getOverrideHandler('/sessionserver/session/minecraft/hasJoined') ?? async function (req, rep) {
|
handler: getOverrideHandler('/sessionserver/session/minecraft/hasJoined') ?? async function (req, rep) {
|
||||||
const { username, serverId, ip } = req.query
|
const { username, serverId, ip } = req.query
|
||||||
const { ssID, sIP } = joinServerRequest.get(username)
|
|
||||||
|
const player = await this.models.Player.findOne({ username })
|
||||||
|
if (!player) {
|
||||||
|
return await rep.code(400).send({
|
||||||
|
error: "IllegalArgumentException",
|
||||||
|
errorMessage: "请求内容不正确",
|
||||||
|
cause: "用户不存在"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const request = joinServerRequest.get(player.uuid)
|
||||||
|
this.log.info(request)
|
||||||
|
|
||||||
if(ip) {
|
if(ip) {
|
||||||
if(ip !== sIP) {
|
if(ip !== request.ip) {
|
||||||
return await rep.code(401).send({
|
return await rep.code(401).send({
|
||||||
error: "IllegalArgumentException",
|
error: "IllegalArgumentException",
|
||||||
errorMessage: "无效会话",
|
errorMessage: "无效会话",
|
||||||
|
@ -109,7 +121,7 @@ export const hasJoined = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(serverId !== ssID) {
|
if(serverId !== request.serverId) {
|
||||||
return await rep.code(401).send({
|
return await rep.code(401).send({
|
||||||
error: "IllegalArgumentException",
|
error: "IllegalArgumentException",
|
||||||
errorMessage: "无效会话",
|
errorMessage: "无效会话",
|
||||||
|
@ -117,14 +129,6 @@ export const hasJoined = {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const player = await this.models.Player.findOne({ uuid: toSymboUUID(username) })
|
|
||||||
if (!player) {
|
|
||||||
return await rep.code(400).send({
|
|
||||||
error: "IllegalArgumentException",
|
|
||||||
errorMessage: "请求内容不正确",
|
|
||||||
cause: "用户不存在"
|
|
||||||
})
|
|
||||||
}
|
|
||||||
await rep.code(200).send(getPlayerSerialization(player))
|
await rep.code(200).send(getPlayerSerialization(player))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue