mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-12 03:37:27 +08:00
[F] Fix url passing
This commit is contained in:
@@ -6,7 +6,6 @@ import jakarta.servlet.http.HttpServletRequest
|
|||||||
import jakarta.servlet.http.HttpServletRequestWrapper
|
import jakarta.servlet.http.HttpServletRequestWrapper
|
||||||
import jakarta.servlet.http.HttpServletResponse
|
import jakarta.servlet.http.HttpServletResponse
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.beans.factory.annotation.Value
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
|
||||||
import org.springframework.context.annotation.Configuration
|
import org.springframework.context.annotation.Configuration
|
||||||
@@ -82,12 +81,17 @@ class TokenChecker(
|
|||||||
/**
|
/**
|
||||||
* Request wrapper for rewriting the URI after token check.
|
* Request wrapper for rewriting the URI after token check.
|
||||||
*/
|
*/
|
||||||
class RewriteWrapper(req: HttpServletRequest, token: Str) : HttpServletRequestWrapper(req) {
|
class RewriteWrapper(val req: HttpServletRequest, token: Str) : HttpServletRequestWrapper(req) {
|
||||||
val replace = "/gs/$token/"
|
val replace = "/gs/$token/"
|
||||||
val newUri = req.requestURI.replace(replace, "/g/")
|
val newUri = req.requestURI.replace(replace, "/g/")
|
||||||
val newUrl = req.requestURL.toString().replace(replace, "/g/")
|
val newUrl = req.requestURL.toString().replace(replace, "/g/")
|
||||||
val newSp = req.servletPath.replace(replace, "/g/")
|
val newSp = req.servletPath.replace(replace, "/g/")
|
||||||
|
|
||||||
|
override fun getHeader(name: String): String? {
|
||||||
|
if (name == "wrapper original url") return req.requestURL.toString()
|
||||||
|
return super.getHeader(name)
|
||||||
|
}
|
||||||
|
|
||||||
override fun getRequestURI() = newUri
|
override fun getRequestURI() = newUri
|
||||||
override fun getRequestURL() = StringBuffer(newUrl)
|
override fun getRequestURL() = StringBuffer(newUrl)
|
||||||
override fun getServletPath() = newSp
|
override fun getServletPath() = newSp
|
||||||
|
|||||||
@@ -214,7 +214,8 @@ fun ChusanServletController.init() {
|
|||||||
val fmt = DateTimeFormatter.ofPattern("uuuu-MM-dd HH:mm:ss")
|
val fmt = DateTimeFormatter.ofPattern("uuuu-MM-dd HH:mm:ss")
|
||||||
|
|
||||||
// Get the request url as te address
|
// Get the request url as te address
|
||||||
val addr = req.requestURL.toString().removeSuffix("GetGameSettingApi")
|
val addr = (req.getHeader("wrapper original url") ?: req.requestURL.toString())
|
||||||
|
.removeSuffix("GetGameSettingApi")
|
||||||
|
|
||||||
mapOf(
|
mapOf(
|
||||||
"gameSetting" to mapOf(
|
"gameSetting" to mapOf(
|
||||||
|
|||||||
Reference in New Issue
Block a user