mirror of
https://github.com/v2rayA/v2rayA.git
synced 2026-11-20 23:02:25 +03:00
PostImport, PutPorts, PutDnsRules, PutRoutingA, PutGFWList,
DeleteGFWList, PutDomainsExcluded, PutTproxyWhiteIpGroups, PostOutbound
and PutOutbound wrote the store and regenerated the core outside the
mutation turn, so two of them could interleave core restarts with each
other or with a latency test. They take it like the rest.
ParseSSURL and ParseVmessURL sliced past the end of a link shorter than
its scheme prefix ("ss:", "vmess:x"), a panic reachable from a
subscription line.
57 lines
1.2 KiB
Go
57 lines
1.2 KiB
Go
package controller
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/v2rayA/v2rayA/common"
|
|
"github.com/v2rayA/v2rayA/kernel/v2ray/asset/dat"
|
|
)
|
|
|
|
func PutGFWList(ctx *gin.Context) {
|
|
release, ok := beginMutation(ctx)
|
|
if !ok {
|
|
return
|
|
}
|
|
defer release()
|
|
var data struct {
|
|
DownloadLink string `json:"downloadLink"`
|
|
}
|
|
err := ctx.ShouldBindJSON(&data)
|
|
if err != nil {
|
|
common.ResponseError(ctx, badRequest("downloadLink", "request body must be {\"downloadLink\": string}"))
|
|
return
|
|
}
|
|
localGFWListVersion, err := dat.CheckAndUpdateGFWList(data.DownloadLink)
|
|
if errors.Is(err, dat.ErrGFWListUpToDate) {
|
|
// Nothing to download is a result, not a failure.
|
|
common.ResponseSuccess(ctx, gin.H{
|
|
"localGFWListVersion": localGFWListVersion,
|
|
"alreadyUpToDate": true,
|
|
})
|
|
return
|
|
}
|
|
if err != nil {
|
|
common.ResponseError(ctx, logError(err))
|
|
return
|
|
}
|
|
common.ResponseSuccess(ctx, gin.H{
|
|
"localGFWListVersion": localGFWListVersion,
|
|
"alreadyUpToDate": false,
|
|
})
|
|
}
|
|
|
|
func DeleteGFWList(ctx *gin.Context) {
|
|
release, ok := beginMutation(ctx)
|
|
if !ok {
|
|
return
|
|
}
|
|
defer release()
|
|
err := dat.DeleteGFWList()
|
|
if err != nil {
|
|
common.ResponseError(ctx, logError(err))
|
|
return
|
|
}
|
|
common.ResponseSuccess(ctx, gin.H{})
|
|
}
|