httpserver
This commit is contained in:
parent
290163871d
commit
fd136460b4
|
|
@ -88,7 +88,9 @@ dependencies {
|
|||
// https://mvnrepository.com/artifact/com.sun.net.httpserver/http
|
||||
|
||||
// implementation("com.sun.net.httpserver:http:20070405")
|
||||
implementation("com.hibegin:simplewebserver:0.1.15")
|
||||
// implementation("com.hibegin:simplewebserver:0.1.15")
|
||||
implementation("com.github.codeborne.klite:klite-server:1.7.0")
|
||||
|
||||
|
||||
//implementation 'wang.harlon.quickjs:wrapper-java:1.0.0'
|
||||
// implementation(ext: 'aar', name: 'quickjs', group: 'fongmi', version: 'release')
|
||||
|
|
|
|||
|
|
@ -58,8 +58,13 @@
|
|||
# Logback (Custom rules, see https://github.com/krschultz/android-proguard-snippets/blob/master/libraries/proguard-logback-android.pro)
|
||||
# to ignore warnings coming from slf4j and logback
|
||||
|
||||
|
||||
-assumenosideeffects class com.hibegin.common.util.LoggerUtil {*;}
|
||||
# Please add these rules to your existing keep rules in order to suppress warnings.
|
||||
# This is generated automatically by the Android Gradle plugin.
|
||||
-dontwarn com.sun.net.httpserver.HttpContext
|
||||
-dontwarn com.sun.net.httpserver.HttpHandler
|
||||
-dontwarn com.sun.net.httpserver.HttpServer
|
||||
-dontwarn java.lang.System$Logger$Level
|
||||
-dontwarn java.lang.System$Logger
|
||||
|
||||
# Please add these rules to your existing keep rules in order to suppress warnings.
|
||||
# This is generated automatically by the Android Gradle plugin.
|
||||
|
|
|
|||
|
|
@ -4,19 +4,8 @@ package com.github.catvod.utils
|
|||
import com.github.catvod.crawler.SpiderDebug
|
||||
import com.github.catvod.net.OkHttp
|
||||
import com.google.gson.Gson
|
||||
import com.hibegin.http.server.SimpleWebServer
|
||||
import com.hibegin.http.server.WebServerBuilder
|
||||
import com.hibegin.http.server.api.HttpRequest
|
||||
import com.hibegin.http.server.api.HttpResponse
|
||||
import com.hibegin.http.server.config.ServerConfig
|
||||
import com.hibegin.http.server.util.StatusCodeUtil
|
||||
import com.hibegin.http.server.web.Controller
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.ByteArrayOutputStream
|
||||
import klite.Server
|
||||
import java.net.InetSocketAddress
|
||||
import java.nio.charset.Charset
|
||||
|
||||
|
||||
|
|
@ -24,37 +13,34 @@ object ProxyServer {
|
|||
private val THREAD_NUM = Runtime.getRuntime().availableProcessors() * 2
|
||||
private const val partSize = 1024 * 1024 * 1
|
||||
private var port = 12345
|
||||
private var httpServer: SimpleWebServer? = null
|
||||
|
||||
private val infos = mutableMapOf<String, MutableMap<String, MutableList<String>>>();
|
||||
|
||||
fun stop() {
|
||||
httpServer?.destroy()
|
||||
stop()
|
||||
}
|
||||
|
||||
fun start() {
|
||||
|
||||
|
||||
try {
|
||||
val serverConfig = ServerConfig()
|
||||
serverConfig.port = port
|
||||
serverConfig.router.addMapper("/proxy", ProxyController::class.java)
|
||||
val builder = WebServerBuilder.Builder().serverConfig(serverConfig).build()
|
||||
|
||||
builder.startWithThread()
|
||||
httpServer = builder.webServer
|
||||
|
||||
|
||||
Server(InetSocketAddress(port)).apply {
|
||||
context("/api") {
|
||||
get("/hello") { "Hello, world!" }
|
||||
}
|
||||
start()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
SpiderDebug.log("start server e:" + e.message)
|
||||
e.printStackTrace()
|
||||
|
||||
httpServer?.destroy()
|
||||
stop()
|
||||
}
|
||||
SpiderDebug.log("Server start on " + port)
|
||||
|
||||
}
|
||||
|
||||
class ProxyController : Controller() {
|
||||
/*class ProxyController : Controller() {
|
||||
fun index() {
|
||||
|
||||
val url = Util.base64Decode(getRequest().getParaToStr("url"))
|
||||
|
|
@ -176,7 +162,7 @@ object ProxyServer {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
private fun queryToMap(query: String?): Map<String, String>? {
|
||||
if (query == null) {
|
||||
return null
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
7ea431fa6a92ee4ce0bf240561ab1955
|
||||
72e1dea84becb2e4584ddc7433c6229c
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"spider": "https://gh.llkk.cc/https://raw.githubusercontent.com/lushunming/AndroidCatVodSpider/multiThreadNew/jar/custom_spider.jar;md5;7ea431fa6a92ee4ce0bf240561ab1955",
|
||||
"spider": "https://gh.llkk.cc/https://raw.githubusercontent.com/lushunming/AndroidCatVodSpider/multiThreadNew/jar/custom_spider.jar;md5;72e1dea84becb2e4584ddc7433c6229c",
|
||||
"lives": [
|
||||
{
|
||||
"name": "电视直播",
|
||||
|
|
|
|||
Loading…
Reference in New Issue