mirror of
https://github.com/v2rayA/v2rayA.git
synced 2026-10-21 08:46:07 +08:00
ccfc5ca096
Three structural changes that share files, so one commit:
Settings, ports, DNS rules and custom inbounds each carried their own
copy of "store the new value, regenerate the core config, put the old
value back when that fails", and the outbound setting path had no
restore at all. ApplyCoreConfig takes a snapshot function and a store
function and does the sequence once for all five callers; the outbound
setting path restores like the others, and the error names which of
the three steps failed.
configure.Which was the persisted discriminator, the key that locates a
node, and the response row with its latency, link and selected flag at
once. NodeRef {type, id, sub, outbound} is the identity used by the
locator, EqualTo, the connected lists and the group operations; Which
embeds it and keeps the status fields. The JSON stays byte for byte
what it was (a test marshals a fixture before and after), stored
connected lists decode unchanged, and deduplication keys by identity
instead of by the whole row.
db.List* dispatched on "bucket/key" string literals to reach the
servers and subscriptions tables. The bodies are now Servers* and
Subscriptions* functions that configure calls directly; the List*
wrappers remain for the migration.
25 lines
665 B
Go
25 lines
665 B
Go
package controller
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/json-iterator/go"
|
|
"github.com/v2rayA/v2rayA/common"
|
|
"github.com/v2rayA/v2rayA/db/configure"
|
|
"github.com/v2rayA/v2rayA/server/service"
|
|
)
|
|
|
|
func GetSharingAddress(ctx *gin.Context) {
|
|
var w configure.NodeRef
|
|
err := jsoniter.Unmarshal([]byte(ctx.Query("touch")), &w)
|
|
if err != nil {
|
|
common.ResponseError(ctx, badRequest("touch", "query parameter \"touch\" must be a JSON server or subscription item"))
|
|
return
|
|
}
|
|
addr, err := service.GetSharingAddress(&w)
|
|
if err != nil {
|
|
common.ResponseError(ctx, logError(err))
|
|
return
|
|
}
|
|
common.ResponseSuccess(ctx, gin.H{"sharingAddress": addr})
|
|
}
|