package app import "net/http" var ( singBoxRenderedRootDir = stateDir + "/transport/singbox-rendered" singBoxHistoryRootDir = stateDir + "/transport/singbox-history" singBoxAppliedRootDir = stateDir + "/transport/singbox-applied" ) type singBoxProfileHistoryRecord struct { ID string `json:"id"` At string `json:"at"` ProfileID string `json:"profile_id"` Action string `json:"action"` Status string `json:"status"` Code string `json:"code,omitempty"` Message string `json:"message,omitempty"` ProfileRevision int64 `json:"profile_revision,omitempty"` RenderRevision int64 `json:"render_revision,omitempty"` RenderDigest string `json:"render_digest,omitempty"` RenderPath string `json:"render_path,omitempty"` ClientID string `json:"client_id,omitempty"` ConfigPath string `json:"config_path,omitempty"` PrevConfigB64 string `json:"prev_config_b64,omitempty"` PrevConfigExist bool `json:"prev_config_exists,omitempty"` Diff SingBoxProfileRenderDiff `json:"diff"` Errors []SingBoxProfileIssue `json:"errors,omitempty"` Warnings []SingBoxProfileIssue `json:"warnings,omitempty"` } func (r singBoxProfileHistoryRecord) Public() SingBoxProfileHistoryEntry { return SingBoxProfileHistoryEntry{ ID: r.ID, At: r.At, ProfileID: r.ProfileID, Action: r.Action, Status: r.Status, Code: r.Code, Message: r.Message, ProfileRevision: r.ProfileRevision, RenderRevision: r.RenderRevision, RenderDigest: r.RenderDigest, RenderPath: r.RenderPath, ClientID: r.ClientID, } } func handleTransportSingBoxProfileAction(w http.ResponseWriter, r *http.Request, id, action string) { switch action { case "validate": handleTransportSingBoxProfileValidate(w, r, id) case "render": handleTransportSingBoxProfileRender(w, r, id) case "apply": handleTransportSingBoxProfileApply(w, r, id) case "rollback": handleTransportSingBoxProfileRollback(w, r, id) case "history": handleTransportSingBoxProfileHistory(w, r, id) default: http.NotFound(w, r) } }