Skip to content

Commit

Permalink
improvement: clash api security
Browse files Browse the repository at this point in the history
  • Loading branch information
snakem982 committed Oct 4, 2024
1 parent 3c4e12b commit 65e2c1e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
7 changes: 7 additions & 0 deletions backend/meta/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"runtime"
"strings"
"sync"
"time"
)

//go:embed geoip.metadb
Expand Down Expand Up @@ -205,5 +206,11 @@ func StartCore(profile resolve.Profile, reload bool) {
NowConfig.General.MixedPort = freePort
}

// 垃圾回收
go func() {
time.Sleep(3 * time.Minute)
runtime.GC()
}()

executor.ApplyConfig(NowConfig, true)
}
7 changes: 7 additions & 0 deletions backend/spider/spider.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"pandora-box/backend/premium"
"pandora-box/backend/tools"
"path/filepath"
"runtime"
"sort"
"strings"
"sync"
Expand Down Expand Up @@ -106,6 +107,12 @@ func Crawl() bool {
// 清理realIp缓存
go cleanRealIpCache()

// 垃圾回收
go func() {
time.Sleep(2 * time.Minute)
runtime.GC()
}()

return true
}

Expand Down
8 changes: 7 additions & 1 deletion frontend/src/views/Profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {ClipboardGetText, ClipboardSetText} from "../../wailsjs/runtime";
import {mdiDownload, mdiFileReplace, mdiFolderOpen} from "@mdi/js";
import SvgIcon from "@jamescoyle/vue-icon";
import {useRouter} from "vue-router";
import {GetFreePort} from "../../wailsjs/go/main/App";
import {GetFreePort, GetSecret} from "../../wailsjs/go/main/App";
const subOrShare = ref('')
const drawer = ref(false)
Expand Down Expand Up @@ -94,11 +94,16 @@ async function delProfile(id: string) {
}
const uploadUrl = ref('')
const uploadHeader = reactive({
Authorization: ''
})
onMounted(async () => {
await getProfile()
const host = await GetFreePort()
uploadUrl.value = "http://" + host + "/profile/file"
const secret = await GetSecret()
uploadHeader.Authorization = 'Bearer ' + secret
})
const toolFormVisible = ref(false)
Expand Down Expand Up @@ -420,6 +425,7 @@ function toCrawl() {
:on-error="uploadError"
:on-success="uploadSuccess"
ref="drawerUpload"
:headers = uploadHeader
>
<el-icon size="50" class="el-icon--upload">
<UploadFilled/>
Expand Down

0 comments on commit 65e2c1e

Please sign in to comment.