httpserver
This commit is contained in:
parent
290163871d
commit
fd136460b4
|
|
@ -88,7 +88,9 @@ dependencies {
|
||||||
// https://mvnrepository.com/artifact/com.sun.net.httpserver/http
|
// https://mvnrepository.com/artifact/com.sun.net.httpserver/http
|
||||||
|
|
||||||
// implementation("com.sun.net.httpserver:http:20070405")
|
// 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 'wang.harlon.quickjs:wrapper-java:1.0.0'
|
||||||
// implementation(ext: 'aar', name: 'quickjs', group: 'fongmi', version: 'release')
|
// 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)
|
# 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
|
# to ignore warnings coming from slf4j and logback
|
||||||
|
|
||||||
|
# Please add these rules to your existing keep rules in order to suppress warnings.
|
||||||
-assumenosideeffects class com.hibegin.common.util.LoggerUtil {*;}
|
# 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.
|
# Please add these rules to your existing keep rules in order to suppress warnings.
|
||||||
# This is generated automatically by the Android Gradle plugin.
|
# 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.crawler.SpiderDebug
|
||||||
import com.github.catvod.net.OkHttp
|
import com.github.catvod.net.OkHttp
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import com.hibegin.http.server.SimpleWebServer
|
import klite.Server
|
||||||
import com.hibegin.http.server.WebServerBuilder
|
import java.net.InetSocketAddress
|
||||||
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 java.nio.charset.Charset
|
import java.nio.charset.Charset
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -24,37 +13,34 @@ object ProxyServer {
|
||||||
private val THREAD_NUM = Runtime.getRuntime().availableProcessors() * 2
|
private val THREAD_NUM = Runtime.getRuntime().availableProcessors() * 2
|
||||||
private const val partSize = 1024 * 1024 * 1
|
private const val partSize = 1024 * 1024 * 1
|
||||||
private var port = 12345
|
private var port = 12345
|
||||||
private var httpServer: SimpleWebServer? = null
|
|
||||||
private val infos = mutableMapOf<String, MutableMap<String, MutableList<String>>>();
|
private val infos = mutableMapOf<String, MutableMap<String, MutableList<String>>>();
|
||||||
|
|
||||||
fun stop() {
|
fun stop() {
|
||||||
httpServer?.destroy()
|
stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun start() {
|
fun start() {
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val serverConfig = ServerConfig()
|
Server(InetSocketAddress(port)).apply {
|
||||||
serverConfig.port = port
|
context("/api") {
|
||||||
serverConfig.router.addMapper("/proxy", ProxyController::class.java)
|
get("/hello") { "Hello, world!" }
|
||||||
val builder = WebServerBuilder.Builder().serverConfig(serverConfig).build()
|
}
|
||||||
|
start()
|
||||||
builder.startWithThread()
|
}
|
||||||
httpServer = builder.webServer
|
|
||||||
|
|
||||||
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
SpiderDebug.log("start server e:" + e.message)
|
SpiderDebug.log("start server e:" + e.message)
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
|
||||||
httpServer?.destroy()
|
stop()
|
||||||
}
|
}
|
||||||
SpiderDebug.log("Server start on " + port)
|
SpiderDebug.log("Server start on " + port)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ProxyController : Controller() {
|
/*class ProxyController : Controller() {
|
||||||
fun index() {
|
fun index() {
|
||||||
|
|
||||||
val url = Util.base64Decode(getRequest().getParaToStr("url"))
|
val url = Util.base64Decode(getRequest().getParaToStr("url"))
|
||||||
|
|
@ -176,7 +162,7 @@ object ProxyServer {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
private fun queryToMap(query: String?): Map<String, String>? {
|
private fun queryToMap(query: String?): Map<String, String>? {
|
||||||
if (query == null) {
|
if (query == null) {
|
||||||
return 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": [
|
"lives": [
|
||||||
{
|
{
|
||||||
"name": "电视直播",
|
"name": "电视直播",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue