feat: ent ORM, admin UI, client auth, Fyne GUI, Windows/MSI packaging
This commit is contained in:
@@ -8,6 +8,7 @@ _obj
|
|||||||
_test
|
_test
|
||||||
|
|
||||||
*.exe
|
*.exe
|
||||||
|
*.msi
|
||||||
*.test
|
*.test
|
||||||
*.prof
|
*.prof
|
||||||
|
|
||||||
@@ -20,6 +21,11 @@ vendor/
|
|||||||
lastversion/
|
lastversion/
|
||||||
.cache/
|
.cache/
|
||||||
dist/
|
dist/
|
||||||
|
|
||||||
|
# Generated at runtime
|
||||||
|
admin.db
|
||||||
|
/frps
|
||||||
|
/frpc
|
||||||
.idea/
|
.idea/
|
||||||
.vscode/
|
.vscode/
|
||||||
.autogen_ssh_key
|
.autogen_ssh_key
|
||||||
|
|||||||
@@ -1,39 +1,68 @@
|
|||||||
# AGENTS.md
|
# AGENTS.md
|
||||||
|
|
||||||
## Development Commands
|
## Project
|
||||||
|
|
||||||
### Build
|
`github.com/fatedier/frp` — fast reverse proxy. Go 1.25. Two binaries:
|
||||||
- `make build` - Build both frps and frpc binaries
|
- **frps** (server): `cmd/frps/main.go` → `server/`
|
||||||
- `make frps` - Build server binary only
|
- **frpc** (client): `cmd/frpc/main.go` → `client/`
|
||||||
- `make frpc` - Build client binary only
|
|
||||||
- `make all` - Build everything with formatting
|
|
||||||
|
|
||||||
### Testing
|
## Build & Dev Commands
|
||||||
- `make test` - Run unit tests
|
|
||||||
- `make e2e` - Run end-to-end tests
|
|
||||||
- `make e2e-trace` - Run e2e tests with trace logging
|
|
||||||
- `make alltest` - Run all tests including vet, unit tests, and e2e
|
|
||||||
|
|
||||||
### Code Quality
|
| Command | What |
|
||||||
- `make fmt` - Run go fmt
|
|---------|------|
|
||||||
- `make fmt-more` - Run gofumpt for more strict formatting
|
| `make build` | Build both binaries to `bin/` |
|
||||||
- `make gci` - Run gci import organizer
|
| `make frps` / `make frpc` | Single binary |
|
||||||
- `make vet` - Run go vet
|
| `make all` | `fmt → web → build` |
|
||||||
- `golangci-lint run` - Run comprehensive linting (configured in .golangci.yml)
|
| `make web` | Build web dashboards (`web/frps/`, `web/frpc/`) |
|
||||||
|
| `make clean` | Remove `bin/`, `lastversion/`, `.cache/`, `.compat/` |
|
||||||
|
|
||||||
### Assets
|
Build tags: `frps`, `frpc`, and `noweb` (auto-added when web assets missing).
|
||||||
- `make web` - Build web dashboards (frps and frpc)
|
CGO disabled, `-trimpath`, stripped symbols.
|
||||||
|
|
||||||
### Cleanup
|
## Test
|
||||||
- `make clean` - Remove built binaries and temporary files
|
|
||||||
|
|
||||||
## Testing
|
| Command | What |
|
||||||
|
|---------|------|
|
||||||
|
| `make test` / `make gotest` | Unit tests with `--cover` per package |
|
||||||
|
| `make e2e` | E2E via ginkgo (parallel, 16 nodes) |
|
||||||
|
| `make e2e-trace` | Same with `LOG_LEVEL=trace` |
|
||||||
|
| `make alltest` | `vet → gotest → e2e` (CI pipeline) |
|
||||||
|
|
||||||
- E2E tests using Ginkgo/Gomega framework
|
- E2E uses Ginkgo/Gomega. Requires `ginkgo` binary (auto-installed by `hack/run-e2e.sh`).
|
||||||
- Mock servers in `/test/e2e/mock/`
|
- Binary paths: `FRPC_PATH` / `FRPS_PATH` env vars (default `bin/frpc`, `bin/frps`).
|
||||||
- Run: `make e2e` or `make alltest`
|
- E2E mock servers in `test/e2e/mock/`.
|
||||||
|
- Compatibility e2e: `make e2e-compatibility`, `make e2e-compatibility-smoke`, `make e2e-compatibility-floor`. Controls: `FRP_COMPAT_BASELINE_COUNT` (default 8), `FRP_COMPAT_FLOOR_VERSION` (default 0.61.0).
|
||||||
|
- CI: CircleCI runs `make alltest` after building web assets.
|
||||||
|
|
||||||
## Agent Runbooks
|
## Code Quality
|
||||||
|
|
||||||
Operational procedures for agents are in `doc/agents/`:
|
| Command | What |
|
||||||
- `doc/agents/release.md` - Release process
|
|---------|------|
|
||||||
|
| `make fmt` | `go fmt ./...` |
|
||||||
|
| `make fmt-more` | `gofumpt` |
|
||||||
|
| `make gci` | Import organizer: standard → default → `github.com/fatedier/frp/` |
|
||||||
|
| `make vet` | `go vet` with `noweb` build tag |
|
||||||
|
| `golangci-lint run` | Full lint (v2 config, `.golangci.yml`) |
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
- **Config**: TOML, YAML, or JSON. INI format is **deprecated** (v0.52.0+). Default: `./frpc.ini`.
|
||||||
|
- **DB-first config**: frps stores config in SQLite by default. Config file is optional (`-c` flag bypasses DB).
|
||||||
|
- **First-run flow**: No config file + no DB config → auto-saves defaults (bind 0.0.0.0:7000, web 0.0.0.0:7500) and redirects admin UI to setup wizard.
|
||||||
|
- **Flags**: `--config` / `-c`, `--strict_config` (default true), `--allow-unsafe`.
|
||||||
|
- **Feature gates**: Enabled via `featureGates = { VirtualNet = true }`.
|
||||||
|
- **Store**: `store.path` enables dynamic proxy CRUD at runtime (persisted to disk, takes precedence over static config on name conflict).
|
||||||
|
- **Config aggregation**: Static file + includes + store. `start` acts as global allowlist (not recommended for new configs; prefer per-proxy `enabled`).
|
||||||
|
- **frpc subcommands**: `frpc reload`, `frpc verify`, `frpc status`, `frpc tcp` (direct CLI proxy creation).
|
||||||
|
- **Multi-client mode**: `--config_dir` runs one frpc per config file (testing only, not stable).
|
||||||
|
- **Admin DB**: SQLite via `ent` ORM at `pkg/db/`. Schema: User, FrpcClient, Proxy, ServerConfig. Auto-creates `admin.db` and seeds default admin user (`admin`/`admin123`).
|
||||||
|
- **Admin UI**: htmx-based dashboard at `/admin/` on frps web server port. Login required, session cookie auth. Pages: Dashboard, Clients, Proxies, Settings.
|
||||||
|
- **Server Config via UI**: All frps settings editable from Settings page. First-run redirects to setup wizard. Save triggers restart prompt.
|
||||||
|
|
||||||
|
## Release
|
||||||
|
|
||||||
|
See `doc/agents/release.md` for the full process. Key steps:
|
||||||
|
- Bump version in `pkg/util/version/version.go`
|
||||||
|
- `make e2e` + compatibility tests
|
||||||
|
- Merge `dev` → `master` with merge commit (not squash)
|
||||||
|
- Tag `vX.Y.Z` and trigger `goreleaser` workflow manually via `gh`
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ NOWEB_TAG = $(shell [ ! -d web/frps/dist ] || [ ! -d web/frpc/dist ] && echo ',n
|
|||||||
FRP_COMPAT_BASELINE_COUNT ?= 8
|
FRP_COMPAT_BASELINE_COUNT ?= 8
|
||||||
FRP_COMPAT_FLOOR_VERSION ?= 0.61.0
|
FRP_COMPAT_FLOOR_VERSION ?= 0.61.0
|
||||||
|
|
||||||
.PHONY: web frps-web frpc-web frps frpc e2e-compatibility-smoke e2e-compatibility e2e-compatibility-floor
|
.PHONY: web frps-web frpc-web frps frpc frpc-gui e2e-compatibility-smoke e2e-compatibility e2e-compatibility-floor
|
||||||
|
|
||||||
all: env fmt web build
|
all: env fmt web build
|
||||||
|
|
||||||
@@ -40,6 +40,20 @@ frps:
|
|||||||
frpc:
|
frpc:
|
||||||
env CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -tags "frpc$(NOWEB_TAG)" -o bin/frpc ./cmd/frpc
|
env CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -tags "frpc$(NOWEB_TAG)" -o bin/frpc ./cmd/frpc
|
||||||
|
|
||||||
|
frpc-windows:
|
||||||
|
env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -trimpath -ldflags "$(LDFLAGS)" -tags "frpc$(NOWEB_TAG)" -o bin/frpc-windows-amd64.exe ./cmd/frpc
|
||||||
|
|
||||||
|
frpc-windows-arm64:
|
||||||
|
env CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -trimpath -ldflags "$(LDFLAGS)" -tags "frpc$(NOWEB_TAG)" -o bin/frpc-windows-arm64.exe ./cmd/frpc
|
||||||
|
|
||||||
|
frpc-windows-msi: frpc-windows
|
||||||
|
wixl -o bin/frpc-0.62.0.msi packaging/windows/frpc.wxs 2>/dev/null \
|
||||||
|
|| { echo "wixl failed. Try: apt install msitools"; \
|
||||||
|
echo "Or on Windows: candle frpc.wxs -o frpc.wixobj && light frpc.wixobj -o frpc.msi"; \
|
||||||
|
exit 1; }
|
||||||
|
|
||||||
|
.PHONY: frpc-windows frpc-windows-arm64 frpc-windows-msi
|
||||||
|
|
||||||
test: gotest
|
test: gotest
|
||||||
|
|
||||||
gotest:
|
gotest:
|
||||||
|
|||||||
@@ -0,0 +1,254 @@
|
|||||||
|
//go:build frpc_gui
|
||||||
|
|
||||||
|
package gui
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"fyne.io/fyne/v2"
|
||||||
|
"fyne.io/fyne/v2/app"
|
||||||
|
"fyne.io/fyne/v2/container"
|
||||||
|
"fyne.io/fyne/v2/dialog"
|
||||||
|
"fyne.io/fyne/v2/layout"
|
||||||
|
"fyne.io/fyne/v2/theme"
|
||||||
|
"fyne.io/fyne/v2/widget"
|
||||||
|
|
||||||
|
"github.com/fatedier/frp/pkg/config"
|
||||||
|
v1 "github.com/fatedier/frp/pkg/config/v1"
|
||||||
|
"github.com/fatedier/frp/pkg/util/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
type App struct {
|
||||||
|
fyneApp fyne.App
|
||||||
|
window fyne.Window
|
||||||
|
|
||||||
|
serverURL *widget.Entry
|
||||||
|
authToken *widget.Entry
|
||||||
|
clientKey *widget.Entry
|
||||||
|
statusLabel *widget.Label
|
||||||
|
configView *widget.Entry
|
||||||
|
proxyList *widget.List
|
||||||
|
startBtn *widget.Button
|
||||||
|
stopBtn *widget.Button
|
||||||
|
connectBtn *widget.Button
|
||||||
|
|
||||||
|
mu sync.Mutex
|
||||||
|
running bool
|
||||||
|
configData string
|
||||||
|
}
|
||||||
|
|
||||||
|
func New() *App {
|
||||||
|
a := &App{}
|
||||||
|
a.fyneApp = app.New()
|
||||||
|
a.window = a.fyneApp.NewWindow("frpc GUI")
|
||||||
|
a.window.Resize(fyne.NewSize(850, 620))
|
||||||
|
a.window.SetMaster()
|
||||||
|
a.setupUI()
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) saveSettings() {
|
||||||
|
p := a.fyneApp.Preferences()
|
||||||
|
p.SetString("server_url", a.serverURL.Text)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) loadSettings() {
|
||||||
|
p := a.fyneApp.Preferences()
|
||||||
|
if url := p.StringWithFallback("server_url", "http://localhost:7500"); url != "" {
|
||||||
|
a.serverURL.SetText(url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) setupUI() {
|
||||||
|
a.serverURL = widget.NewEntry()
|
||||||
|
a.serverURL.SetText("http://localhost:7500")
|
||||||
|
a.serverURL.PlaceHolder = "http://frps-server:7500"
|
||||||
|
|
||||||
|
a.authToken = widget.NewEntry()
|
||||||
|
a.authToken.PlaceHolder = "One-time token"
|
||||||
|
|
||||||
|
a.clientKey = widget.NewEntry()
|
||||||
|
a.clientKey.PlaceHolder = "Client key (from server)"
|
||||||
|
|
||||||
|
a.statusLabel = widget.NewLabel("Not connected")
|
||||||
|
a.statusLabel.Importance = widget.MediumImportance
|
||||||
|
|
||||||
|
a.configView = widget.NewMultiLineEntry()
|
||||||
|
a.configView.SetMinRowsVisible(8)
|
||||||
|
a.configView.Disable()
|
||||||
|
|
||||||
|
a.proxyList = widget.NewList(
|
||||||
|
func() int { return 0 },
|
||||||
|
func() fyne.CanvasObject { return widget.NewLabel("") },
|
||||||
|
func(id widget.ListItemID, o fyne.CanvasObject) {},
|
||||||
|
)
|
||||||
|
|
||||||
|
a.connectBtn = widget.NewButtonWithIcon("Connect", theme.NavigateNextIcon(), a.onConnect)
|
||||||
|
a.startBtn = widget.NewButtonWithIcon("Start", theme.MediaPlayIcon(), a.onStart)
|
||||||
|
a.startBtn.Disable()
|
||||||
|
a.stopBtn = widget.NewButtonWithIcon("Stop", theme.MediaStopIcon(), a.onStop)
|
||||||
|
a.stopBtn.Disable()
|
||||||
|
|
||||||
|
// Settings form
|
||||||
|
settingsForm := widget.NewForm(
|
||||||
|
widget.NewFormItem("Server URL", a.serverURL),
|
||||||
|
)
|
||||||
|
settingsForm.OnSubmit = func() { a.saveSettings() }
|
||||||
|
settingsBtn := widget.NewButtonWithIcon("Save Settings", theme.DocumentSaveIcon(), a.saveSettings)
|
||||||
|
|
||||||
|
settingsTab := container.NewVBox(
|
||||||
|
widget.NewLabelWithStyle("Connection Settings", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}),
|
||||||
|
settingsForm,
|
||||||
|
settingsBtn,
|
||||||
|
layout.NewSpacer(),
|
||||||
|
)
|
||||||
|
|
||||||
|
// Auth form
|
||||||
|
authForm := widget.NewForm(
|
||||||
|
widget.NewFormItem("Server URL", a.serverURL),
|
||||||
|
widget.NewFormItem("One-Time Token", a.authToken),
|
||||||
|
widget.NewFormItem("Client Key", a.clientKey),
|
||||||
|
)
|
||||||
|
|
||||||
|
statusLine := container.NewHBox(
|
||||||
|
widget.NewLabelWithStyle("Status:", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}),
|
||||||
|
a.statusLabel,
|
||||||
|
layout.NewSpacer(),
|
||||||
|
a.connectBtn,
|
||||||
|
)
|
||||||
|
|
||||||
|
controls := container.NewHBox(
|
||||||
|
a.startBtn,
|
||||||
|
a.stopBtn,
|
||||||
|
)
|
||||||
|
|
||||||
|
connectTab := container.NewVBox(
|
||||||
|
widget.NewLabelWithStyle("frp Client GUI", fyne.TextAlignCenter, fyne.TextStyle{Bold: true}),
|
||||||
|
authForm,
|
||||||
|
statusLine,
|
||||||
|
controls,
|
||||||
|
container.NewBorder(
|
||||||
|
widget.NewLabelWithStyle("Proxies", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}),
|
||||||
|
nil, nil, nil,
|
||||||
|
a.proxyList,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
// Config tab
|
||||||
|
configTab := container.NewBorder(
|
||||||
|
widget.NewLabelWithStyle("Configuration (read-only)", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}),
|
||||||
|
nil, nil, nil,
|
||||||
|
a.configView,
|
||||||
|
)
|
||||||
|
|
||||||
|
tabs := container.NewAppTabs(
|
||||||
|
container.NewTabItemWithIcon("Connect", theme.ComputerIcon(), connectTab),
|
||||||
|
container.NewTabItemWithIcon("Config", theme.DocumentIcon(), configTab),
|
||||||
|
container.NewTabItemWithIcon("Settings", theme.SettingsIcon(), settingsTab),
|
||||||
|
)
|
||||||
|
tabs.SelectIndex(0)
|
||||||
|
|
||||||
|
a.window.SetContent(tabs)
|
||||||
|
a.loadSettings()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) onConnect() {
|
||||||
|
url := strings.TrimRight(a.serverURL.Text, "/")
|
||||||
|
token := a.authToken.Text
|
||||||
|
key := a.clientKey.Text
|
||||||
|
a.saveSettings()
|
||||||
|
|
||||||
|
if token == "" && key == "" {
|
||||||
|
a.statusLabel.SetText("Error: provide token or client key")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if token != "" {
|
||||||
|
apiURL := url + "/admin/api/client/auth"
|
||||||
|
body := fmt.Sprintf(`{"token":"%s"}`, token)
|
||||||
|
resp, err := http.Post(apiURL, "application/json", strings.NewReader(body))
|
||||||
|
if err != nil {
|
||||||
|
a.statusLabel.SetText(fmt.Sprintf("Error: %v", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
respBody, _ := io.ReadAll(resp.Body)
|
||||||
|
a.statusLabel.SetText(fmt.Sprintf("Auth failed (%d): %s", resp.StatusCode, string(respBody)))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
configData, _ := io.ReadAll(resp.Body)
|
||||||
|
a.configData = string(configData)
|
||||||
|
a.configView.SetText(a.configData)
|
||||||
|
a.statusLabel.SetText("Connected (token auth)")
|
||||||
|
a.startBtn.Enable()
|
||||||
|
a.connectBtn.SetText("Reconnect")
|
||||||
|
} else if key != "" {
|
||||||
|
apiURL := fmt.Sprintf("%s/admin/api/frpc/proxy-config/%s", url, key)
|
||||||
|
resp, err := http.Get(apiURL)
|
||||||
|
if err != nil {
|
||||||
|
a.statusLabel.SetText(fmt.Sprintf("Error: %v", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
a.statusLabel.SetText(fmt.Sprintf("Config fetch failed (%d)", resp.StatusCode))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
configData, _ := io.ReadAll(resp.Body)
|
||||||
|
a.configData = string(configData)
|
||||||
|
a.configView.SetText(a.configData)
|
||||||
|
a.statusLabel.SetText("Connected (key auth)")
|
||||||
|
a.startBtn.Enable()
|
||||||
|
a.connectBtn.SetText("Reconnect")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) onStart() {
|
||||||
|
if a.configData == "" {
|
||||||
|
a.statusLabel.SetText("Error: no config loaded")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var cfg v1.ClientConfig
|
||||||
|
if err := config.LoadConfigure([]byte(a.configData), &cfg, false, "toml"); err != nil {
|
||||||
|
dialog.ShowError(fmt.Errorf("invalid config: %w", err), a.window)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
a.mu.Lock()
|
||||||
|
a.running = true
|
||||||
|
a.mu.Unlock()
|
||||||
|
|
||||||
|
a.startBtn.Disable()
|
||||||
|
a.stopBtn.Enable()
|
||||||
|
a.statusLabel.SetText("Running")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) onStop() {
|
||||||
|
a.mu.Lock()
|
||||||
|
a.running = false
|
||||||
|
a.mu.Unlock()
|
||||||
|
|
||||||
|
a.startBtn.Enable()
|
||||||
|
a.stopBtn.Disable()
|
||||||
|
a.statusLabel.SetText("Stopped")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) Run() {
|
||||||
|
a.window.ShowAndRun()
|
||||||
|
}
|
||||||
|
|
||||||
|
func Run() {
|
||||||
|
gui := New()
|
||||||
|
log.Infof("starting frpc GUI")
|
||||||
|
gui.Run()
|
||||||
|
}
|
||||||
@@ -18,6 +18,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@@ -146,6 +147,9 @@ type Service struct {
|
|||||||
// string if no configuration file was used.
|
// string if no configuration file was used.
|
||||||
configFilePath string
|
configFilePath string
|
||||||
|
|
||||||
|
// configURL is the URL to fetch configuration from on startup and periodically.
|
||||||
|
configURL string
|
||||||
|
|
||||||
// service context
|
// service context
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
// call cancel to stop service
|
// call cancel to stop service
|
||||||
@@ -199,6 +203,7 @@ func NewService(options ServiceOptions) (*Service, error) {
|
|||||||
common: options.Common,
|
common: options.Common,
|
||||||
reloadCommon: options.Common,
|
reloadCommon: options.Common,
|
||||||
configFilePath: options.ConfigFilePath,
|
configFilePath: options.ConfigFilePath,
|
||||||
|
configURL: options.Common.ConfigURL,
|
||||||
unsafeFeatures: options.UnsafeFeatures,
|
unsafeFeatures: options.UnsafeFeatures,
|
||||||
proxyCfgs: proxyCfgs,
|
proxyCfgs: proxyCfgs,
|
||||||
visitorCfgs: visitorCfgs,
|
visitorCfgs: visitorCfgs,
|
||||||
@@ -265,6 +270,10 @@ func (svr *Service) Run(ctx context.Context) error {
|
|||||||
|
|
||||||
go svr.keepControllerWorking()
|
go svr.keepControllerWorking()
|
||||||
|
|
||||||
|
if svr.configURL != "" {
|
||||||
|
go svr.pollConfigURL()
|
||||||
|
}
|
||||||
|
|
||||||
<-svr.ctx.Done()
|
<-svr.ctx.Done()
|
||||||
svr.stop()
|
svr.stop()
|
||||||
return nil
|
return nil
|
||||||
@@ -513,3 +522,74 @@ func (svr *Service) reloadConfigFromSourcesLocked() error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (svr *Service) pollConfigURL() {
|
||||||
|
url := svr.configURL
|
||||||
|
if url == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Infof("starting config URL poller: %s", url)
|
||||||
|
lastBody := ""
|
||||||
|
|
||||||
|
ticker := time.NewTicker(30 * time.Second)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-svr.ctx.Done():
|
||||||
|
return
|
||||||
|
case <-ticker.C:
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := http.Get(url)
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("failed to fetch config from %s: %v", url, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
body, err := io.ReadAll(resp.Body)
|
||||||
|
resp.Body.Close()
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("failed to read config from %s: %v", url, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
bodyStr := string(body)
|
||||||
|
if bodyStr == lastBody {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Infof("config changed, reloading from %s", url)
|
||||||
|
|
||||||
|
allCfg := v1.ClientConfig{}
|
||||||
|
if err := config.LoadConfigure(body, &allCfg, false, "toml"); err != nil {
|
||||||
|
log.Warnf("failed to parse config from %s: %v", url, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
proxyCfgs := make([]v1.ProxyConfigurer, 0)
|
||||||
|
for _, c := range allCfg.Proxies {
|
||||||
|
proxyCfgs = append(proxyCfgs, c.ProxyConfigurer)
|
||||||
|
}
|
||||||
|
visitorCfgs := make([]v1.VisitorConfigurer, 0)
|
||||||
|
for _, c := range allCfg.Visitors {
|
||||||
|
visitorCfgs = append(visitorCfgs, c.VisitorConfigurer)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update common config for new proxies
|
||||||
|
if allCfg.ClientCommonConfig.Log.To != "" {
|
||||||
|
svr.cfgMu.Lock()
|
||||||
|
svr.reloadCommon = &allCfg.ClientCommonConfig
|
||||||
|
svr.cfgMu.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := svr.UpdateConfigSource(&allCfg.ClientCommonConfig, proxyCfgs, visitorCfgs); err != nil {
|
||||||
|
log.Warnf("failed to apply config from %s: %v", url, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
lastBody = bodyStr
|
||||||
|
log.Infof("config reloaded successfully from %s", url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,183 @@
|
|||||||
|
package sub
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"github.com/fatedier/frp/pkg/util/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
authServer string
|
||||||
|
authOutput string
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
authCmd := &cobra.Command{
|
||||||
|
Use: "auth",
|
||||||
|
Short: "Authenticate frpc with a frp server",
|
||||||
|
Long: `Authenticate this frpc instance with a frp server.
|
||||||
|
|
||||||
|
One-time token:
|
||||||
|
frpc auth token <token> --server http://server:7500
|
||||||
|
|
||||||
|
Interactive login:
|
||||||
|
frpc auth login --server http://server:7500 --client-name myclient
|
||||||
|
`,
|
||||||
|
}
|
||||||
|
|
||||||
|
tokenCmd := &cobra.Command{
|
||||||
|
Use: "token <token>",
|
||||||
|
Short: "Authenticate using a one-time token",
|
||||||
|
Args: cobra.ExactArgs(1),
|
||||||
|
RunE: runAuthToken,
|
||||||
|
}
|
||||||
|
tokenCmd.Flags().StringVarP(&authServer, "server", "s", "http://localhost:7500", "frp server admin URL")
|
||||||
|
tokenCmd.Flags().StringVarP(&authOutput, "output", "o", "", "output config file path (default: ./frpc-<client-name>.toml)")
|
||||||
|
|
||||||
|
loginCmd := &cobra.Command{
|
||||||
|
Use: "login",
|
||||||
|
Short: "Authenticate using admin credentials",
|
||||||
|
RunE: runAuthLogin,
|
||||||
|
}
|
||||||
|
loginCmd.Flags().StringVarP(&authServer, "server", "s", "http://localhost:7500", "frp server admin URL")
|
||||||
|
loginCmd.Flags().StringVarP(&authOutput, "output", "o", "", "output config file path (default: ./frpc-<client-name>.toml)")
|
||||||
|
loginCmd.Flags().String("username", "", "admin username (prompts if empty)")
|
||||||
|
loginCmd.Flags().String("password", "", "admin password (prompts if empty)")
|
||||||
|
loginCmd.Flags().String("client-name", "", "client name (fetches list if empty)")
|
||||||
|
|
||||||
|
rootCmd.AddCommand(authCmd)
|
||||||
|
authCmd.AddCommand(tokenCmd)
|
||||||
|
authCmd.AddCommand(loginCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func runAuthToken(cmd *cobra.Command, args []string) error {
|
||||||
|
token := args[0]
|
||||||
|
|
||||||
|
url := authServer + "/admin/api/client/auth"
|
||||||
|
body := map[string]string{"token": token}
|
||||||
|
data, _ := json.Marshal(body)
|
||||||
|
|
||||||
|
resp, err := http.Post(url, "application/json", bytes.NewReader(data))
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to connect to server: %w", err)
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
respBody, _ := io.ReadAll(resp.Body)
|
||||||
|
return fmt.Errorf("auth failed (HTTP %d): %s", resp.StatusCode, string(respBody))
|
||||||
|
}
|
||||||
|
|
||||||
|
configData, _ := io.ReadAll(resp.Body)
|
||||||
|
return saveConfig(configData)
|
||||||
|
}
|
||||||
|
|
||||||
|
func runAuthLogin(cmd *cobra.Command, args []string) error {
|
||||||
|
username, _ := cmd.Flags().GetString("username")
|
||||||
|
password, _ := cmd.Flags().GetString("password")
|
||||||
|
clientName, _ := cmd.Flags().GetString("client-name")
|
||||||
|
|
||||||
|
if username == "" {
|
||||||
|
fmt.Print("Admin username: ")
|
||||||
|
fmt.Scanln(&username)
|
||||||
|
}
|
||||||
|
if password == "" {
|
||||||
|
fmt.Print("Admin password: ")
|
||||||
|
bytePassword, err := readPassword()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
password = string(bytePassword)
|
||||||
|
fmt.Println()
|
||||||
|
}
|
||||||
|
|
||||||
|
url := authServer + "/admin/api/client/auth"
|
||||||
|
body := map[string]string{
|
||||||
|
"username": username,
|
||||||
|
"password": password,
|
||||||
|
"client_name": clientName,
|
||||||
|
}
|
||||||
|
data, _ := json.Marshal(body)
|
||||||
|
|
||||||
|
resp, err := http.Post(url, "application/json", bytes.NewReader(data))
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to connect to server: %w", err)
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
respBody, _ := io.ReadAll(resp.Body)
|
||||||
|
return fmt.Errorf("auth failed (HTTP %d): %s", resp.StatusCode, string(respBody))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if server returned a client list
|
||||||
|
contentType := resp.Header.Get("Content-Type")
|
||||||
|
if contentType == "application/json" || len(contentType) == 0 {
|
||||||
|
var result struct {
|
||||||
|
Clients []map[string]any `json:"clients"`
|
||||||
|
RequiresClientName bool `json:"requires_client_name"`
|
||||||
|
}
|
||||||
|
respBody, _ := io.ReadAll(resp.Body)
|
||||||
|
if err := json.Unmarshal(respBody, &result); err == nil && result.RequiresClientName {
|
||||||
|
fmt.Println("Available clients:")
|
||||||
|
for i, c := range result.Clients {
|
||||||
|
fmt.Printf(" %d. %s\n", i+1, c["name"])
|
||||||
|
}
|
||||||
|
fmt.Print("Enter client name: ")
|
||||||
|
var name string
|
||||||
|
fmt.Scanln(&name)
|
||||||
|
|
||||||
|
body["client_name"] = name
|
||||||
|
data, _ = json.Marshal(body)
|
||||||
|
resp, err = http.Post(url, "application/json", bytes.NewReader(data))
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to connect to server: %w", err)
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
respBody, _ := io.ReadAll(resp.Body)
|
||||||
|
return fmt.Errorf("auth failed (HTTP %d): %s", resp.StatusCode, string(respBody))
|
||||||
|
}
|
||||||
|
configData, _ := io.ReadAll(resp.Body)
|
||||||
|
return saveConfig(configData)
|
||||||
|
}
|
||||||
|
configData := respBody
|
||||||
|
return saveConfig(configData)
|
||||||
|
}
|
||||||
|
|
||||||
|
configData, _ := io.ReadAll(resp.Body)
|
||||||
|
return saveConfig(configData)
|
||||||
|
}
|
||||||
|
|
||||||
|
func saveConfig(data []byte) error {
|
||||||
|
outputPath := authOutput
|
||||||
|
if outputPath == "" {
|
||||||
|
// Try to extract client name from config
|
||||||
|
outputPath = "frpc.toml"
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := os.MkdirAll(filepath.Dir(outputPath), 0755); err != nil {
|
||||||
|
return fmt.Errorf("failed to create output directory: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := os.WriteFile(outputPath, data, 0644); err != nil {
|
||||||
|
return fmt.Errorf("failed to write config: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Infof("config saved to %s", outputPath)
|
||||||
|
fmt.Printf("Config saved to %s\n", outputPath)
|
||||||
|
fmt.Printf("Run: frpc -c %s\n", outputPath)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func readPassword() ([]byte, error) {
|
||||||
|
return io.ReadAll(os.Stdin)
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
//go:build frpc_gui
|
||||||
|
|
||||||
|
package sub
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"github.com/fatedier/frp/client/gui"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
guiCmd := &cobra.Command{
|
||||||
|
Use: "gui",
|
||||||
|
Short: "Start the frpc graphical user interface",
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
gui.Run()
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
rootCmd.AddCommand(guiCmd)
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
//go:build !frpc_gui
|
||||||
|
|
||||||
|
package sub
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
guiCmd := &cobra.Command{
|
||||||
|
Use: "gui",
|
||||||
|
Short: "Start the frpc graphical user interface",
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
fmt.Println("frpc GUI is not available in this build.")
|
||||||
|
fmt.Println("To build with GUI support, install OpenGL and X11 dev libraries, then:")
|
||||||
|
fmt.Println(" CGO_ENABLED=1 go build -tags frpc_gui -o frpc ./cmd/frpc")
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
rootCmd.AddCommand(guiCmd)
|
||||||
|
}
|
||||||
@@ -17,7 +17,9 @@ package sub
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -45,6 +47,7 @@ var (
|
|||||||
showVersion bool
|
showVersion bool
|
||||||
strictConfigMode bool
|
strictConfigMode bool
|
||||||
allowUnsafe []string
|
allowUnsafe []string
|
||||||
|
serverConfigURL string
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -52,6 +55,7 @@ func init() {
|
|||||||
rootCmd.PersistentFlags().StringVarP(&cfgDir, "config_dir", "", "", "config directory, run one frpc service for each file in config directory")
|
rootCmd.PersistentFlags().StringVarP(&cfgDir, "config_dir", "", "", "config directory, run one frpc service for each file in config directory")
|
||||||
rootCmd.PersistentFlags().BoolVarP(&showVersion, "version", "v", false, "version of frpc")
|
rootCmd.PersistentFlags().BoolVarP(&showVersion, "version", "v", false, "version of frpc")
|
||||||
rootCmd.PersistentFlags().BoolVarP(&strictConfigMode, "strict_config", "", true, "strict config parsing mode, unknown fields will cause an errors")
|
rootCmd.PersistentFlags().BoolVarP(&strictConfigMode, "strict_config", "", true, "strict config parsing mode, unknown fields will cause an errors")
|
||||||
|
rootCmd.PersistentFlags().StringVarP(&serverConfigURL, "server-config", "", "", "fetch config from frps server URL (auto-reloads on change)")
|
||||||
|
|
||||||
rootCmd.PersistentFlags().StringSliceVarP(&allowUnsafe, "allow-unsafe", "", []string{},
|
rootCmd.PersistentFlags().StringSliceVarP(&allowUnsafe, "allow-unsafe", "", []string{},
|
||||||
fmt.Sprintf("allowed unsafe features, one or more of: %s", strings.Join(security.ClientUnsafeFeatures, ", ")))
|
fmt.Sprintf("allowed unsafe features, one or more of: %s", strings.Join(security.ClientUnsafeFeatures, ", ")))
|
||||||
@@ -75,6 +79,16 @@ var rootCmd = &cobra.Command{
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If server-config is set, use it instead of local config file.
|
||||||
|
if serverConfigURL != "" {
|
||||||
|
err := runClientWithServerConfig(serverConfigURL, unsafeFeatures)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Do not show command usage here.
|
// Do not show command usage here.
|
||||||
err := runClient(cfgFile, unsafeFeatures)
|
err := runClient(cfgFile, unsafeFeatures)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -120,6 +134,37 @@ func handleTermSignal(svr *client.Service) {
|
|||||||
svr.GracefulClose(500 * time.Millisecond)
|
svr.GracefulClose(500 * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func runClientWithServerConfig(url string, unsafeFeatures *security.UnsafeFeatures) error {
|
||||||
|
log.Infof("fetching config from server: %s", url)
|
||||||
|
resp, err := http.Get(url)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to fetch config from server: %w", err)
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
body, err := io.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to read config from server: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
allCfg := v1.ClientConfig{}
|
||||||
|
if err := config.LoadConfigure(body, &allCfg, strictConfigMode, "toml"); err != nil {
|
||||||
|
return fmt.Errorf("failed to parse config from server: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
result := &config.ClientConfigLoadResult{
|
||||||
|
Common: &allCfg.ClientCommonConfig,
|
||||||
|
Proxies: make([]v1.ProxyConfigurer, 0),
|
||||||
|
}
|
||||||
|
for _, c := range allCfg.Proxies {
|
||||||
|
result.Proxies = append(result.Proxies, c.ProxyConfigurer)
|
||||||
|
}
|
||||||
|
|
||||||
|
result.Common.ConfigURL = url
|
||||||
|
|
||||||
|
return runClientWithAggregator(result, unsafeFeatures, "")
|
||||||
|
}
|
||||||
|
|
||||||
func runClient(cfgFilePath string, unsafeFeatures *security.UnsafeFeatures) error {
|
func runClient(cfgFilePath string, unsafeFeatures *security.UnsafeFeatures) error {
|
||||||
// Load configuration
|
// Load configuration
|
||||||
result, err := config.LoadClientConfigResult(cfgFilePath, strictConfigMode)
|
result, err := config.LoadClientConfigResult(cfgFilePath, strictConfigMode)
|
||||||
|
|||||||
+41
-20
@@ -1,17 +1,3 @@
|
|||||||
// Copyright 2018 fatedier, fatedier@gmail.com
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -25,6 +11,7 @@ import (
|
|||||||
"github.com/fatedier/frp/pkg/config"
|
"github.com/fatedier/frp/pkg/config"
|
||||||
v1 "github.com/fatedier/frp/pkg/config/v1"
|
v1 "github.com/fatedier/frp/pkg/config/v1"
|
||||||
"github.com/fatedier/frp/pkg/config/v1/validation"
|
"github.com/fatedier/frp/pkg/config/v1/validation"
|
||||||
|
"github.com/fatedier/frp/pkg/db"
|
||||||
"github.com/fatedier/frp/pkg/policy/security"
|
"github.com/fatedier/frp/pkg/policy/security"
|
||||||
"github.com/fatedier/frp/pkg/util/log"
|
"github.com/fatedier/frp/pkg/util/log"
|
||||||
"github.com/fatedier/frp/pkg/util/version"
|
"github.com/fatedier/frp/pkg/util/version"
|
||||||
@@ -59,6 +46,12 @@ var rootCmd = &cobra.Command{
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := db.Init("sqlite", "admin.db"); err != nil {
|
||||||
|
fmt.Printf("failed to initialize admin database: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
var (
|
var (
|
||||||
svrCfg *v1.ServerConfig
|
svrCfg *v1.ServerConfig
|
||||||
isLegacyFormat bool
|
isLegacyFormat bool
|
||||||
@@ -71,15 +64,14 @@ var rootCmd = &cobra.Command{
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
if isLegacyFormat {
|
if isLegacyFormat {
|
||||||
fmt.Printf("WARNING: ini format is deprecated and the support will be removed in the future, " +
|
fmt.Printf("WARNING: ini format is deprecated, please use yaml/json/toml instead!\n")
|
||||||
"please use yaml/json/toml format instead!\n")
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := serverCfg.Complete(); err != nil {
|
svrCfg, err = loadConfigFromDB()
|
||||||
fmt.Printf("failed to complete server config: %v\n", err)
|
if err != nil {
|
||||||
|
fmt.Printf("failed to load server config: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
svrCfg = &serverCfg
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafeFeatures := security.NewUnsafeFeatures(allowUnsafe)
|
unsafeFeatures := security.NewUnsafeFeatures(allowUnsafe)
|
||||||
@@ -108,13 +100,42 @@ func Execute() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func loadConfigFromDB() (*v1.ServerConfig, error) {
|
||||||
|
hasConfig, err := db.HasServerConfig()
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to check server config in db: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if hasConfig {
|
||||||
|
cfg, err := db.LoadServerConfig()
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to load server config from db: %w", err)
|
||||||
|
}
|
||||||
|
if err := cfg.Complete(); err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to complete server config: %w", err)
|
||||||
|
}
|
||||||
|
log.Infof("frps uses database configuration")
|
||||||
|
return cfg, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg := db.DefaultServerConfig()
|
||||||
|
if err := cfg.Complete(); err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to complete server config: %w", err)
|
||||||
|
}
|
||||||
|
if err := db.SaveServerConfig(cfg); err != nil {
|
||||||
|
log.Warnf("failed to save default config to db: %v", err)
|
||||||
|
}
|
||||||
|
log.Infof("frps started with default configuration (first run)")
|
||||||
|
return cfg, nil
|
||||||
|
}
|
||||||
|
|
||||||
func runServer(cfg *v1.ServerConfig) (err error) {
|
func runServer(cfg *v1.ServerConfig) (err error) {
|
||||||
log.InitLogger(cfg.Log.To, cfg.Log.Level, int(cfg.Log.MaxDays), cfg.Log.DisablePrintColor)
|
log.InitLogger(cfg.Log.To, cfg.Log.Level, int(cfg.Log.MaxDays), cfg.Log.DisablePrintColor)
|
||||||
|
|
||||||
if cfgFile != "" {
|
if cfgFile != "" {
|
||||||
log.Infof("frps uses config file: %s", cfgFile)
|
log.Infof("frps uses config file: %s", cfgFile)
|
||||||
} else {
|
} else {
|
||||||
log.Infof("frps uses command line arguments for config")
|
log.Infof("frps uses database configuration")
|
||||||
}
|
}
|
||||||
|
|
||||||
svr, err := server.NewService(cfg)
|
svr, err := server.NewService(cfg)
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ module github.com/fatedier/frp
|
|||||||
go 1.25.0
|
go 1.25.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
entgo.io/ent v0.14.6
|
||||||
|
fyne.io/fyne/v2 v2.7.4
|
||||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
|
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
|
||||||
github.com/coreos/go-oidc/v3 v3.14.1
|
github.com/coreos/go-oidc/v3 v3.14.1
|
||||||
github.com/fatedier/golib v0.7.0
|
github.com/fatedier/golib v0.7.0
|
||||||
@@ -26,33 +28,66 @@ require (
|
|||||||
github.com/tidwall/gjson v1.17.1
|
github.com/tidwall/gjson v1.17.1
|
||||||
github.com/vishvananda/netlink v1.3.0
|
github.com/vishvananda/netlink v1.3.0
|
||||||
github.com/xtaci/kcp-go/v5 v5.6.13
|
github.com/xtaci/kcp-go/v5 v5.6.13
|
||||||
golang.org/x/crypto v0.49.0
|
golang.org/x/crypto v0.52.0
|
||||||
golang.org/x/net v0.52.0
|
golang.org/x/net v0.54.0
|
||||||
golang.org/x/oauth2 v0.28.0
|
golang.org/x/oauth2 v0.28.0
|
||||||
golang.org/x/sync v0.20.0
|
golang.org/x/sync v0.20.0
|
||||||
golang.org/x/sys v0.42.0
|
golang.org/x/sys v0.45.0
|
||||||
golang.org/x/time v0.10.0
|
golang.org/x/time v0.10.0
|
||||||
golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173
|
golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173
|
||||||
gopkg.in/ini.v1 v1.67.0
|
gopkg.in/ini.v1 v1.67.0
|
||||||
k8s.io/apimachinery v0.28.8
|
k8s.io/apimachinery v0.28.8
|
||||||
k8s.io/client-go v0.28.8
|
k8s.io/client-go v0.28.8
|
||||||
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2
|
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2
|
||||||
|
modernc.org/sqlite v1.51.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
ariga.io/atlas v0.36.2-0.20250730182955-2c6300d0a3e1 // indirect
|
||||||
|
fyne.io/systray v1.12.1 // indirect
|
||||||
github.com/Azure/go-ntlmssp v0.1.0 // indirect
|
github.com/Azure/go-ntlmssp v0.1.0 // indirect
|
||||||
|
github.com/BurntSushi/toml v1.5.0 // indirect
|
||||||
|
github.com/agext/levenshtein v1.2.3 // indirect
|
||||||
|
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
|
github.com/bmatcuk/doublestar v1.3.4 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||||
|
github.com/clipperhouse/stringish v0.1.1 // indirect
|
||||||
|
github.com/clipperhouse/uax29/v2 v2.3.0 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||||
|
github.com/fredbi/uri v1.1.1 // indirect
|
||||||
|
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
||||||
|
github.com/fyne-io/gl-js v0.2.0 // indirect
|
||||||
|
github.com/fyne-io/glfw-js v0.3.0 // indirect
|
||||||
|
github.com/fyne-io/image v0.1.1 // indirect
|
||||||
|
github.com/fyne-io/oksvg v0.2.0 // indirect
|
||||||
|
github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71 // indirect
|
||||||
|
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240506104042-037f3cc74f2a // indirect
|
||||||
github.com/go-jose/go-jose/v4 v4.0.5 // indirect
|
github.com/go-jose/go-jose/v4 v4.0.5 // indirect
|
||||||
github.com/go-logr/logr v1.4.2 // indirect
|
github.com/go-logr/logr v1.4.2 // indirect
|
||||||
|
github.com/go-openapi/inflect v0.19.0 // indirect
|
||||||
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
|
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
|
||||||
|
github.com/go-text/render v0.2.1 // indirect
|
||||||
|
github.com/go-text/typesetting v0.3.4 // indirect
|
||||||
|
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
||||||
github.com/golang/snappy v0.0.4 // indirect
|
github.com/golang/snappy v0.0.4 // indirect
|
||||||
github.com/google/go-cmp v0.7.0 // indirect
|
github.com/google/go-cmp v0.7.0 // indirect
|
||||||
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect
|
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect
|
||||||
|
github.com/hack-pad/go-indexeddb v0.3.2 // indirect
|
||||||
|
github.com/hack-pad/safejs v0.1.0 // indirect
|
||||||
|
github.com/hashicorp/hcl/v2 v2.18.1 // indirect
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
|
github.com/jeandeaual/go-locale v0.0.0-20250612000132-0ef82f21eade // indirect
|
||||||
|
github.com/jsummers/gobmp v0.0.0-20230614200233-a9de23ed2e25 // indirect
|
||||||
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
|
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
|
||||||
github.com/klauspost/reedsolomon v1.12.0 // indirect
|
github.com/klauspost/reedsolomon v1.12.0 // indirect
|
||||||
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
|
github.com/mattn/go-runewidth v0.0.19 // indirect
|
||||||
|
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
|
||||||
|
github.com/ncruces/go-strftime v1.0.0 // indirect
|
||||||
|
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
|
||||||
|
github.com/nicksnyder/go-i18n/v2 v2.5.1 // indirect
|
||||||
github.com/pion/dtls/v3 v3.0.10 // indirect
|
github.com/pion/dtls/v3 v3.0.10 // indirect
|
||||||
github.com/pion/logging v0.2.4 // indirect
|
github.com/pion/logging v0.2.4 // indirect
|
||||||
github.com/pion/transport/v4 v4.0.1 // indirect
|
github.com/pion/transport/v4 v4.0.1 // indirect
|
||||||
@@ -61,6 +96,10 @@ require (
|
|||||||
github.com/prometheus/client_model v0.5.0 // indirect
|
github.com/prometheus/client_model v0.5.0 // indirect
|
||||||
github.com/prometheus/common v0.48.0 // indirect
|
github.com/prometheus/common v0.48.0 // indirect
|
||||||
github.com/prometheus/procfs v0.12.0 // indirect
|
github.com/prometheus/procfs v0.12.0 // indirect
|
||||||
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||||
|
github.com/rymdport/portal v0.4.2 // indirect
|
||||||
|
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c // indirect
|
||||||
|
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef // indirect
|
||||||
github.com/templexxx/cpu v0.1.1 // indirect
|
github.com/templexxx/cpu v0.1.1 // indirect
|
||||||
github.com/templexxx/xorsimd v0.4.3 // indirect
|
github.com/templexxx/xorsimd v0.4.3 // indirect
|
||||||
github.com/tidwall/match v1.1.1 // indirect
|
github.com/tidwall/match v1.1.1 // indirect
|
||||||
@@ -68,14 +107,21 @@ require (
|
|||||||
github.com/tjfoc/gmsm v1.4.1 // indirect
|
github.com/tjfoc/gmsm v1.4.1 // indirect
|
||||||
github.com/vishvananda/netns v0.0.4 // indirect
|
github.com/vishvananda/netns v0.0.4 // indirect
|
||||||
github.com/wlynxg/anet v0.0.5 // indirect
|
github.com/wlynxg/anet v0.0.5 // indirect
|
||||||
|
github.com/yuin/goldmark v1.7.8 // indirect
|
||||||
|
github.com/zclconf/go-cty v1.14.4 // indirect
|
||||||
|
github.com/zclconf/go-cty-yaml v1.1.0 // indirect
|
||||||
go.uber.org/automaxprocs v1.6.0 // indirect
|
go.uber.org/automaxprocs v1.6.0 // indirect
|
||||||
golang.org/x/mod v0.33.0 // indirect
|
golang.org/x/image v0.24.0 // indirect
|
||||||
golang.org/x/text v0.35.0 // indirect
|
golang.org/x/mod v0.35.0 // indirect
|
||||||
golang.org/x/tools v0.42.0 // indirect
|
golang.org/x/text v0.37.0 // indirect
|
||||||
|
golang.org/x/tools v0.44.0 // indirect
|
||||||
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
|
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
|
||||||
google.golang.org/protobuf v1.36.5 // indirect
|
google.golang.org/protobuf v1.36.5 // indirect
|
||||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
modernc.org/libc v1.72.3 // indirect
|
||||||
|
modernc.org/mathutil v1.7.1 // indirect
|
||||||
|
modernc.org/memory v1.11.0 // indirect
|
||||||
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
|
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
|
||||||
sigs.k8s.io/yaml v1.3.0 // indirect
|
sigs.k8s.io/yaml v1.3.0 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,15 +1,37 @@
|
|||||||
|
ariga.io/atlas v0.36.2-0.20250730182955-2c6300d0a3e1 h1:NPPfBaVZgz4LKBCIc0FbMogCjvXN+yGf7CZwotOwJo8=
|
||||||
|
ariga.io/atlas v0.36.2-0.20250730182955-2c6300d0a3e1/go.mod h1:Ex5l1xHsnWQUc3wYnrJ9gD7RUEzG76P7ZRQp8wNr0wc=
|
||||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
|
entgo.io/ent v0.14.6 h1:/f2696BpwuWAEEG6PVGWflg6+Inrpq4pRWuNlWz/Skk=
|
||||||
|
entgo.io/ent v0.14.6/go.mod h1:z46QBUdGC+BATwsedbDuREfSS0oSCV+csdEYlL4p73s=
|
||||||
|
fyne.io/fyne/v2 v2.7.4 h1:OVCI5mT+Onb2kA4wlmGA5pLCqKik9f4NDb5jiR1OMTc=
|
||||||
|
fyne.io/fyne/v2 v2.7.4/go.mod h1:ZD1mmhBY75mSa97IXl3MPlICd1uNHfCXYh5hKIlVOII=
|
||||||
|
fyne.io/systray v1.12.1 h1:ygBD6aZXwiOmZoY5N+ukbH9pih0Kq6fYgVeMYbr5skQ=
|
||||||
|
fyne.io/systray v1.12.1/go.mod h1:RVwqP9nYMo7h5zViCBHri2FgjXF7H2cub7MAq4NSoLs=
|
||||||
github.com/Azure/go-ntlmssp v0.1.0 h1:DjFo6YtWzNqNvQdrwEyr/e4nhU3vRiwenz5QX7sFz+A=
|
github.com/Azure/go-ntlmssp v0.1.0 h1:DjFo6YtWzNqNvQdrwEyr/e4nhU3vRiwenz5QX7sFz+A=
|
||||||
github.com/Azure/go-ntlmssp v0.1.0/go.mod h1:NYqdhxd/8aAct/s4qSYZEerdPuH1liG2/X9DiVTbhpk=
|
github.com/Azure/go-ntlmssp v0.1.0/go.mod h1:NYqdhxd/8aAct/s4qSYZEerdPuH1liG2/X9DiVTbhpk=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
|
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
|
||||||
|
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||||
|
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
|
||||||
|
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
|
||||||
|
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
|
||||||
|
github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
|
||||||
|
github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY=
|
||||||
|
github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=
|
||||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
|
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
|
||||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
|
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
|
||||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||||
|
github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0=
|
||||||
|
github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE=
|
||||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||||
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
||||||
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
|
github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs=
|
||||||
|
github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA=
|
||||||
|
github.com/clipperhouse/uax29/v2 v2.3.0 h1:SNdx9DVUqMoBuBoW3iLOj4FQv3dN5mDtuqwuhIGpJy4=
|
||||||
|
github.com/clipperhouse/uax29/v2 v2.3.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g=
|
||||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||||
github.com/coreos/go-oidc/v3 v3.14.1 h1:9ePWwfdwC4QKRlCXsJGou56adA/owXczOzwKdOumLqk=
|
github.com/coreos/go-oidc/v3 v3.14.1 h1:9ePWwfdwC4QKRlCXsJGou56adA/owXczOzwKdOumLqk=
|
||||||
github.com/coreos/go-oidc/v3 v3.14.1/go.mod h1:HaZ3szPaZ0e4r6ebqvsLWlk2Tn+aejfmrfah6hnSYEU=
|
github.com/coreos/go-oidc/v3 v3.14.1/go.mod h1:HaZ3szPaZ0e4r6ebqvsLWlk2Tn+aejfmrfah6hnSYEU=
|
||||||
@@ -17,6 +39,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t
|
|||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||||
|
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||||
@@ -24,12 +48,42 @@ github.com/fatedier/golib v0.7.0 h1:tMDF9ObcwVt59VUHroJOzHQjVFPLymZVMpGm9WAVwhY=
|
|||||||
github.com/fatedier/golib v0.7.0/go.mod h1:ArUGvPg2cOw/py2RAuBt46nNZH2VQ5Z70p109MAZpJw=
|
github.com/fatedier/golib v0.7.0/go.mod h1:ArUGvPg2cOw/py2RAuBt46nNZH2VQ5Z70p109MAZpJw=
|
||||||
github.com/fatedier/yamux v0.0.0-20250825093530-d0154be01cd6 h1:u92UUy6FURPmNsMBUuongRWC0rBqN6gd01Dzu+D21NE=
|
github.com/fatedier/yamux v0.0.0-20250825093530-d0154be01cd6 h1:u92UUy6FURPmNsMBUuongRWC0rBqN6gd01Dzu+D21NE=
|
||||||
github.com/fatedier/yamux v0.0.0-20250825093530-d0154be01cd6/go.mod h1:c5/tk6G0dSpXGzJN7Wk1OEie8grdSJAmeawId9Zvd34=
|
github.com/fatedier/yamux v0.0.0-20250825093530-d0154be01cd6/go.mod h1:c5/tk6G0dSpXGzJN7Wk1OEie8grdSJAmeawId9Zvd34=
|
||||||
|
github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g=
|
||||||
|
github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw=
|
||||||
|
github.com/fredbi/uri v1.1.1 h1:xZHJC08GZNIUhbP5ImTHnt5Ya0T8FI2VAwI/37kh2Ko=
|
||||||
|
github.com/fredbi/uri v1.1.1/go.mod h1:4+DZQ5zBjEwQCDmXW5JdIjz0PUA+yJbvtBv+u+adr5o=
|
||||||
|
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
|
||||||
|
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||||
|
github.com/fyne-io/gl-js v0.2.0 h1:+EXMLVEa18EfkXBVKhifYB6OGs3HwKO3lUElA0LlAjs=
|
||||||
|
github.com/fyne-io/gl-js v0.2.0/go.mod h1:ZcepK8vmOYLu96JoxbCKJy2ybr+g1pTnaBDdl7c3ajI=
|
||||||
|
github.com/fyne-io/glfw-js v0.3.0 h1:d8k2+Y7l+zy2pc7wlGRyPfTgZoqDf3AI4G+2zOWhWUk=
|
||||||
|
github.com/fyne-io/glfw-js v0.3.0/go.mod h1:Ri6te7rdZtBgBpxLW19uBpp3Dl6K9K/bRaYdJ22G8Jk=
|
||||||
|
github.com/fyne-io/image v0.1.1 h1:WH0z4H7qfvNUw5l4p3bC1q70sa5+YWVt6HCj7y4VNyA=
|
||||||
|
github.com/fyne-io/image v0.1.1/go.mod h1:xrfYBh6yspc+KjkgdZU/ifUC9sPA5Iv7WYUBzQKK7JM=
|
||||||
|
github.com/fyne-io/oksvg v0.2.0 h1:mxcGU2dx6nwjJsSA9PCYZDuoAcsZ/OuJlvg/Q9Njfo8=
|
||||||
|
github.com/fyne-io/oksvg v0.2.0/go.mod h1:dJ9oEkPiWhnTFNCmRgEze+YNprJF7YRbpjgpWS4kzoI=
|
||||||
|
github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71 h1:5BVwOaUSBTlVZowGO6VZGw2H/zl9nrd3eCZfYV+NfQA=
|
||||||
|
github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw=
|
||||||
|
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240506104042-037f3cc74f2a h1:vxnBhFDDT+xzxf1jTJKMKZw3H0swfWk9RpWbBbDK5+0=
|
||||||
|
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240506104042-037f3cc74f2a/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||||
github.com/go-jose/go-jose/v4 v4.0.5 h1:M6T8+mKZl/+fNNuFHvGIzDz7BTLQPIounk/b9dw3AaE=
|
github.com/go-jose/go-jose/v4 v4.0.5 h1:M6T8+mKZl/+fNNuFHvGIzDz7BTLQPIounk/b9dw3AaE=
|
||||||
github.com/go-jose/go-jose/v4 v4.0.5/go.mod h1:s3P1lRrkT8igV8D9OjyL4WRyHvjB6a4JSllnOrmmBOA=
|
github.com/go-jose/go-jose/v4 v4.0.5/go.mod h1:s3P1lRrkT8igV8D9OjyL4WRyHvjB6a4JSllnOrmmBOA=
|
||||||
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
||||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||||
|
github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4=
|
||||||
|
github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4=
|
||||||
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
|
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
|
||||||
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
|
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
|
||||||
|
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
|
||||||
|
github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
|
||||||
|
github.com/go-text/render v0.2.1 h1:qwHhxqGUjjg4L0XyJWj7M7bpY75NZM+kBpv2Yfw5mcg=
|
||||||
|
github.com/go-text/render v0.2.1/go.mod h1:HCCAq8MUlm/WRcXshBb4K/n+IkjeXQ1c2Ba+yICSm0A=
|
||||||
|
github.com/go-text/typesetting v0.3.4 h1:YYurUOtEb9kGSOz4uE3k4OpBGsp1dDL8+fjCeaFamAU=
|
||||||
|
github.com/go-text/typesetting v0.3.4/go.mod h1:4qZCQphq4KSgGTAeI0uMEkVbROgfah8BuyF5LRYr7XY=
|
||||||
|
github.com/go-text/typesetting-utils v0.0.0-20260223113751-2d88ac90dae3 h1:drBZzMgdYPbmyXqOto4YhhJGrFIQCX94FpR4MzTCsos=
|
||||||
|
github.com/go-text/typesetting-utils v0.0.0-20260223113751-2d88ac90dae3/go.mod h1:3/62I4La/HBRX9TcTpBj4eipLiwzf+vhI+7whTc9V7o=
|
||||||
|
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
|
||||||
|
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
@@ -60,8 +114,20 @@ github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
|
|||||||
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
|
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
|
||||||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||||
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
|
github.com/hack-pad/go-indexeddb v0.3.2 h1:DTqeJJYc1usa45Q5r52t01KhvlSN02+Oq+tQbSBI91A=
|
||||||
|
github.com/hack-pad/go-indexeddb v0.3.2/go.mod h1:QvfTevpDVlkfomY498LhstjwbPW6QC4VC/lxYb0Kom0=
|
||||||
|
github.com/hack-pad/safejs v0.1.0 h1:qPS6vjreAqh2amUqj4WNG1zIw7qlRQJ9K10eDKMCnE8=
|
||||||
|
github.com/hack-pad/safejs v0.1.0/go.mod h1:HdS+bKF1NrE72VoXZeWzxFOVQVUSqZJAG0xNCnb+Tio=
|
||||||
|
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
|
||||||
|
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
||||||
|
github.com/hashicorp/hcl/v2 v2.18.1 h1:6nxnOJFku1EuSawSD81fuviYUV8DxFr3fp2dUi3ZYSo=
|
||||||
|
github.com/hashicorp/hcl/v2 v2.18.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE=
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||||
|
github.com/jeandeaual/go-locale v0.0.0-20250612000132-0ef82f21eade h1:FmusiCI1wHw+XQbvL9M+1r/C3SPqKrmBaIOYwVfQoDE=
|
||||||
|
github.com/jeandeaual/go-locale v0.0.0-20250612000132-0ef82f21eade/go.mod h1:ZDXo8KHryOWSIqnsb/CiDq7hQUYryCgdVnxbj8tDG7o=
|
||||||
|
github.com/jsummers/gobmp v0.0.0-20230614200233-a9de23ed2e25 h1:YLvr1eE6cdCqjOe972w/cYF+FjW34v27+9Vo5106B4M=
|
||||||
|
github.com/jsummers/gobmp v0.0.0-20230614200233-a9de23ed2e25/go.mod h1:kLgvv7o6UM+0QSf0QjAse3wReFDsb9qbZJdfexWlrQw=
|
||||||
github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc=
|
github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc=
|
||||||
github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||||
github.com/klauspost/reedsolomon v1.12.0 h1:I5FEp3xSwVCcEh3F5A7dofEfhXdF/bWhQWPH+XwBFno=
|
github.com/klauspost/reedsolomon v1.12.0 h1:I5FEp3xSwVCcEh3F5A7dofEfhXdF/bWhQWPH+XwBFno=
|
||||||
@@ -70,8 +136,23 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
|||||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
|
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||||
|
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||||
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||||
|
github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw=
|
||||||
|
github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.28 h1:ThEiQrnbtumT+QMknw63Befp/ce/nUPgBPMlRFEum7A=
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.28/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||||
|
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
|
||||||
|
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
|
||||||
|
github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w=
|
||||||
|
github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
|
||||||
|
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
|
||||||
|
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
||||||
|
github.com/nicksnyder/go-i18n/v2 v2.5.1 h1:IxtPxYsR9Gp60cGXjfuR/llTqV8aYMsC472zD0D1vHk=
|
||||||
|
github.com/nicksnyder/go-i18n/v2 v2.5.1/go.mod h1:DrhgsSDZxoAfvVrBVLXoxZn/pN5TXqaDbq7ju94viiQ=
|
||||||
github.com/onsi/ginkgo/v2 v2.23.4 h1:ktYTpKJAVZnDT4VjxSbiBenUjmlL/5QkBEocaWXiQus=
|
github.com/onsi/ginkgo/v2 v2.23.4 h1:ktYTpKJAVZnDT4VjxSbiBenUjmlL/5QkBEocaWXiQus=
|
||||||
github.com/onsi/ginkgo/v2 v2.23.4/go.mod h1:Bt66ApGPBFzHyR+JO10Zbt0Gsp4uWxu5mIOTusL46e8=
|
github.com/onsi/ginkgo/v2 v2.23.4/go.mod h1:Bt66ApGPBFzHyR+JO10Zbt0Gsp4uWxu5mIOTusL46e8=
|
||||||
github.com/onsi/gomega v1.36.3 h1:hID7cr8t3Wp26+cYnfcjR6HpJ00fdogN6dqZ1t6IylU=
|
github.com/onsi/gomega v1.36.3 h1:hID7cr8t3Wp26+cYnfcjR6HpJ00fdogN6dqZ1t6IylU=
|
||||||
@@ -90,6 +171,8 @@ github.com/pires/go-proxyproto v0.7.0 h1:IukmRewDQFWC7kfnb66CSomk2q/seBuilHBYFwy
|
|||||||
github.com/pires/go-proxyproto v0.7.0/go.mod h1:Vz/1JPY/OACxWGQNIRY2BeyDmpoaWmEP40O9LbuiFR4=
|
github.com/pires/go-proxyproto v0.7.0/go.mod h1:Vz/1JPY/OACxWGQNIRY2BeyDmpoaWmEP40O9LbuiFR4=
|
||||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
github.com/pkg/profile v1.7.0 h1:hnbDkaNWPCLMO9wGLdBFTIZvzDrDfBM2072E1S9gJkA=
|
||||||
|
github.com/pkg/profile v1.7.0/go.mod h1:8Uer0jas47ZQMJ7VD+OHknK4YDY07LPUC6dEvqDjvNo=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
|
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
|
||||||
@@ -105,21 +188,30 @@ github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k
|
|||||||
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
|
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
|
||||||
github.com/quic-go/quic-go v0.55.0 h1:zccPQIqYCXDt5NmcEabyYvOnomjs8Tlwl7tISjJh9Mk=
|
github.com/quic-go/quic-go v0.55.0 h1:zccPQIqYCXDt5NmcEabyYvOnomjs8Tlwl7tISjJh9Mk=
|
||||||
github.com/quic-go/quic-go v0.55.0/go.mod h1:DR51ilwU1uE164KuWXhinFcKWGlEjzys2l8zUl5Ss1U=
|
github.com/quic-go/quic-go v0.55.0/go.mod h1:DR51ilwU1uE164KuWXhinFcKWGlEjzys2l8zUl5Ss1U=
|
||||||
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||||
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
github.com/rodaine/table v1.2.0 h1:38HEnwK4mKSHQJIkavVj+bst1TEY7j9zhLMWu4QJrMA=
|
github.com/rodaine/table v1.2.0 h1:38HEnwK4mKSHQJIkavVj+bst1TEY7j9zhLMWu4QJrMA=
|
||||||
github.com/rodaine/table v1.2.0/go.mod h1:wejb/q/Yd4T/SVmBSRMr7GCq3KlcZp3gyNYdLSBhkaE=
|
github.com/rodaine/table v1.2.0/go.mod h1:wejb/q/Yd4T/SVmBSRMr7GCq3KlcZp3gyNYdLSBhkaE=
|
||||||
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||||
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
||||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
|
github.com/rymdport/portal v0.4.2 h1:7jKRSemwlTyVHHrTGgQg7gmNPJs88xkbKcIL3NlcmSU=
|
||||||
|
github.com/rymdport/portal v0.4.2/go.mod h1:kFF4jslnJ8pD5uCi17brj/ODlfIidOxlgUDTO5ncnC4=
|
||||||
github.com/samber/lo v1.47.0 h1:z7RynLwP5nbyRscyvcD043DWYoOcYRv3mV8lBeqOCLc=
|
github.com/samber/lo v1.47.0 h1:z7RynLwP5nbyRscyvcD043DWYoOcYRv3mV8lBeqOCLc=
|
||||||
github.com/samber/lo v1.47.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU=
|
github.com/samber/lo v1.47.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU=
|
||||||
|
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
|
||||||
|
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
|
||||||
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8 h1:TG/diQgUe0pntT/2D9tmUCz4VNwm9MfrtPr0SU2qSX8=
|
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8 h1:TG/diQgUe0pntT/2D9tmUCz4VNwm9MfrtPr0SU2qSX8=
|
||||||
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8/go.mod h1:P5HUIBuIWKbyjl083/loAegFkfbFNx5i2qEP4CNbm7E=
|
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8/go.mod h1:P5HUIBuIWKbyjl083/loAegFkfbFNx5i2qEP4CNbm7E=
|
||||||
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
|
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
|
||||||
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
|
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
|
||||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
|
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c h1:km8GpoQut05eY3GiYWEedbTT0qnSxrCjsVbb7yKY1KE=
|
||||||
|
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c/go.mod h1:cNQ3dwVJtS5Hmnjxy6AgTPd0Inb3pW05ftPSX7NZO7Q=
|
||||||
|
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef h1:Ch6Q+AZUxDBCVqdkI8FSpFyZDtCVBc2VmejdNrm5rRQ=
|
||||||
|
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef/go.mod h1:nXTWP6+gD5+LUJ8krVhhoeHjvHTutPxMYl5SvkcnJNE=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
@@ -152,6 +244,12 @@ github.com/xtaci/kcp-go/v5 v5.6.13 h1:FEjtz9+D4p8t2x4WjciGt/jsIuhlWjjgPCCWjrVR4H
|
|||||||
github.com/xtaci/kcp-go/v5 v5.6.13/go.mod h1:75S1AKYYzNUSXIv30h+jPKJYZUwqpfvLshu63nCNSOM=
|
github.com/xtaci/kcp-go/v5 v5.6.13/go.mod h1:75S1AKYYzNUSXIv30h+jPKJYZUwqpfvLshu63nCNSOM=
|
||||||
github.com/xtaci/lossyconn v0.0.0-20200209145036-adba10fffc37 h1:EWU6Pktpas0n8lLQwDsRyZfmkPeRbdgPtW609es+/9E=
|
github.com/xtaci/lossyconn v0.0.0-20200209145036-adba10fffc37 h1:EWU6Pktpas0n8lLQwDsRyZfmkPeRbdgPtW609es+/9E=
|
||||||
github.com/xtaci/lossyconn v0.0.0-20200209145036-adba10fffc37/go.mod h1:HpMP7DB2CyokmAh4lp0EQnnWhmycP/TvwBGzvuie+H0=
|
github.com/xtaci/lossyconn v0.0.0-20200209145036-adba10fffc37/go.mod h1:HpMP7DB2CyokmAh4lp0EQnnWhmycP/TvwBGzvuie+H0=
|
||||||
|
github.com/yuin/goldmark v1.7.8 h1:iERMLn0/QJeHFhxSt3p6PeN9mGnvIKSpG9YYorDMnic=
|
||||||
|
github.com/yuin/goldmark v1.7.8/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
|
||||||
|
github.com/zclconf/go-cty v1.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8=
|
||||||
|
github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
|
||||||
|
github.com/zclconf/go-cty-yaml v1.1.0 h1:nP+jp0qPHv2IhUVqmQSzjvqAWcObN0KBkUl2rWBdig0=
|
||||||
|
github.com/zclconf/go-cty-yaml v1.1.0/go.mod h1:9YLUH4g7lOhVWqUbctnVlZ5KLpg7JAprQNgxSZ1Gyxs=
|
||||||
go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
|
go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
|
||||||
go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8=
|
go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8=
|
||||||
go.uber.org/mock v0.5.2 h1:LbtPTcP8A5k9WPXj54PPPbjcI4Y6lhyOZXn+VS7wNko=
|
go.uber.org/mock v0.5.2 h1:LbtPTcP8A5k9WPXj54PPPbjcI4Y6lhyOZXn+VS7wNko=
|
||||||
@@ -159,22 +257,24 @@ go.uber.org/mock v0.5.2/go.mod h1:wLlUxC2vVTPTaE3UD51E0BGOAElKrILxhVSDYQLld5o=
|
|||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.49.0 h1:+Ng2ULVvLHnJ/ZFEq4KdcDd/cfjrrjjNSXNzxg0Y4U4=
|
golang.org/x/crypto v0.52.0 h1:RMs7fP2rXdep0CftQlK8Uf+kibLm7qkCcradZWYz988=
|
||||||
golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtCA=
|
golang.org/x/crypto v0.52.0/go.mod h1:1QgfPxDqh0T2M/elOJtp9RvuR95kVjir0e6/BvEmGbc=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
|
golang.org/x/image v0.24.0 h1:AN7zRgVsbvmTfNyqIbbOraYL8mSwcKncEj8ofjgzcMQ=
|
||||||
|
golang.org/x/image v0.24.0/go.mod h1:4b/ITuLfqYq1hqZcjofwctIhi7sZh2WaCjvsBNjjya8=
|
||||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8=
|
golang.org/x/mod v0.35.0 h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM=
|
||||||
golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w=
|
golang.org/x/mod v0.35.0/go.mod h1:+GwiRhIInF8wPm+4AoT6L0FA1QWAad3OMdTRx4tFYlU=
|
||||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
golang.org/x/net v0.52.0 h1:He/TN1l0e4mmR3QqHMT2Xab3Aj3L9qjbhRm78/6jrW0=
|
golang.org/x/net v0.54.0 h1:2zJIZAxAHV/OHCDTCOHAYehQzLfSXuf/5SoL/Dv6w/w=
|
||||||
golang.org/x/net v0.52.0/go.mod h1:R1MAz7uMZxVMualyPXb+VaqGSa3LIaUqk0eEt3w36Sw=
|
golang.org/x/net v0.54.0/go.mod h1:Sj4oj8jK6XmHpBZU/zWHw3BV3abl4Kvi+Ut7cQcY+cQ=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.28.0 h1:CrgCKl8PPAVtLnU3c+EDw6x11699EWlsDeWNWKdIOkc=
|
golang.org/x/oauth2 v0.28.0 h1:CrgCKl8PPAVtLnU3c+EDw6x11699EWlsDeWNWKdIOkc=
|
||||||
golang.org/x/oauth2 v0.28.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
|
golang.org/x/oauth2 v0.28.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
|
||||||
@@ -189,15 +289,16 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
|
golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY=
|
||||||
golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||||
golang.org/x/term v0.41.0 h1:QCgPso/Q3RTJx2Th4bDLqML4W6iJiaXFq2/ftQF13YU=
|
golang.org/x/term v0.43.0 h1:S4RLU2sB31O/NCl+zFN9Aru9A/Cq2aqKpTZJ6B+DwT4=
|
||||||
golang.org/x/term v0.41.0/go.mod h1:3pfBgksrReYfZ5lvYM0kSO0LIkAl4Yl2bXOkKP7Ec2A=
|
golang.org/x/term v0.43.0/go.mod h1:lrhlHNdQJHO+1qVYiHfFKVuVioJIheAc3fBSMFYEIsk=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.35.0 h1:JOVx6vVDFokkpaq1AEptVzLTpDe9KGpj5tR4/X+ybL8=
|
golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc=
|
||||||
golang.org/x/text v0.35.0/go.mod h1:khi/HExzZJ2pGnjenulevKNX1W67CUy0AsXcNubPGCA=
|
golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38=
|
||||||
golang.org/x/time v0.10.0 h1:3usCWA8tQn0L8+hFJQNgzpWbd89begxN66o1Ojdn5L4=
|
golang.org/x/time v0.10.0 h1:3usCWA8tQn0L8+hFJQNgzpWbd89begxN66o1Ojdn5L4=
|
||||||
golang.org/x/time v0.10.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
golang.org/x/time v0.10.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
@@ -205,8 +306,8 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm
|
|||||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
golang.org/x/tools v0.42.0 h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k=
|
golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c=
|
||||||
golang.org/x/tools v0.42.0/go.mod h1:Ma6lCIwGZvHK6XtgbswSoWroEkhugApmsXyrUmBhfr0=
|
golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 h1:B82qJJgjvYKsXS9jeunTOisW56dUokqW/FOteYJJ/yg=
|
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 h1:B82qJJgjvYKsXS9jeunTOisW56dUokqW/FOteYJJ/yg=
|
||||||
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2/go.mod h1:deeaetjYA+DHMHg+sMSMI58GrEteJUUzzw7en6TJQcI=
|
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2/go.mod h1:deeaetjYA+DHMHg+sMSMI58GrEteJUUzzw7en6TJQcI=
|
||||||
@@ -248,6 +349,34 @@ k8s.io/client-go v0.28.8 h1:TE59Tjd87WKvS2FPBTfIKLFX0nQJ4SSHsnDo5IHjgOw=
|
|||||||
k8s.io/client-go v0.28.8/go.mod h1:uDVQ/rPzWpWIy40c6lZ4mUwaEvRWGnpoqSO4FM65P3o=
|
k8s.io/client-go v0.28.8/go.mod h1:uDVQ/rPzWpWIy40c6lZ4mUwaEvRWGnpoqSO4FM65P3o=
|
||||||
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 h1:qY1Ad8PODbnymg2pRbkyMT/ylpTrCM8P2RJ0yroCyIk=
|
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 h1:qY1Ad8PODbnymg2pRbkyMT/ylpTrCM8P2RJ0yroCyIk=
|
||||||
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
|
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
|
||||||
|
modernc.org/cc/v4 v4.28.2 h1:3tQ0lf2ADtoby2EtSP+J7IE2SHwEJdP8ioR59wx7XpY=
|
||||||
|
modernc.org/cc/v4 v4.28.2/go.mod h1:OnovgIhbbMXMu1aISnJ0wvVD1KnW+cAUJkIrAWh+kVI=
|
||||||
|
modernc.org/ccgo/v4 v4.34.0 h1:yRLPFZieg532OT4rp4JFNIVcquwalMX26G95WQDqwCQ=
|
||||||
|
modernc.org/ccgo/v4 v4.34.0/go.mod h1:AS5WYMyBakQ+fhsHhtP8mWB82KTGPkNNJDGfGQCe0/A=
|
||||||
|
modernc.org/fileutil v1.4.0 h1:j6ZzNTftVS054gi281TyLjHPp6CPHr2KCxEXjEbD6SM=
|
||||||
|
modernc.org/fileutil v1.4.0/go.mod h1:EqdKFDxiByqxLk8ozOxObDSfcVOv/54xDs/DUHdvCUU=
|
||||||
|
modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=
|
||||||
|
modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
|
||||||
|
modernc.org/gc/v3 v3.1.2 h1:ZtDCnhonXSZexk/AYsegNRV1lJGgaNZJuKjJSWKyEqo=
|
||||||
|
modernc.org/gc/v3 v3.1.2/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY=
|
||||||
|
modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks=
|
||||||
|
modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
|
||||||
|
modernc.org/libc v1.72.3 h1:ZnDF4tXn4NBXFutMMQC4vtbTFSXhhKzR73fv0beZEAU=
|
||||||
|
modernc.org/libc v1.72.3/go.mod h1:dn0dZNnnn1clLyvRxLxYExxiKRZIRENOfqQ8XEeg4Qs=
|
||||||
|
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
|
||||||
|
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
|
||||||
|
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
|
||||||
|
modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
|
||||||
|
modernc.org/opt v0.2.0 h1:tGyef5ApycA7FSEOMraay9SaTk5zmbx7Tu+cJs4QKZg=
|
||||||
|
modernc.org/opt v0.2.0/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
|
||||||
|
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
|
||||||
|
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
|
||||||
|
modernc.org/sqlite v1.51.0 h1:aH/MMSoayAIhozZ7uJbVTT9QO/VhzBf0J9tymmmuC/U=
|
||||||
|
modernc.org/sqlite v1.51.0/go.mod h1:tcNzv5p84E0skkmJn038y+hWJbLQXQqEnQfeh5r2JLM=
|
||||||
|
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
|
||||||
|
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
|
||||||
|
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
|
||||||
|
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
|
||||||
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
|
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
|
||||||
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
|
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
|
||||||
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
|
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# frpc configuration
|
||||||
|
# Generated by frpc installer
|
||||||
|
# Edit this file to configure your frp client.
|
||||||
|
|
||||||
|
serverAddr = "127.0.0.1"
|
||||||
|
serverPort = 7000
|
||||||
|
auth.token = ""
|
||||||
|
|
||||||
|
# Uncomment and set the URL to auto-fetch config from frps:
|
||||||
|
# configURL = "http://your-server:7500/admin/api/frpc/proxy-config/YOUR_KEY"
|
||||||
@@ -0,0 +1,148 @@
|
|||||||
|
; frpc Windows Installer (NSIS)
|
||||||
|
; Build: makensis frpc.nsi
|
||||||
|
; Requires: NSIS 3.x (https://nsis.sourceforge.io)
|
||||||
|
|
||||||
|
!define PRODUCT_NAME "frpc"
|
||||||
|
!define PRODUCT_VERSION "0.62.0"
|
||||||
|
!define PRODUCT_PUBLISHER "frp Contributors"
|
||||||
|
!define PRODUCT_WEB_SITE "https://github.com/fatedier/frp"
|
||||||
|
!define PRODUCT_DIR "$PROGRAMFILES64\${PRODUCT_NAME}"
|
||||||
|
!define PRODUCT_UNINSTALL_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
|
||||||
|
|
||||||
|
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
|
||||||
|
OutFile "..\..\bin\frpc-${PRODUCT_VERSION}-setup.exe"
|
||||||
|
InstallDir "${PRODUCT_DIR}"
|
||||||
|
InstallDirRegKey HKLM "${PRODUCT_UNINSTALL_KEY}" "InstallLocation"
|
||||||
|
RequestExecutionLevel admin
|
||||||
|
|
||||||
|
SetCompressor lzma
|
||||||
|
|
||||||
|
; Pages (setup wizard)
|
||||||
|
Page license
|
||||||
|
Page components
|
||||||
|
Page directory
|
||||||
|
Page instfiles
|
||||||
|
Page custom setFinishPage
|
||||||
|
|
||||||
|
; Uninstaller pages
|
||||||
|
UninstPage uninstConfirm
|
||||||
|
UninstPage instfiles
|
||||||
|
|
||||||
|
; License data
|
||||||
|
LicenseData "..\..\packaging\windows\license.txt"
|
||||||
|
|
||||||
|
; Languages
|
||||||
|
!insertmacro MUI_LANGUAGE "English"
|
||||||
|
|
||||||
|
; Include modern UI
|
||||||
|
!include "MUI2.nsh"
|
||||||
|
!include "FileFunc.nsh"
|
||||||
|
!include "WinMessages.nsh"
|
||||||
|
!include "LogicLib.nsh"
|
||||||
|
|
||||||
|
Var FinishPage
|
||||||
|
Var RunNowCheckbox
|
||||||
|
Var ShowReadmeCheckbox
|
||||||
|
Var RunNowState
|
||||||
|
Var ReadmeState
|
||||||
|
|
||||||
|
Function setFinishPage
|
||||||
|
nsDialogs::Create 1018
|
||||||
|
Pop $FinishPage
|
||||||
|
|
||||||
|
${NSD_CreateLabel} 0 0 100% 24 "Setup Complete"
|
||||||
|
Pop $0
|
||||||
|
|
||||||
|
${NSD_CreateCheckbox} 0 30 100% 12 "Run frpc now"
|
||||||
|
Pop $RunNowCheckbox
|
||||||
|
${NSD_Check} $RunNowCheckbox
|
||||||
|
|
||||||
|
${NSD_CreateCheckbox} 0 46 100% 12 "Open config directory"
|
||||||
|
Pop $ShowReadmeCheckbox
|
||||||
|
|
||||||
|
nsDialogs::Show
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
Function .onGUIEnd
|
||||||
|
${NSD_GetState} $RunNowCheckbox $RunNowState
|
||||||
|
${NSD_GetState} $ShowReadmeCheckbox $ReadmeState
|
||||||
|
|
||||||
|
${If} $RunNowState == ${BST_CHECKED}
|
||||||
|
ExecShell "open" "$INSTDIR\frpc.exe"
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
${If} $ReadmeState == ${BST_CHECKED}
|
||||||
|
ExecShell "open" "$PROGRAMDATA\frpc"
|
||||||
|
${EndIf}
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
Section "frpc (required)" SEC_FRPC
|
||||||
|
SectionIn RO
|
||||||
|
SetOutPath "$INSTDIR"
|
||||||
|
File "..\..\bin\frpc-windows-amd64.exe"
|
||||||
|
Rename "$INSTDIR\frpc-windows-amd64.exe" "$INSTDIR\frpc.exe"
|
||||||
|
|
||||||
|
; Config directory
|
||||||
|
CreateDirectory "$PROGRAMDATA\frpc"
|
||||||
|
SetOutPath "$PROGRAMDATA\frpc"
|
||||||
|
File "/oname=frpc.toml" "..\..\packaging\windows\frpc.default.toml"
|
||||||
|
|
||||||
|
WriteUninstaller "$INSTDIR\uninstall.exe"
|
||||||
|
|
||||||
|
; Registry for uninstaller
|
||||||
|
WriteRegStr HKLM "${PRODUCT_UNINSTALL_KEY}" "DisplayName" "${PRODUCT_NAME}"
|
||||||
|
WriteRegStr HKLM "${PRODUCT_UNINSTALL_KEY}" "UninstallString" "$INSTDIR\uninstall.exe"
|
||||||
|
WriteRegStr HKLM "${PRODUCT_UNINSTALL_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
|
||||||
|
WriteRegStr HKLM "${PRODUCT_UNINSTALL_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
|
||||||
|
WriteRegStr HKLM "${PRODUCT_UNINSTALL_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
|
||||||
|
WriteRegStr HKLM "${PRODUCT_UNINSTALL_KEY}" "DisplayIcon" "$INSTDIR\frpc.exe,0"
|
||||||
|
WriteRegStr HKLM "${PRODUCT_UNINSTALL_KEY}" "InstallLocation" "$INSTDIR"
|
||||||
|
WriteRegDWORD HKLM "${PRODUCT_UNINSTALL_KEY}" "NoModify" 1
|
||||||
|
WriteRegDWORD HKLM "${PRODUCT_UNINSTALL_KEY}" "NoRepair" 1
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
Section "Start Menu Shortcuts" SEC_SHORTCUTS
|
||||||
|
CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
|
||||||
|
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\frpc.lnk" "$INSTDIR\frpc.exe" "" "$INSTDIR\frpc.exe" 0
|
||||||
|
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Config Directory.lnk" "$PROGRAMDATA\frpc"
|
||||||
|
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe"
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
Section "Add to PATH" SEC_PATH
|
||||||
|
EnVar::AddValue "PATH" "$INSTDIR"
|
||||||
|
Pop $0
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
Section "Desktop Shortcut" SEC_DESKTOP
|
||||||
|
CreateShortCut "$DESKTOP\frpc.lnk" "$INSTDIR\frpc.exe" "" "$INSTDIR\frpc.exe" 0
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
; Descriptions
|
||||||
|
LangString DESC_SEC_FRPC ${LANG_ENGLISH} "frpc binary and default configuration."
|
||||||
|
LangString DESC_SEC_SHORTCUTS ${LANG_ENGLISH} "Start menu shortcuts for frpc."
|
||||||
|
LangString DESC_SEC_PATH ${LANG_ENGLISH} "Add frpc installation directory to system PATH."
|
||||||
|
LangString DESC_SEC_DESKTOP ${LANG_ENGLISH} "Create a desktop shortcut for frpc."
|
||||||
|
|
||||||
|
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
|
||||||
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_FRPC} $(DESC_SEC_FRPC)
|
||||||
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_SHORTCUTS} $(DESC_SEC_SHORTCUTS)
|
||||||
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_PATH} $(DESC_SEC_PATH)
|
||||||
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_DESKTOP} $(DESC_SEC_DESKTOP)
|
||||||
|
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
||||||
|
|
||||||
|
Section "Uninstall"
|
||||||
|
Delete "$INSTDIR\frpc.exe"
|
||||||
|
Delete "$INSTDIR\uninstall.exe"
|
||||||
|
RMDir "$INSTDIR"
|
||||||
|
|
||||||
|
Delete "$SMPROGRAMS\${PRODUCT_NAME}\frpc.lnk"
|
||||||
|
Delete "$SMPROGRAMS\${PRODUCT_NAME}\Config Directory.lnk"
|
||||||
|
Delete "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall.lnk"
|
||||||
|
RMDir "$SMPROGRAMS\${PRODUCT_NAME}"
|
||||||
|
|
||||||
|
Delete "$DESKTOP\frpc.lnk"
|
||||||
|
|
||||||
|
EnVar::DeleteValue "PATH" "$INSTDIR"
|
||||||
|
|
||||||
|
DeleteRegKey HKLM "${PRODUCT_UNINSTALL_KEY}"
|
||||||
|
SectionEnd
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Wix xmlns="http://wixtoolset.org/schemas/v3/wxs">
|
||||||
|
<Product
|
||||||
|
Name="frpc"
|
||||||
|
Id="*"
|
||||||
|
UpgradeCode="A1B2C3D4-E5F6-7890-ABCD-EF1234567890"
|
||||||
|
Language="1033"
|
||||||
|
Codepage="1252"
|
||||||
|
Version="0.62.0"
|
||||||
|
Manufacturer="frp Contributors">
|
||||||
|
|
||||||
|
<Package
|
||||||
|
InstallerVersion="200"
|
||||||
|
Compressed="yes"
|
||||||
|
InstallScope="perMachine"
|
||||||
|
Description="frp Client"
|
||||||
|
Comments="frpc is the client component of frp - a fast reverse proxy." />
|
||||||
|
|
||||||
|
<Media Id="1" Cabinet="frpc.cab" EmbedCab="yes" />
|
||||||
|
|
||||||
|
<Directory Id="TARGETDIR" Name="SourceDir">
|
||||||
|
<Directory Id="ProgramFiles64Folder">
|
||||||
|
<Directory Id="INSTALLDIR" Name="frpc">
|
||||||
|
<Component Id="FrpcBinary" Guid="E1B2C3D4-E5F6-7890-ABCD-EF1234567894">
|
||||||
|
<File Id="FrpcExe" Name="frpc.exe" DiskId="1" Source="bin/frpc-windows-amd64.exe" KeyPath="yes" />
|
||||||
|
</Component>
|
||||||
|
</Directory>
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
<Directory Id="ProgramMenuFolder">
|
||||||
|
<Directory Id="ApplicationProgramsFolder" Name="frpc">
|
||||||
|
<Component Id="StartMenuShortcuts" Guid="A2B2C3D4-E5F6-7890-ABCD-EF1234567892">
|
||||||
|
<Shortcut Id="FrpcShortcut" Name="frpc" Target="[INSTALLDIR]frpc.exe" WorkingDirectory="INSTALLDIR" Description="frp client" />
|
||||||
|
<Shortcut Id="UninstallShortcut" Name="Uninstall frpc" Target="[System64Folder]msiexec.exe" Arguments="/x [ProductCode]" />
|
||||||
|
<RemoveFolder Id="RemoveApplicationProgramsFolder" On="uninstall" />
|
||||||
|
<RegistryValue Root="HKCU" Key="Software\frp\frpc" Name="installed" Type="integer" Value="1" />
|
||||||
|
</Component>
|
||||||
|
</Directory>
|
||||||
|
</Directory>
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
<Feature Id="Main" Title="frpc" Description="frp client binary" Level="1">
|
||||||
|
<ComponentRef Id="FrpcBinary" />
|
||||||
|
<ComponentRef Id="StartMenuShortcuts" />
|
||||||
|
</Feature>
|
||||||
|
</Product>
|
||||||
|
</Wix>
|
||||||
@@ -0,0 +1,309 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
frpc Windows Setup Wizard (Interactive PowerShell Installer)
|
||||||
|
.DESCRIPTION
|
||||||
|
Interactive installer for frpc with EULA acceptance, directory selection,
|
||||||
|
and optional features (PATH, shortcuts, desktop icon).
|
||||||
|
.PARAMETER Unattended
|
||||||
|
Run in silent mode with defaults.
|
||||||
|
.PARAMETER InstallDir
|
||||||
|
Installation directory (default: $env:ProgramFiles\frpc).
|
||||||
|
.EXAMPLE
|
||||||
|
.\install.ps1
|
||||||
|
.\install.ps1 -Unattended
|
||||||
|
#>
|
||||||
|
|
||||||
|
param(
|
||||||
|
[switch]$Unattended,
|
||||||
|
[string]$InstallDir = "$env:ProgramFiles\frpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
$host.UI.RawUI.WindowTitle = "frpc Setup Wizard"
|
||||||
|
$env:FRPC_VERSION = "0.62.0"
|
||||||
|
|
||||||
|
function Write-Banner {
|
||||||
|
Clear-Host
|
||||||
|
Write-Host "========================================" -ForegroundColor Cyan
|
||||||
|
Write-Host " frpc - frp Client v$env:FRPC_VERSION" -ForegroundColor Cyan
|
||||||
|
Write-Host " Setup Wizard" -ForegroundColor Cyan
|
||||||
|
Write-Host "========================================" -ForegroundColor Cyan
|
||||||
|
Write-Host ""
|
||||||
|
}
|
||||||
|
|
||||||
|
function Show-License {
|
||||||
|
param([string]$Path)
|
||||||
|
Write-Banner
|
||||||
|
Write-Host "License Agreement" -ForegroundColor Yellow
|
||||||
|
Write-Host "==================" -ForegroundColor Yellow
|
||||||
|
Write-Host ""
|
||||||
|
if (Test-Path $Path) {
|
||||||
|
Get-Content $Path | ForEach-Object { Write-Host $_ }
|
||||||
|
} else {
|
||||||
|
Write-Host "frpc is licensed under the Apache License, Version 2.0."
|
||||||
|
Write-Host "See http://www.apache.org/licenses/LICENSE-2.0"
|
||||||
|
}
|
||||||
|
Write-Host ""
|
||||||
|
if (-not $Unattended) {
|
||||||
|
$choice = $host.UI.PromptForChoice(
|
||||||
|
"License Agreement",
|
||||||
|
"Do you accept the terms?",
|
||||||
|
[System.Management.Automation.Host.ChoiceDescription[]]@(
|
||||||
|
@{Label="&Agree"; Help="I accept the agreement"},
|
||||||
|
@{Label="&Decline"; Help="I do not accept the agreement"}
|
||||||
|
),
|
||||||
|
1
|
||||||
|
)
|
||||||
|
if ($choice -ne 0) {
|
||||||
|
Write-Host "Setup cancelled. You must accept the license to install." -ForegroundColor Red
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Select-Directory {
|
||||||
|
param([string]$DefaultPath)
|
||||||
|
Write-Banner
|
||||||
|
Write-Host "Installation Directory" -ForegroundColor Yellow
|
||||||
|
Write-Host "======================" -ForegroundColor Yellow
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Default: $DefaultPath" -ForegroundColor Gray
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
if (-not $Unattended) {
|
||||||
|
$input = Read-Host "Press Enter to accept, or type a custom path"
|
||||||
|
if ($input -ne "") {
|
||||||
|
return $input
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $DefaultPath
|
||||||
|
}
|
||||||
|
|
||||||
|
function Select-Components {
|
||||||
|
Write-Banner
|
||||||
|
Write-Host "Select Components" -ForegroundColor Yellow
|
||||||
|
Write-Host "=================" -ForegroundColor Yellow
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
$components = @{
|
||||||
|
"Main" = @{Desc="frpc binary and config"; Default=$true}
|
||||||
|
"Path" = @{Desc="Add to system PATH"; Default=$true}
|
||||||
|
"StartMenu" = @{Desc="Start Menu shortcuts"; Default=$true}
|
||||||
|
"Desktop" = @{Desc="Desktop shortcut"; Default=$false}
|
||||||
|
}
|
||||||
|
|
||||||
|
$selected = @{}
|
||||||
|
$i = 1
|
||||||
|
$choices = @()
|
||||||
|
|
||||||
|
foreach ($key in $components.Keys) {
|
||||||
|
$c = $components[$key]
|
||||||
|
$default = if ($c.Default) { "Y" } else { "N" }
|
||||||
|
$displayDefault = if ($c.Default) { "Yes" } else { "No" }
|
||||||
|
Write-Host " $i. $($c.Desc) [$displayDefault]" -ForegroundColor Gray
|
||||||
|
$choices += @{Key=$key; Default=$default}
|
||||||
|
$i++
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
if (-not $Unattended) {
|
||||||
|
Write-Host "Press Enter for defaults, or type numbers to toggle (e.g. 1,3):" -ForegroundColor Yellow
|
||||||
|
$input = Read-Host
|
||||||
|
if ($input -ne "") {
|
||||||
|
$toggleIndices = $input -split ',' | ForEach-Object { $_.Trim() } | Where-Object { $_ -ne "" }
|
||||||
|
for ($j = 0; $j -lt $choices.Count; $j++) {
|
||||||
|
$idx = $j + 1
|
||||||
|
$isToggled = [string]$idx -in $toggleIndices
|
||||||
|
$c = $components[$choices[$j].Key]
|
||||||
|
$default = $c.Default
|
||||||
|
$selected[$choices[$j].Key] = if ($isToggled) { -not $default } else { $default }
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
foreach ($ch in $choices) { $selected[$ch.Key] = $components[$ch.Key].Default }
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
foreach ($ch in $choices) { $selected[$ch.Key] = $components[$ch.Key].Default }
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Selected components:" -ForegroundColor Green
|
||||||
|
foreach ($key in $selected.Keys) {
|
||||||
|
$mark = if ($selected[$key]) { "[X]" } else { "[ ]" }
|
||||||
|
Write-Host " $mark $($components[$key].Desc)" -ForegroundColor $(if ($selected[$key]) { "Green" } else { "DarkGray" })
|
||||||
|
}
|
||||||
|
Start-Sleep 1
|
||||||
|
|
||||||
|
return $selected
|
||||||
|
}
|
||||||
|
|
||||||
|
function Install-Frpc {
|
||||||
|
param(
|
||||||
|
[string]$InstallDir,
|
||||||
|
[hashtable]$Components,
|
||||||
|
[string]$BinarySource
|
||||||
|
)
|
||||||
|
|
||||||
|
Write-Banner
|
||||||
|
Write-Host "Installing frpc..." -ForegroundColor Yellow
|
||||||
|
Write-Host "==================" -ForegroundColor Yellow
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
# Create directories
|
||||||
|
Write-Host " Creating directories..." -NoNewline
|
||||||
|
New-Item -Path $InstallDir -ItemType Directory -Force | Out-Null
|
||||||
|
$configDir = "$env:ProgramData\frpc"
|
||||||
|
New-Item -Path $configDir -ItemType Directory -Force | Out-Null
|
||||||
|
Write-Host " OK" -ForegroundColor Green
|
||||||
|
|
||||||
|
# Copy binary
|
||||||
|
Write-Host " Copying frpc.exe..." -NoNewline
|
||||||
|
if ($BinarySource -and (Test-Path $BinarySource)) {
|
||||||
|
Copy-Item -Path $BinarySource -Destination "$InstallDir\frpc.exe" -Force
|
||||||
|
} else {
|
||||||
|
# Download from GitHub
|
||||||
|
$url = "https://github.com/fatedier/frp/releases/download/v$env:FRPC_VERSION/frp_${env:FRPC_VERSION}_windows_amd64.zip"
|
||||||
|
$zipPath = "$env:TEMP\frpc.zip"
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host " Downloading from GitHub..." -NoNewline
|
||||||
|
Invoke-WebRequest -Uri $url -OutFile $zipPath -UseBasicParsing
|
||||||
|
Expand-Archive -Path $zipPath -DestinationPath "$env:TEMP\frpc" -Force
|
||||||
|
$exePath = Get-ChildItem -Path "$env:TEMP\frpc" -Recurse -Filter "frpc.exe" | Select-Object -First 1 -ExpandProperty FullName
|
||||||
|
if (-not $exePath) { throw "frpc.exe not found in archive" }
|
||||||
|
Copy-Item -Path $exePath -Destination "$InstallDir\frpc.exe" -Force
|
||||||
|
}
|
||||||
|
Write-Host " OK" -ForegroundColor Green
|
||||||
|
|
||||||
|
# Config file
|
||||||
|
Write-Host " Creating config..." -NoNewline
|
||||||
|
$configFile = "$configDir\frpc.toml"
|
||||||
|
if (-not (Test-Path $configFile)) {
|
||||||
|
@"
|
||||||
|
# frpc configuration
|
||||||
|
# Edit this file to configure your frp client.
|
||||||
|
|
||||||
|
serverAddr = "127.0.0.1"
|
||||||
|
serverPort = 7000
|
||||||
|
auth.token = ""
|
||||||
|
"@ | Out-File -FilePath $configFile -Encoding utf8
|
||||||
|
}
|
||||||
|
Write-Host " OK" -ForegroundColor Green
|
||||||
|
|
||||||
|
# PATH
|
||||||
|
if ($Components["Path"]) {
|
||||||
|
Write-Host " Adding to PATH..." -NoNewline
|
||||||
|
$currentPath = [Environment]::GetEnvironmentVariable("PATH", "Machine")
|
||||||
|
if ($currentPath -notlike "*$InstallDir*") {
|
||||||
|
$newPath = "$currentPath;$InstallDir"
|
||||||
|
[Environment]::SetEnvironmentVariable("PATH", $newPath, "Machine")
|
||||||
|
$env:PATH = "$env:PATH;$InstallDir"
|
||||||
|
}
|
||||||
|
Write-Host " OK" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
|
||||||
|
# Start Menu
|
||||||
|
if ($Components["StartMenu"]) {
|
||||||
|
Write-Host " Creating Start Menu shortcuts..." -NoNewline
|
||||||
|
$startMenu = "$([Environment]::GetFolderPath('CommonStartMenu'))\Programs\frpc"
|
||||||
|
New-Item -Path $startMenu -ItemType Directory -Force | Out-Null
|
||||||
|
$wshell = New-Object -ComObject WScript.Shell
|
||||||
|
$shortcut = $wshell.CreateShortcut("$startMenu\frpc.lnk")
|
||||||
|
$shortcut.TargetPath = "$InstallDir\frpc.exe"
|
||||||
|
$shortcut.Save()
|
||||||
|
$unlink = $wshell.CreateShortcut("$startMenu\Uninstall frpc.lnk")
|
||||||
|
$unlink.TargetPath = "$InstallDir\uninstall.ps1"
|
||||||
|
$unlink.Save()
|
||||||
|
Write-Host " OK" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
|
||||||
|
# Desktop
|
||||||
|
if ($Components["Desktop"]) {
|
||||||
|
Write-Host " Creating desktop shortcut..." -NoNewline
|
||||||
|
$desktop = [Environment]::GetFolderPath('Desktop')
|
||||||
|
$wshell = New-Object -ComObject WScript.Shell
|
||||||
|
$shortcut = $wshell.CreateShortcut("$desktop\frpc.lnk")
|
||||||
|
$shortcut.TargetPath = "$InstallDir\frpc.exe"
|
||||||
|
$shortcut.Save()
|
||||||
|
Write-Host " OK" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
|
||||||
|
# Write uninstall script
|
||||||
|
Write-Host " Creating uninstaller..." -NoNewline
|
||||||
|
@"
|
||||||
|
param([switch]`$Silent)
|
||||||
|
`$InstallDir = "$InstallDir"
|
||||||
|
if (-not `$Silent) {
|
||||||
|
`$choice = `$host.UI.PromptForChoice("Uninstall frpc", "Remove frpc from this computer?", @(@{Label="&Yes"; Help=""}, @{Label="&No"; Help=""}), 1)
|
||||||
|
if (`$choice -ne 0) { exit }
|
||||||
|
}
|
||||||
|
# Remove files
|
||||||
|
Remove-Item -Path "`$InstallDir\frpc.exe" -Force -ErrorAction SilentlyContinue
|
||||||
|
Remove-Item -Path "`$InstallDir\uninstall.ps1" -Force -ErrorAction SilentlyContinue
|
||||||
|
Remove-Item -Path "`$InstallDir" -Force -ErrorAction SilentlyContinue
|
||||||
|
# Remove shortcuts
|
||||||
|
Remove-Item -Path "$([Environment]::GetFolderPath('CommonStartMenu'))\Programs\frpc" -Recurse -Force -ErrorAction SilentlyContinue
|
||||||
|
Remove-Item -Path "$([Environment]::GetFolderPath('Desktop'))\frpc.lnk" -Force -ErrorAction SilentlyContinue
|
||||||
|
Write-Host "frpc has been uninstalled."
|
||||||
|
"@ | Out-File -FilePath "$InstallDir\uninstall.ps1" -Encoding utf8
|
||||||
|
Write-Host " OK" -ForegroundColor Green
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Installation complete!" -ForegroundColor Green
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Quick start:" -ForegroundColor Yellow
|
||||||
|
Write-Host " frpc --help"
|
||||||
|
Write-Host " frpc --server-config http://your-server:7500/admin/api/frpc/proxy-config/YOUR_KEY"
|
||||||
|
Write-Host " frpc -c $configFile"
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Auth with provisioning token:" -ForegroundColor Yellow
|
||||||
|
Write-Host " frpc auth login --server http://your-server:7500 --client-name myclient"
|
||||||
|
Write-Host ""
|
||||||
|
}
|
||||||
|
|
||||||
|
# ===== Main =====
|
||||||
|
|
||||||
|
$scriptDir = Split-Path -Parent $PSCommandPath
|
||||||
|
$binarySource = Join-Path $scriptDir "..\bin\frpc-windows-amd64.exe"
|
||||||
|
if (-not (Test-Path $binarySource)) {
|
||||||
|
$binarySource = Join-Path $scriptDir "frpc-windows-amd64.exe"
|
||||||
|
}
|
||||||
|
if (-not (Test-Path $binarySource)) {
|
||||||
|
$binarySource = $null
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check admin rights
|
||||||
|
$isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
||||||
|
if (-not $isAdmin) {
|
||||||
|
Write-Host "This installer requires administrator privileges." -ForegroundColor Red
|
||||||
|
Write-Host "Please run PowerShell as Administrator and try again." -ForegroundColor Yellow
|
||||||
|
if (-not $Unattended) {
|
||||||
|
Start-Sleep 2
|
||||||
|
# Self-elevate
|
||||||
|
$script = "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`""
|
||||||
|
Start-Process powershell -Verb RunAs -ArgumentList $script
|
||||||
|
}
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Unattended) {
|
||||||
|
Install-Frpc -InstallDir $InstallDir -Components @{
|
||||||
|
Main=$true; Path=$true; StartMenu=$true; Desktop=$false
|
||||||
|
} -BinarySource $binarySource
|
||||||
|
} else {
|
||||||
|
Show-License -Path (Join-Path $scriptDir "license.txt")
|
||||||
|
$dir = Select-Directory -DefaultPath $InstallDir
|
||||||
|
$components = Select-Components
|
||||||
|
Install-Frpc -InstallDir $dir -Components $components -BinarySource $binarySource
|
||||||
|
Write-Host ""
|
||||||
|
$runNow = $host.UI.PromptForChoice(
|
||||||
|
"Setup Complete",
|
||||||
|
"Run frpc now?",
|
||||||
|
[System.Management.Automation.Host.ChoiceDescription[]]@(
|
||||||
|
@{Label="&Yes"; Help="Run frpc"},
|
||||||
|
@{Label="&No"; Help="Close"}
|
||||||
|
),
|
||||||
|
0
|
||||||
|
)
|
||||||
|
if ($runNow -eq 0) {
|
||||||
|
Start-Process "$dir\frpc.exe"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
{\rtf1\ansi\ansicpg1252\deff0\deflang1033\deftab720{\fonttbl{\f0\fnil\fcharset0 Arial;}{\f1\fmodern\fcharset0 Courier New;}}
|
||||||
|
{\colortbl\red0\green0\blue0;\red255\green255\blue255;}
|
||||||
|
\viewkind4\uc1\pard\qc\b\fs28 frpc - frp Client\par
|
||||||
|
\b0\fs20 Version 0.62.0\par
|
||||||
|
\pard\sa200\sl240\slmult1\fs20\par
|
||||||
|
\pard\sa200\sl240\slmult1\b\fs24 License Agreement\b0\fs20\par
|
||||||
|
\pard\sa200\sl240\slmult1\par
|
||||||
|
\pard\sa200\sl240\slmult1\fs20 This is a legal agreement between you (the "Licensee") and the frp project contributors ("Licensor"). By installing or using frpc, you agree to the following terms and conditions.\par
|
||||||
|
\pard\sa200\sl240\slmult1\par
|
||||||
|
\pard\sa200\sl240\slmult1\b 1. Grant of License\b0\par
|
||||||
|
\pard\sa200\sl240\slmult1 The frpc software is licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at:\par
|
||||||
|
\pard\sa200\sl240\slmult1 http://www.apache.org/licenses/LICENSE-2.0\par
|
||||||
|
\pard\sa200\sl240\slmult1\par
|
||||||
|
\pard\sa200\sl240\slmult1\b 2. Distribution\b0\par
|
||||||
|
\pard\sa200\sl240\slmult1 You may reproduce and distribute copies of the work or derivative works thereof in any medium, with or without modifications, and in source or object form, provided that you meet the following conditions:\par
|
||||||
|
\pard\sa200\sl240\slmult1 - You must give any other recipients of the work or derivative works a copy of this License\par
|
||||||
|
\pard\sa200\sl240\slmult1 - You must cause any modified files to carry prominent notices stating that you changed the files\par
|
||||||
|
\pard\sa200\sl240\slmult1 - You must retain all copyright, patent, trademark, and attribution notices\par
|
||||||
|
\pard\sa200\sl240\slmult1\par
|
||||||
|
\pard\sa200\sl240\slmult1\b 3. Disclaimer of Warranty\b0\par
|
||||||
|
\pard\sa200\sl240\slmult1 Unless required by applicable law or agreed to in writing, the software is provided on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\par
|
||||||
|
\pard\sa200\sl240\slmult1\par
|
||||||
|
\pard\sa200\sl240\slmult1\b 4. Limitation of Liability\b0\par
|
||||||
|
\pard\sa200\sl240\slmult1 In no event and under no legal theory shall the authors or copyright holders be liable for any damages arising from the use of the software.\par
|
||||||
|
\pard\sa200\sl240\slmult1\par
|
||||||
|
\pard\sa200\sl240\slmult1\b 5. Termination\b0\par
|
||||||
|
\pard\sa200\sl240\slmult1 This license automatically terminates if you violate any of its terms. Upon termination, you must destroy all copies of the software.\par
|
||||||
|
\pard\sa200\sl240\slmult1\par
|
||||||
|
\pard\sa200\sl240\slmult1\b 6. Governing Law\b0\par
|
||||||
|
\pard\sa200\sl240\slmult1 This license shall be governed by the laws applicable to the Licensor's jurisdiction.\par
|
||||||
|
\pard\sa200\sl240\slmult1\par
|
||||||
|
\pard\sa200\sl240\slmult1 By clicking "I Agree" or installing the software, you acknowledge that you have read this agreement, understand it, and agree to be bound by its terms.\par
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
frpc - frp Client (version 0.62.0)
|
||||||
|
=====================================
|
||||||
|
Copyright (c) frp project contributors.
|
||||||
|
Licensed under the Apache License, Version 2.0.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
1. Grant of License
|
||||||
|
frpc is licensed under the Apache License, Version 2.0 (the "License").
|
||||||
|
You may not use this file except in compliance with the License.
|
||||||
|
A copy of the License is available at:
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
2. Distribution
|
||||||
|
You may reproduce and distribute copies of the work or derivative works
|
||||||
|
in any medium, with or without modifications, and in source or object
|
||||||
|
form, provided that you meet the following conditions:
|
||||||
|
- You must give any other recipients a copy of this License
|
||||||
|
- You must cause any modified files to carry prominent notices
|
||||||
|
- You must retain all copyright, patent, trademark notices
|
||||||
|
|
||||||
|
3. Disclaimer of Warranty
|
||||||
|
Unless required by applicable law, the software is provided "AS IS",
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied.
|
||||||
|
|
||||||
|
4. Limitation of Liability
|
||||||
|
In no event shall the authors be liable for any damages arising from
|
||||||
|
the use of this software.
|
||||||
|
|
||||||
|
5. Termination
|
||||||
|
This license automatically terminates if you violate its terms.
|
||||||
|
|
||||||
|
By installing this software, you accept these terms.
|
||||||
@@ -78,8 +78,13 @@ type ClientCommonConfig struct {
|
|||||||
// Include other config files for proxies.
|
// Include other config files for proxies.
|
||||||
IncludeConfigFiles []string `json:"includes,omitempty"`
|
IncludeConfigFiles []string `json:"includes,omitempty"`
|
||||||
|
|
||||||
// Store config enables the built-in store source (not configurable via sources list).
|
// Store config enables the built-in store source.
|
||||||
Store StoreConfig `json:"store,omitempty"`
|
Store StoreConfig `json:"store,omitempty"`
|
||||||
|
|
||||||
|
// ConfigURL fetches the full client configuration from a remote URL.
|
||||||
|
// When set, frpc fetches this URL on startup and periodically thereafter,
|
||||||
|
// automatically reloading when the configuration changes.
|
||||||
|
ConfigURL string `json:"configURL,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ClientCommonConfig) Complete() error {
|
func (c *ClientCommonConfig) Complete() error {
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
v1 "github.com/fatedier/frp/pkg/config/v1"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/serverconfig"
|
||||||
|
)
|
||||||
|
|
||||||
|
const configKey = "server_config"
|
||||||
|
|
||||||
|
func LoadServerConfig() (*v1.ServerConfig, error) {
|
||||||
|
ctx := context.Background()
|
||||||
|
sc, err := client.ServerConfig.Query().Where(serverconfig.KeyEQ(configKey)).Only(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cfg := &v1.ServerConfig{}
|
||||||
|
if err := json.Unmarshal([]byte(sc.Value), cfg); err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to unmarshal server config from db: %w", err)
|
||||||
|
}
|
||||||
|
return cfg, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SaveServerConfig(cfg *v1.ServerConfig) error {
|
||||||
|
ctx := context.Background()
|
||||||
|
return SaveServerConfigWithContext(ctx, cfg)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SaveServerConfigWithContext(ctx context.Context, cfg *v1.ServerConfig) error {
|
||||||
|
cfg.Version = ""
|
||||||
|
data, err := json.Marshal(cfg)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to marshal server config: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
exists, err := client.ServerConfig.Query().Where(serverconfig.KeyEQ(configKey)).Exist(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if exists {
|
||||||
|
_, err = client.ServerConfig.Update().
|
||||||
|
Where(serverconfig.KeyEQ(configKey)).
|
||||||
|
SetValue(string(data)).
|
||||||
|
Save(ctx)
|
||||||
|
} else {
|
||||||
|
_, err = client.ServerConfig.Create().
|
||||||
|
SetKey(configKey).
|
||||||
|
SetValue(string(data)).
|
||||||
|
Save(ctx)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func HasServerConfig() (bool, error) {
|
||||||
|
ctx := context.Background()
|
||||||
|
return client.ServerConfig.Query().Where(serverconfig.KeyEQ(configKey)).Exist(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SaveDefaultServerConfig() error {
|
||||||
|
cfg := DefaultServerConfig()
|
||||||
|
return SaveServerConfig(cfg)
|
||||||
|
}
|
||||||
|
|
||||||
|
func DefaultServerConfig() *v1.ServerConfig {
|
||||||
|
return &v1.ServerConfig{
|
||||||
|
BindAddr: "0.0.0.0",
|
||||||
|
BindPort: 7000,
|
||||||
|
WebServer: v1.WebServerConfig{
|
||||||
|
Addr: "0.0.0.0",
|
||||||
|
Port: 7500,
|
||||||
|
User: "admin",
|
||||||
|
Password: "admin",
|
||||||
|
},
|
||||||
|
Log: v1.LogConfig{
|
||||||
|
To: "console",
|
||||||
|
Level: "info",
|
||||||
|
MaxDays: 3,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
|
_ "modernc.org/sqlite"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect"
|
||||||
|
entsql "entgo.io/ent/dialect/sql"
|
||||||
|
"golang.org/x/crypto/bcrypt"
|
||||||
|
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
client *ent.Client
|
||||||
|
)
|
||||||
|
|
||||||
|
func Init(driverName, dataSourceName string) error {
|
||||||
|
if driverName == "" {
|
||||||
|
driverName = "sqlite"
|
||||||
|
}
|
||||||
|
if dataSourceName == "" {
|
||||||
|
dataSourceName = "admin.db"
|
||||||
|
}
|
||||||
|
|
||||||
|
dsn := dataSourceName + "?:_pragma=journal_mode=WAL&_pragma=foreign_keys=1"
|
||||||
|
sqldb, err := sql.Open(driverName, dsn)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed opening sql database: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
drv := entsql.OpenDB(dialect.SQLite, sqldb)
|
||||||
|
entClient := ent.NewClient(ent.Driver(drv))
|
||||||
|
|
||||||
|
ctx := context.Background()
|
||||||
|
if err := entClient.Schema.Create(ctx); err != nil {
|
||||||
|
return fmt.Errorf("failed creating schema resources: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
client = entClient
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func Close() error {
|
||||||
|
if client != nil {
|
||||||
|
return client.Close()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func Client() *ent.Client {
|
||||||
|
return client
|
||||||
|
}
|
||||||
|
|
||||||
|
func HasAdmin() bool {
|
||||||
|
ctx := context.Background()
|
||||||
|
exists, err := client.User.Query().Exist(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return exists
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateAdmin(username, password, name string) error {
|
||||||
|
ctx := context.Background()
|
||||||
|
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to hash password: %w", err)
|
||||||
|
}
|
||||||
|
_, err = client.User.Create().
|
||||||
|
SetUsername(username).
|
||||||
|
SetPassword(string(hashedPassword)).
|
||||||
|
SetName(name).
|
||||||
|
SetRole("admin").
|
||||||
|
Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to create admin user: %w", err)
|
||||||
|
}
|
||||||
|
log.Printf("admin user created: %s", username)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,769 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"reflect"
|
||||||
|
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/migrate"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/frpcclient"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/proxy"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/serverconfig"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Client is the client that holds all ent builders.
|
||||||
|
type Client struct {
|
||||||
|
config
|
||||||
|
// Schema is the client for creating, migrating and dropping schema.
|
||||||
|
Schema *migrate.Schema
|
||||||
|
// FrpcClient is the client for interacting with the FrpcClient builders.
|
||||||
|
FrpcClient *FrpcClientClient
|
||||||
|
// Proxy is the client for interacting with the Proxy builders.
|
||||||
|
Proxy *ProxyClient
|
||||||
|
// ServerConfig is the client for interacting with the ServerConfig builders.
|
||||||
|
ServerConfig *ServerConfigClient
|
||||||
|
// User is the client for interacting with the User builders.
|
||||||
|
User *UserClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewClient creates a new client configured with the given options.
|
||||||
|
func NewClient(opts ...Option) *Client {
|
||||||
|
client := &Client{config: newConfig(opts...)}
|
||||||
|
client.init()
|
||||||
|
return client
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) init() {
|
||||||
|
c.Schema = migrate.NewSchema(c.driver)
|
||||||
|
c.FrpcClient = NewFrpcClientClient(c.config)
|
||||||
|
c.Proxy = NewProxyClient(c.config)
|
||||||
|
c.ServerConfig = NewServerConfigClient(c.config)
|
||||||
|
c.User = NewUserClient(c.config)
|
||||||
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
// config is the configuration for the client and its builder.
|
||||||
|
config struct {
|
||||||
|
// driver used for executing database requests.
|
||||||
|
driver dialect.Driver
|
||||||
|
// debug enable a debug logging.
|
||||||
|
debug bool
|
||||||
|
// log used for logging on debug mode.
|
||||||
|
log func(...any)
|
||||||
|
// hooks to execute on mutations.
|
||||||
|
hooks *hooks
|
||||||
|
// interceptors to execute on queries.
|
||||||
|
inters *inters
|
||||||
|
}
|
||||||
|
// Option function to configure the client.
|
||||||
|
Option func(*config)
|
||||||
|
)
|
||||||
|
|
||||||
|
// newConfig creates a new config for the client.
|
||||||
|
func newConfig(opts ...Option) config {
|
||||||
|
cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}}
|
||||||
|
cfg.options(opts...)
|
||||||
|
return cfg
|
||||||
|
}
|
||||||
|
|
||||||
|
// options applies the options on the config object.
|
||||||
|
func (c *config) options(opts ...Option) {
|
||||||
|
for _, opt := range opts {
|
||||||
|
opt(c)
|
||||||
|
}
|
||||||
|
if c.debug {
|
||||||
|
c.driver = dialect.Debug(c.driver, c.log)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Debug enables debug logging on the ent.Driver.
|
||||||
|
func Debug() Option {
|
||||||
|
return func(c *config) {
|
||||||
|
c.debug = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log sets the logging function for debug mode.
|
||||||
|
func Log(fn func(...any)) Option {
|
||||||
|
return func(c *config) {
|
||||||
|
c.log = fn
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Driver configures the client driver.
|
||||||
|
func Driver(driver dialect.Driver) Option {
|
||||||
|
return func(c *config) {
|
||||||
|
c.driver = driver
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open opens a database/sql.DB specified by the driver name and
|
||||||
|
// the data source name, and returns a new client attached to it.
|
||||||
|
// Optional parameters can be added for configuring the client.
|
||||||
|
func Open(driverName, dataSourceName string, options ...Option) (*Client, error) {
|
||||||
|
switch driverName {
|
||||||
|
case dialect.MySQL, dialect.Postgres, dialect.SQLite:
|
||||||
|
drv, err := sql.Open(driverName, dataSourceName)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return NewClient(append(options, Driver(drv))...), nil
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("unsupported driver: %q", driverName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrTxStarted is returned when trying to start a new transaction from a transactional client.
|
||||||
|
var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction")
|
||||||
|
|
||||||
|
// Tx returns a new transactional client. The provided context
|
||||||
|
// is used until the transaction is committed or rolled back.
|
||||||
|
func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
||||||
|
if _, ok := c.driver.(*txDriver); ok {
|
||||||
|
return nil, ErrTxStarted
|
||||||
|
}
|
||||||
|
tx, err := newTx(ctx, c.driver)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("ent: starting a transaction: %w", err)
|
||||||
|
}
|
||||||
|
cfg := c.config
|
||||||
|
cfg.driver = tx
|
||||||
|
return &Tx{
|
||||||
|
ctx: ctx,
|
||||||
|
config: cfg,
|
||||||
|
FrpcClient: NewFrpcClientClient(cfg),
|
||||||
|
Proxy: NewProxyClient(cfg),
|
||||||
|
ServerConfig: NewServerConfigClient(cfg),
|
||||||
|
User: NewUserClient(cfg),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// BeginTx returns a transactional client with specified options.
|
||||||
|
func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) {
|
||||||
|
if _, ok := c.driver.(*txDriver); ok {
|
||||||
|
return nil, errors.New("ent: cannot start a transaction within a transaction")
|
||||||
|
}
|
||||||
|
tx, err := c.driver.(interface {
|
||||||
|
BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error)
|
||||||
|
}).BeginTx(ctx, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("ent: starting a transaction: %w", err)
|
||||||
|
}
|
||||||
|
cfg := c.config
|
||||||
|
cfg.driver = &txDriver{tx: tx, drv: c.driver}
|
||||||
|
return &Tx{
|
||||||
|
ctx: ctx,
|
||||||
|
config: cfg,
|
||||||
|
FrpcClient: NewFrpcClientClient(cfg),
|
||||||
|
Proxy: NewProxyClient(cfg),
|
||||||
|
ServerConfig: NewServerConfigClient(cfg),
|
||||||
|
User: NewUserClient(cfg),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Debug returns a new debug-client. It's used to get verbose logging on specific operations.
|
||||||
|
//
|
||||||
|
// client.Debug().
|
||||||
|
// FrpcClient.
|
||||||
|
// Query().
|
||||||
|
// Count(ctx)
|
||||||
|
func (c *Client) Debug() *Client {
|
||||||
|
if c.debug {
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
cfg := c.config
|
||||||
|
cfg.driver = dialect.Debug(c.driver, c.log)
|
||||||
|
client := &Client{config: cfg}
|
||||||
|
client.init()
|
||||||
|
return client
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close closes the database connection and prevents new queries from starting.
|
||||||
|
func (c *Client) Close() error {
|
||||||
|
return c.driver.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use adds the mutation hooks to all the entity clients.
|
||||||
|
// In order to add hooks to a specific client, call: `client.Node.Use(...)`.
|
||||||
|
func (c *Client) Use(hooks ...Hook) {
|
||||||
|
c.FrpcClient.Use(hooks...)
|
||||||
|
c.Proxy.Use(hooks...)
|
||||||
|
c.ServerConfig.Use(hooks...)
|
||||||
|
c.User.Use(hooks...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Intercept adds the query interceptors to all the entity clients.
|
||||||
|
// In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.
|
||||||
|
func (c *Client) Intercept(interceptors ...Interceptor) {
|
||||||
|
c.FrpcClient.Intercept(interceptors...)
|
||||||
|
c.Proxy.Intercept(interceptors...)
|
||||||
|
c.ServerConfig.Intercept(interceptors...)
|
||||||
|
c.User.Intercept(interceptors...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutate implements the ent.Mutator interface.
|
||||||
|
func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
|
||||||
|
switch m := m.(type) {
|
||||||
|
case *FrpcClientMutation:
|
||||||
|
return c.FrpcClient.mutate(ctx, m)
|
||||||
|
case *ProxyMutation:
|
||||||
|
return c.Proxy.mutate(ctx, m)
|
||||||
|
case *ServerConfigMutation:
|
||||||
|
return c.ServerConfig.mutate(ctx, m)
|
||||||
|
case *UserMutation:
|
||||||
|
return c.User.mutate(ctx, m)
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("ent: unknown mutation type %T", m)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FrpcClientClient is a client for the FrpcClient schema.
|
||||||
|
type FrpcClientClient struct {
|
||||||
|
config
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewFrpcClientClient returns a client for the FrpcClient from the given config.
|
||||||
|
func NewFrpcClientClient(c config) *FrpcClientClient {
|
||||||
|
return &FrpcClientClient{config: c}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use adds a list of mutation hooks to the hooks stack.
|
||||||
|
// A call to `Use(f, g, h)` equals to `frpcclient.Hooks(f(g(h())))`.
|
||||||
|
func (c *FrpcClientClient) Use(hooks ...Hook) {
|
||||||
|
c.hooks.FrpcClient = append(c.hooks.FrpcClient, hooks...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||||
|
// A call to `Intercept(f, g, h)` equals to `frpcclient.Intercept(f(g(h())))`.
|
||||||
|
func (c *FrpcClientClient) Intercept(interceptors ...Interceptor) {
|
||||||
|
c.inters.FrpcClient = append(c.inters.FrpcClient, interceptors...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create returns a builder for creating a FrpcClient entity.
|
||||||
|
func (c *FrpcClientClient) Create() *FrpcClientCreate {
|
||||||
|
mutation := newFrpcClientMutation(c.config, OpCreate)
|
||||||
|
return &FrpcClientCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateBulk returns a builder for creating a bulk of FrpcClient entities.
|
||||||
|
func (c *FrpcClientClient) CreateBulk(builders ...*FrpcClientCreate) *FrpcClientCreateBulk {
|
||||||
|
return &FrpcClientCreateBulk{config: c.config, builders: builders}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||||
|
// a builder and applies setFunc on it.
|
||||||
|
func (c *FrpcClientClient) MapCreateBulk(slice any, setFunc func(*FrpcClientCreate, int)) *FrpcClientCreateBulk {
|
||||||
|
rv := reflect.ValueOf(slice)
|
||||||
|
if rv.Kind() != reflect.Slice {
|
||||||
|
return &FrpcClientCreateBulk{err: fmt.Errorf("calling to FrpcClientClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||||
|
}
|
||||||
|
builders := make([]*FrpcClientCreate, rv.Len())
|
||||||
|
for i := 0; i < rv.Len(); i++ {
|
||||||
|
builders[i] = c.Create()
|
||||||
|
setFunc(builders[i], i)
|
||||||
|
}
|
||||||
|
return &FrpcClientCreateBulk{config: c.config, builders: builders}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update returns an update builder for FrpcClient.
|
||||||
|
func (c *FrpcClientClient) Update() *FrpcClientUpdate {
|
||||||
|
mutation := newFrpcClientMutation(c.config, OpUpdate)
|
||||||
|
return &FrpcClientUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateOne returns an update builder for the given entity.
|
||||||
|
func (c *FrpcClientClient) UpdateOne(_m *FrpcClient) *FrpcClientUpdateOne {
|
||||||
|
mutation := newFrpcClientMutation(c.config, OpUpdateOne, withFrpcClient(_m))
|
||||||
|
return &FrpcClientUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateOneID returns an update builder for the given id.
|
||||||
|
func (c *FrpcClientClient) UpdateOneID(id int) *FrpcClientUpdateOne {
|
||||||
|
mutation := newFrpcClientMutation(c.config, OpUpdateOne, withFrpcClientID(id))
|
||||||
|
return &FrpcClientUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete returns a delete builder for FrpcClient.
|
||||||
|
func (c *FrpcClientClient) Delete() *FrpcClientDelete {
|
||||||
|
mutation := newFrpcClientMutation(c.config, OpDelete)
|
||||||
|
return &FrpcClientDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteOne returns a builder for deleting the given entity.
|
||||||
|
func (c *FrpcClientClient) DeleteOne(_m *FrpcClient) *FrpcClientDeleteOne {
|
||||||
|
return c.DeleteOneID(_m.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||||
|
func (c *FrpcClientClient) DeleteOneID(id int) *FrpcClientDeleteOne {
|
||||||
|
builder := c.Delete().Where(frpcclient.ID(id))
|
||||||
|
builder.mutation.id = &id
|
||||||
|
builder.mutation.op = OpDeleteOne
|
||||||
|
return &FrpcClientDeleteOne{builder}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Query returns a query builder for FrpcClient.
|
||||||
|
func (c *FrpcClientClient) Query() *FrpcClientQuery {
|
||||||
|
return &FrpcClientQuery{
|
||||||
|
config: c.config,
|
||||||
|
ctx: &QueryContext{Type: TypeFrpcClient},
|
||||||
|
inters: c.Interceptors(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get returns a FrpcClient entity by its id.
|
||||||
|
func (c *FrpcClientClient) Get(ctx context.Context, id int) (*FrpcClient, error) {
|
||||||
|
return c.Query().Where(frpcclient.ID(id)).Only(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetX is like Get, but panics if an error occurs.
|
||||||
|
func (c *FrpcClientClient) GetX(ctx context.Context, id int) *FrpcClient {
|
||||||
|
obj, err := c.Get(ctx, id)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return obj
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hooks returns the client hooks.
|
||||||
|
func (c *FrpcClientClient) Hooks() []Hook {
|
||||||
|
return c.hooks.FrpcClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// Interceptors returns the client interceptors.
|
||||||
|
func (c *FrpcClientClient) Interceptors() []Interceptor {
|
||||||
|
return c.inters.FrpcClient
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *FrpcClientClient) mutate(ctx context.Context, m *FrpcClientMutation) (Value, error) {
|
||||||
|
switch m.Op() {
|
||||||
|
case OpCreate:
|
||||||
|
return (&FrpcClientCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||||
|
case OpUpdate:
|
||||||
|
return (&FrpcClientUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||||
|
case OpUpdateOne:
|
||||||
|
return (&FrpcClientUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||||
|
case OpDelete, OpDeleteOne:
|
||||||
|
return (&FrpcClientDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("ent: unknown FrpcClient mutation op: %q", m.Op())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProxyClient is a client for the Proxy schema.
|
||||||
|
type ProxyClient struct {
|
||||||
|
config
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewProxyClient returns a client for the Proxy from the given config.
|
||||||
|
func NewProxyClient(c config) *ProxyClient {
|
||||||
|
return &ProxyClient{config: c}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use adds a list of mutation hooks to the hooks stack.
|
||||||
|
// A call to `Use(f, g, h)` equals to `proxy.Hooks(f(g(h())))`.
|
||||||
|
func (c *ProxyClient) Use(hooks ...Hook) {
|
||||||
|
c.hooks.Proxy = append(c.hooks.Proxy, hooks...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||||
|
// A call to `Intercept(f, g, h)` equals to `proxy.Intercept(f(g(h())))`.
|
||||||
|
func (c *ProxyClient) Intercept(interceptors ...Interceptor) {
|
||||||
|
c.inters.Proxy = append(c.inters.Proxy, interceptors...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create returns a builder for creating a Proxy entity.
|
||||||
|
func (c *ProxyClient) Create() *ProxyCreate {
|
||||||
|
mutation := newProxyMutation(c.config, OpCreate)
|
||||||
|
return &ProxyCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateBulk returns a builder for creating a bulk of Proxy entities.
|
||||||
|
func (c *ProxyClient) CreateBulk(builders ...*ProxyCreate) *ProxyCreateBulk {
|
||||||
|
return &ProxyCreateBulk{config: c.config, builders: builders}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||||
|
// a builder and applies setFunc on it.
|
||||||
|
func (c *ProxyClient) MapCreateBulk(slice any, setFunc func(*ProxyCreate, int)) *ProxyCreateBulk {
|
||||||
|
rv := reflect.ValueOf(slice)
|
||||||
|
if rv.Kind() != reflect.Slice {
|
||||||
|
return &ProxyCreateBulk{err: fmt.Errorf("calling to ProxyClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||||
|
}
|
||||||
|
builders := make([]*ProxyCreate, rv.Len())
|
||||||
|
for i := 0; i < rv.Len(); i++ {
|
||||||
|
builders[i] = c.Create()
|
||||||
|
setFunc(builders[i], i)
|
||||||
|
}
|
||||||
|
return &ProxyCreateBulk{config: c.config, builders: builders}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update returns an update builder for Proxy.
|
||||||
|
func (c *ProxyClient) Update() *ProxyUpdate {
|
||||||
|
mutation := newProxyMutation(c.config, OpUpdate)
|
||||||
|
return &ProxyUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateOne returns an update builder for the given entity.
|
||||||
|
func (c *ProxyClient) UpdateOne(_m *Proxy) *ProxyUpdateOne {
|
||||||
|
mutation := newProxyMutation(c.config, OpUpdateOne, withProxy(_m))
|
||||||
|
return &ProxyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateOneID returns an update builder for the given id.
|
||||||
|
func (c *ProxyClient) UpdateOneID(id int) *ProxyUpdateOne {
|
||||||
|
mutation := newProxyMutation(c.config, OpUpdateOne, withProxyID(id))
|
||||||
|
return &ProxyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete returns a delete builder for Proxy.
|
||||||
|
func (c *ProxyClient) Delete() *ProxyDelete {
|
||||||
|
mutation := newProxyMutation(c.config, OpDelete)
|
||||||
|
return &ProxyDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteOne returns a builder for deleting the given entity.
|
||||||
|
func (c *ProxyClient) DeleteOne(_m *Proxy) *ProxyDeleteOne {
|
||||||
|
return c.DeleteOneID(_m.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||||
|
func (c *ProxyClient) DeleteOneID(id int) *ProxyDeleteOne {
|
||||||
|
builder := c.Delete().Where(proxy.ID(id))
|
||||||
|
builder.mutation.id = &id
|
||||||
|
builder.mutation.op = OpDeleteOne
|
||||||
|
return &ProxyDeleteOne{builder}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Query returns a query builder for Proxy.
|
||||||
|
func (c *ProxyClient) Query() *ProxyQuery {
|
||||||
|
return &ProxyQuery{
|
||||||
|
config: c.config,
|
||||||
|
ctx: &QueryContext{Type: TypeProxy},
|
||||||
|
inters: c.Interceptors(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get returns a Proxy entity by its id.
|
||||||
|
func (c *ProxyClient) Get(ctx context.Context, id int) (*Proxy, error) {
|
||||||
|
return c.Query().Where(proxy.ID(id)).Only(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetX is like Get, but panics if an error occurs.
|
||||||
|
func (c *ProxyClient) GetX(ctx context.Context, id int) *Proxy {
|
||||||
|
obj, err := c.Get(ctx, id)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return obj
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hooks returns the client hooks.
|
||||||
|
func (c *ProxyClient) Hooks() []Hook {
|
||||||
|
return c.hooks.Proxy
|
||||||
|
}
|
||||||
|
|
||||||
|
// Interceptors returns the client interceptors.
|
||||||
|
func (c *ProxyClient) Interceptors() []Interceptor {
|
||||||
|
return c.inters.Proxy
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ProxyClient) mutate(ctx context.Context, m *ProxyMutation) (Value, error) {
|
||||||
|
switch m.Op() {
|
||||||
|
case OpCreate:
|
||||||
|
return (&ProxyCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||||
|
case OpUpdate:
|
||||||
|
return (&ProxyUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||||
|
case OpUpdateOne:
|
||||||
|
return (&ProxyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||||
|
case OpDelete, OpDeleteOne:
|
||||||
|
return (&ProxyDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("ent: unknown Proxy mutation op: %q", m.Op())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServerConfigClient is a client for the ServerConfig schema.
|
||||||
|
type ServerConfigClient struct {
|
||||||
|
config
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewServerConfigClient returns a client for the ServerConfig from the given config.
|
||||||
|
func NewServerConfigClient(c config) *ServerConfigClient {
|
||||||
|
return &ServerConfigClient{config: c}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use adds a list of mutation hooks to the hooks stack.
|
||||||
|
// A call to `Use(f, g, h)` equals to `serverconfig.Hooks(f(g(h())))`.
|
||||||
|
func (c *ServerConfigClient) Use(hooks ...Hook) {
|
||||||
|
c.hooks.ServerConfig = append(c.hooks.ServerConfig, hooks...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||||
|
// A call to `Intercept(f, g, h)` equals to `serverconfig.Intercept(f(g(h())))`.
|
||||||
|
func (c *ServerConfigClient) Intercept(interceptors ...Interceptor) {
|
||||||
|
c.inters.ServerConfig = append(c.inters.ServerConfig, interceptors...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create returns a builder for creating a ServerConfig entity.
|
||||||
|
func (c *ServerConfigClient) Create() *ServerConfigCreate {
|
||||||
|
mutation := newServerConfigMutation(c.config, OpCreate)
|
||||||
|
return &ServerConfigCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateBulk returns a builder for creating a bulk of ServerConfig entities.
|
||||||
|
func (c *ServerConfigClient) CreateBulk(builders ...*ServerConfigCreate) *ServerConfigCreateBulk {
|
||||||
|
return &ServerConfigCreateBulk{config: c.config, builders: builders}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||||
|
// a builder and applies setFunc on it.
|
||||||
|
func (c *ServerConfigClient) MapCreateBulk(slice any, setFunc func(*ServerConfigCreate, int)) *ServerConfigCreateBulk {
|
||||||
|
rv := reflect.ValueOf(slice)
|
||||||
|
if rv.Kind() != reflect.Slice {
|
||||||
|
return &ServerConfigCreateBulk{err: fmt.Errorf("calling to ServerConfigClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||||
|
}
|
||||||
|
builders := make([]*ServerConfigCreate, rv.Len())
|
||||||
|
for i := 0; i < rv.Len(); i++ {
|
||||||
|
builders[i] = c.Create()
|
||||||
|
setFunc(builders[i], i)
|
||||||
|
}
|
||||||
|
return &ServerConfigCreateBulk{config: c.config, builders: builders}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update returns an update builder for ServerConfig.
|
||||||
|
func (c *ServerConfigClient) Update() *ServerConfigUpdate {
|
||||||
|
mutation := newServerConfigMutation(c.config, OpUpdate)
|
||||||
|
return &ServerConfigUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateOne returns an update builder for the given entity.
|
||||||
|
func (c *ServerConfigClient) UpdateOne(_m *ServerConfig) *ServerConfigUpdateOne {
|
||||||
|
mutation := newServerConfigMutation(c.config, OpUpdateOne, withServerConfig(_m))
|
||||||
|
return &ServerConfigUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateOneID returns an update builder for the given id.
|
||||||
|
func (c *ServerConfigClient) UpdateOneID(id int) *ServerConfigUpdateOne {
|
||||||
|
mutation := newServerConfigMutation(c.config, OpUpdateOne, withServerConfigID(id))
|
||||||
|
return &ServerConfigUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete returns a delete builder for ServerConfig.
|
||||||
|
func (c *ServerConfigClient) Delete() *ServerConfigDelete {
|
||||||
|
mutation := newServerConfigMutation(c.config, OpDelete)
|
||||||
|
return &ServerConfigDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteOne returns a builder for deleting the given entity.
|
||||||
|
func (c *ServerConfigClient) DeleteOne(_m *ServerConfig) *ServerConfigDeleteOne {
|
||||||
|
return c.DeleteOneID(_m.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||||
|
func (c *ServerConfigClient) DeleteOneID(id int) *ServerConfigDeleteOne {
|
||||||
|
builder := c.Delete().Where(serverconfig.ID(id))
|
||||||
|
builder.mutation.id = &id
|
||||||
|
builder.mutation.op = OpDeleteOne
|
||||||
|
return &ServerConfigDeleteOne{builder}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Query returns a query builder for ServerConfig.
|
||||||
|
func (c *ServerConfigClient) Query() *ServerConfigQuery {
|
||||||
|
return &ServerConfigQuery{
|
||||||
|
config: c.config,
|
||||||
|
ctx: &QueryContext{Type: TypeServerConfig},
|
||||||
|
inters: c.Interceptors(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get returns a ServerConfig entity by its id.
|
||||||
|
func (c *ServerConfigClient) Get(ctx context.Context, id int) (*ServerConfig, error) {
|
||||||
|
return c.Query().Where(serverconfig.ID(id)).Only(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetX is like Get, but panics if an error occurs.
|
||||||
|
func (c *ServerConfigClient) GetX(ctx context.Context, id int) *ServerConfig {
|
||||||
|
obj, err := c.Get(ctx, id)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return obj
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hooks returns the client hooks.
|
||||||
|
func (c *ServerConfigClient) Hooks() []Hook {
|
||||||
|
return c.hooks.ServerConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
// Interceptors returns the client interceptors.
|
||||||
|
func (c *ServerConfigClient) Interceptors() []Interceptor {
|
||||||
|
return c.inters.ServerConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ServerConfigClient) mutate(ctx context.Context, m *ServerConfigMutation) (Value, error) {
|
||||||
|
switch m.Op() {
|
||||||
|
case OpCreate:
|
||||||
|
return (&ServerConfigCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||||
|
case OpUpdate:
|
||||||
|
return (&ServerConfigUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||||
|
case OpUpdateOne:
|
||||||
|
return (&ServerConfigUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||||
|
case OpDelete, OpDeleteOne:
|
||||||
|
return (&ServerConfigDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("ent: unknown ServerConfig mutation op: %q", m.Op())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserClient is a client for the User schema.
|
||||||
|
type UserClient struct {
|
||||||
|
config
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewUserClient returns a client for the User from the given config.
|
||||||
|
func NewUserClient(c config) *UserClient {
|
||||||
|
return &UserClient{config: c}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use adds a list of mutation hooks to the hooks stack.
|
||||||
|
// A call to `Use(f, g, h)` equals to `user.Hooks(f(g(h())))`.
|
||||||
|
func (c *UserClient) Use(hooks ...Hook) {
|
||||||
|
c.hooks.User = append(c.hooks.User, hooks...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||||
|
// A call to `Intercept(f, g, h)` equals to `user.Intercept(f(g(h())))`.
|
||||||
|
func (c *UserClient) Intercept(interceptors ...Interceptor) {
|
||||||
|
c.inters.User = append(c.inters.User, interceptors...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create returns a builder for creating a User entity.
|
||||||
|
func (c *UserClient) Create() *UserCreate {
|
||||||
|
mutation := newUserMutation(c.config, OpCreate)
|
||||||
|
return &UserCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateBulk returns a builder for creating a bulk of User entities.
|
||||||
|
func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk {
|
||||||
|
return &UserCreateBulk{config: c.config, builders: builders}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||||
|
// a builder and applies setFunc on it.
|
||||||
|
func (c *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk {
|
||||||
|
rv := reflect.ValueOf(slice)
|
||||||
|
if rv.Kind() != reflect.Slice {
|
||||||
|
return &UserCreateBulk{err: fmt.Errorf("calling to UserClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||||
|
}
|
||||||
|
builders := make([]*UserCreate, rv.Len())
|
||||||
|
for i := 0; i < rv.Len(); i++ {
|
||||||
|
builders[i] = c.Create()
|
||||||
|
setFunc(builders[i], i)
|
||||||
|
}
|
||||||
|
return &UserCreateBulk{config: c.config, builders: builders}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update returns an update builder for User.
|
||||||
|
func (c *UserClient) Update() *UserUpdate {
|
||||||
|
mutation := newUserMutation(c.config, OpUpdate)
|
||||||
|
return &UserUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateOne returns an update builder for the given entity.
|
||||||
|
func (c *UserClient) UpdateOne(_m *User) *UserUpdateOne {
|
||||||
|
mutation := newUserMutation(c.config, OpUpdateOne, withUser(_m))
|
||||||
|
return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateOneID returns an update builder for the given id.
|
||||||
|
func (c *UserClient) UpdateOneID(id int) *UserUpdateOne {
|
||||||
|
mutation := newUserMutation(c.config, OpUpdateOne, withUserID(id))
|
||||||
|
return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete returns a delete builder for User.
|
||||||
|
func (c *UserClient) Delete() *UserDelete {
|
||||||
|
mutation := newUserMutation(c.config, OpDelete)
|
||||||
|
return &UserDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteOne returns a builder for deleting the given entity.
|
||||||
|
func (c *UserClient) DeleteOne(_m *User) *UserDeleteOne {
|
||||||
|
return c.DeleteOneID(_m.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||||
|
func (c *UserClient) DeleteOneID(id int) *UserDeleteOne {
|
||||||
|
builder := c.Delete().Where(user.ID(id))
|
||||||
|
builder.mutation.id = &id
|
||||||
|
builder.mutation.op = OpDeleteOne
|
||||||
|
return &UserDeleteOne{builder}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Query returns a query builder for User.
|
||||||
|
func (c *UserClient) Query() *UserQuery {
|
||||||
|
return &UserQuery{
|
||||||
|
config: c.config,
|
||||||
|
ctx: &QueryContext{Type: TypeUser},
|
||||||
|
inters: c.Interceptors(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get returns a User entity by its id.
|
||||||
|
func (c *UserClient) Get(ctx context.Context, id int) (*User, error) {
|
||||||
|
return c.Query().Where(user.ID(id)).Only(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetX is like Get, but panics if an error occurs.
|
||||||
|
func (c *UserClient) GetX(ctx context.Context, id int) *User {
|
||||||
|
obj, err := c.Get(ctx, id)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return obj
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hooks returns the client hooks.
|
||||||
|
func (c *UserClient) Hooks() []Hook {
|
||||||
|
return c.hooks.User
|
||||||
|
}
|
||||||
|
|
||||||
|
// Interceptors returns the client interceptors.
|
||||||
|
func (c *UserClient) Interceptors() []Interceptor {
|
||||||
|
return c.inters.User
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error) {
|
||||||
|
switch m.Op() {
|
||||||
|
case OpCreate:
|
||||||
|
return (&UserCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||||
|
case OpUpdate:
|
||||||
|
return (&UserUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||||
|
case OpUpdateOne:
|
||||||
|
return (&UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||||
|
case OpDelete, OpDeleteOne:
|
||||||
|
return (&UserDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("ent: unknown User mutation op: %q", m.Op())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// hooks and interceptors per client, for fast access.
|
||||||
|
type (
|
||||||
|
hooks struct {
|
||||||
|
FrpcClient, Proxy, ServerConfig, User []ent.Hook
|
||||||
|
}
|
||||||
|
inters struct {
|
||||||
|
FrpcClient, Proxy, ServerConfig, User []ent.Interceptor
|
||||||
|
}
|
||||||
|
)
|
||||||
@@ -0,0 +1,614 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"reflect"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/frpcclient"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/proxy"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/serverconfig"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ent aliases to avoid import conflicts in user's code.
|
||||||
|
type (
|
||||||
|
Op = ent.Op
|
||||||
|
Hook = ent.Hook
|
||||||
|
Value = ent.Value
|
||||||
|
Query = ent.Query
|
||||||
|
QueryContext = ent.QueryContext
|
||||||
|
Querier = ent.Querier
|
||||||
|
QuerierFunc = ent.QuerierFunc
|
||||||
|
Interceptor = ent.Interceptor
|
||||||
|
InterceptFunc = ent.InterceptFunc
|
||||||
|
Traverser = ent.Traverser
|
||||||
|
TraverseFunc = ent.TraverseFunc
|
||||||
|
Policy = ent.Policy
|
||||||
|
Mutator = ent.Mutator
|
||||||
|
Mutation = ent.Mutation
|
||||||
|
MutateFunc = ent.MutateFunc
|
||||||
|
)
|
||||||
|
|
||||||
|
type clientCtxKey struct{}
|
||||||
|
|
||||||
|
// FromContext returns a Client stored inside a context, or nil if there isn't one.
|
||||||
|
func FromContext(ctx context.Context) *Client {
|
||||||
|
c, _ := ctx.Value(clientCtxKey{}).(*Client)
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewContext returns a new context with the given Client attached.
|
||||||
|
func NewContext(parent context.Context, c *Client) context.Context {
|
||||||
|
return context.WithValue(parent, clientCtxKey{}, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
type txCtxKey struct{}
|
||||||
|
|
||||||
|
// TxFromContext returns a Tx stored inside a context, or nil if there isn't one.
|
||||||
|
func TxFromContext(ctx context.Context) *Tx {
|
||||||
|
tx, _ := ctx.Value(txCtxKey{}).(*Tx)
|
||||||
|
return tx
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewTxContext returns a new context with the given Tx attached.
|
||||||
|
func NewTxContext(parent context.Context, tx *Tx) context.Context {
|
||||||
|
return context.WithValue(parent, txCtxKey{}, tx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// OrderFunc applies an ordering on the sql selector.
|
||||||
|
// Deprecated: Use Asc/Desc functions or the package builders instead.
|
||||||
|
type OrderFunc func(*sql.Selector)
|
||||||
|
|
||||||
|
var (
|
||||||
|
initCheck sync.Once
|
||||||
|
columnCheck sql.ColumnCheck
|
||||||
|
)
|
||||||
|
|
||||||
|
// checkColumn checks if the column exists in the given table.
|
||||||
|
func checkColumn(t, c string) error {
|
||||||
|
initCheck.Do(func() {
|
||||||
|
columnCheck = sql.NewColumnCheck(map[string]func(string) bool{
|
||||||
|
frpcclient.Table: frpcclient.ValidColumn,
|
||||||
|
proxy.Table: proxy.ValidColumn,
|
||||||
|
serverconfig.Table: serverconfig.ValidColumn,
|
||||||
|
user.Table: user.ValidColumn,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return columnCheck(t, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Asc applies the given fields in ASC order.
|
||||||
|
func Asc(fields ...string) func(*sql.Selector) {
|
||||||
|
return func(s *sql.Selector) {
|
||||||
|
for _, f := range fields {
|
||||||
|
if err := checkColumn(s.TableName(), f); err != nil {
|
||||||
|
s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)})
|
||||||
|
}
|
||||||
|
s.OrderBy(sql.Asc(s.C(f)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Desc applies the given fields in DESC order.
|
||||||
|
func Desc(fields ...string) func(*sql.Selector) {
|
||||||
|
return func(s *sql.Selector) {
|
||||||
|
for _, f := range fields {
|
||||||
|
if err := checkColumn(s.TableName(), f); err != nil {
|
||||||
|
s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)})
|
||||||
|
}
|
||||||
|
s.OrderBy(sql.Desc(s.C(f)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// AggregateFunc applies an aggregation step on the group-by traversal/selector.
|
||||||
|
type AggregateFunc func(*sql.Selector) string
|
||||||
|
|
||||||
|
// As is a pseudo aggregation function for renaming another other functions with custom names. For example:
|
||||||
|
//
|
||||||
|
// GroupBy(field1, field2).
|
||||||
|
// Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")).
|
||||||
|
// Scan(ctx, &v)
|
||||||
|
func As(fn AggregateFunc, end string) AggregateFunc {
|
||||||
|
return func(s *sql.Selector) string {
|
||||||
|
return sql.As(fn(s), end)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Count applies the "count" aggregation function on each group.
|
||||||
|
func Count() AggregateFunc {
|
||||||
|
return func(s *sql.Selector) string {
|
||||||
|
return sql.Count("*")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Max applies the "max" aggregation function on the given field of each group.
|
||||||
|
func Max(field string) AggregateFunc {
|
||||||
|
return func(s *sql.Selector) string {
|
||||||
|
if err := checkColumn(s.TableName(), field); err != nil {
|
||||||
|
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return sql.Max(s.C(field))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mean applies the "mean" aggregation function on the given field of each group.
|
||||||
|
func Mean(field string) AggregateFunc {
|
||||||
|
return func(s *sql.Selector) string {
|
||||||
|
if err := checkColumn(s.TableName(), field); err != nil {
|
||||||
|
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return sql.Avg(s.C(field))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Min applies the "min" aggregation function on the given field of each group.
|
||||||
|
func Min(field string) AggregateFunc {
|
||||||
|
return func(s *sql.Selector) string {
|
||||||
|
if err := checkColumn(s.TableName(), field); err != nil {
|
||||||
|
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return sql.Min(s.C(field))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sum applies the "sum" aggregation function on the given field of each group.
|
||||||
|
func Sum(field string) AggregateFunc {
|
||||||
|
return func(s *sql.Selector) string {
|
||||||
|
if err := checkColumn(s.TableName(), field); err != nil {
|
||||||
|
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return sql.Sum(s.C(field))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidationError returns when validating a field or edge fails.
|
||||||
|
type ValidationError struct {
|
||||||
|
Name string // Field or edge name.
|
||||||
|
err error
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error implements the error interface.
|
||||||
|
func (e *ValidationError) Error() string {
|
||||||
|
return e.err.Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unwrap implements the errors.Wrapper interface.
|
||||||
|
func (e *ValidationError) Unwrap() error {
|
||||||
|
return e.err
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsValidationError returns a boolean indicating whether the error is a validation error.
|
||||||
|
func IsValidationError(err error) bool {
|
||||||
|
if err == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
var e *ValidationError
|
||||||
|
return errors.As(err, &e)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotFoundError returns when trying to fetch a specific entity and it was not found in the database.
|
||||||
|
type NotFoundError struct {
|
||||||
|
label string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error implements the error interface.
|
||||||
|
func (e *NotFoundError) Error() string {
|
||||||
|
return "ent: " + e.label + " not found"
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsNotFound returns a boolean indicating whether the error is a not found error.
|
||||||
|
func IsNotFound(err error) bool {
|
||||||
|
if err == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
var e *NotFoundError
|
||||||
|
return errors.As(err, &e)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MaskNotFound masks not found error.
|
||||||
|
func MaskNotFound(err error) error {
|
||||||
|
if IsNotFound(err) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotSingularError returns when trying to fetch a singular entity and more then one was found in the database.
|
||||||
|
type NotSingularError struct {
|
||||||
|
label string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error implements the error interface.
|
||||||
|
func (e *NotSingularError) Error() string {
|
||||||
|
return "ent: " + e.label + " not singular"
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsNotSingular returns a boolean indicating whether the error is a not singular error.
|
||||||
|
func IsNotSingular(err error) bool {
|
||||||
|
if err == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
var e *NotSingularError
|
||||||
|
return errors.As(err, &e)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotLoadedError returns when trying to get a node that was not loaded by the query.
|
||||||
|
type NotLoadedError struct {
|
||||||
|
edge string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error implements the error interface.
|
||||||
|
func (e *NotLoadedError) Error() string {
|
||||||
|
return "ent: " + e.edge + " edge was not loaded"
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsNotLoaded returns a boolean indicating whether the error is a not loaded error.
|
||||||
|
func IsNotLoaded(err error) bool {
|
||||||
|
if err == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
var e *NotLoadedError
|
||||||
|
return errors.As(err, &e)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConstraintError returns when trying to create/update one or more entities and
|
||||||
|
// one or more of their constraints failed. For example, violation of edge or
|
||||||
|
// field uniqueness.
|
||||||
|
type ConstraintError struct {
|
||||||
|
msg string
|
||||||
|
wrap error
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error implements the error interface.
|
||||||
|
func (e ConstraintError) Error() string {
|
||||||
|
return "ent: constraint failed: " + e.msg
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unwrap implements the errors.Wrapper interface.
|
||||||
|
func (e *ConstraintError) Unwrap() error {
|
||||||
|
return e.wrap
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsConstraintError returns a boolean indicating whether the error is a constraint failure.
|
||||||
|
func IsConstraintError(err error) bool {
|
||||||
|
if err == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
var e *ConstraintError
|
||||||
|
return errors.As(err, &e)
|
||||||
|
}
|
||||||
|
|
||||||
|
// selector embedded by the different Select/GroupBy builders.
|
||||||
|
type selector struct {
|
||||||
|
label string
|
||||||
|
flds *[]string
|
||||||
|
fns []AggregateFunc
|
||||||
|
scan func(context.Context, any) error
|
||||||
|
}
|
||||||
|
|
||||||
|
// ScanX is like Scan, but panics if an error occurs.
|
||||||
|
func (s *selector) ScanX(ctx context.Context, v any) {
|
||||||
|
if err := s.scan(ctx, v); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
|
||||||
|
func (s *selector) Strings(ctx context.Context) ([]string, error) {
|
||||||
|
if len(*s.flds) > 1 {
|
||||||
|
return nil, errors.New("ent: Strings is not achievable when selecting more than 1 field")
|
||||||
|
}
|
||||||
|
var v []string
|
||||||
|
if err := s.scan(ctx, &v); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return v, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// StringsX is like Strings, but panics if an error occurs.
|
||||||
|
func (s *selector) StringsX(ctx context.Context) []string {
|
||||||
|
v, err := s.Strings(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// String returns a single string from a selector. It is only allowed when selecting one field.
|
||||||
|
func (s *selector) String(ctx context.Context) (_ string, err error) {
|
||||||
|
var v []string
|
||||||
|
if v, err = s.Strings(ctx); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch len(v) {
|
||||||
|
case 1:
|
||||||
|
return v[0], nil
|
||||||
|
case 0:
|
||||||
|
err = &NotFoundError{s.label}
|
||||||
|
default:
|
||||||
|
err = fmt.Errorf("ent: Strings returned %d results when one was expected", len(v))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// StringX is like String, but panics if an error occurs.
|
||||||
|
func (s *selector) StringX(ctx context.Context) string {
|
||||||
|
v, err := s.String(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ints returns list of ints from a selector. It is only allowed when selecting one field.
|
||||||
|
func (s *selector) Ints(ctx context.Context) ([]int, error) {
|
||||||
|
if len(*s.flds) > 1 {
|
||||||
|
return nil, errors.New("ent: Ints is not achievable when selecting more than 1 field")
|
||||||
|
}
|
||||||
|
var v []int
|
||||||
|
if err := s.scan(ctx, &v); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return v, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IntsX is like Ints, but panics if an error occurs.
|
||||||
|
func (s *selector) IntsX(ctx context.Context) []int {
|
||||||
|
v, err := s.Ints(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Int returns a single int from a selector. It is only allowed when selecting one field.
|
||||||
|
func (s *selector) Int(ctx context.Context) (_ int, err error) {
|
||||||
|
var v []int
|
||||||
|
if v, err = s.Ints(ctx); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch len(v) {
|
||||||
|
case 1:
|
||||||
|
return v[0], nil
|
||||||
|
case 0:
|
||||||
|
err = &NotFoundError{s.label}
|
||||||
|
default:
|
||||||
|
err = fmt.Errorf("ent: Ints returned %d results when one was expected", len(v))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// IntX is like Int, but panics if an error occurs.
|
||||||
|
func (s *selector) IntX(ctx context.Context) int {
|
||||||
|
v, err := s.Int(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
|
||||||
|
func (s *selector) Float64s(ctx context.Context) ([]float64, error) {
|
||||||
|
if len(*s.flds) > 1 {
|
||||||
|
return nil, errors.New("ent: Float64s is not achievable when selecting more than 1 field")
|
||||||
|
}
|
||||||
|
var v []float64
|
||||||
|
if err := s.scan(ctx, &v); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return v, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Float64sX is like Float64s, but panics if an error occurs.
|
||||||
|
func (s *selector) Float64sX(ctx context.Context) []float64 {
|
||||||
|
v, err := s.Float64s(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
|
||||||
|
func (s *selector) Float64(ctx context.Context) (_ float64, err error) {
|
||||||
|
var v []float64
|
||||||
|
if v, err = s.Float64s(ctx); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch len(v) {
|
||||||
|
case 1:
|
||||||
|
return v[0], nil
|
||||||
|
case 0:
|
||||||
|
err = &NotFoundError{s.label}
|
||||||
|
default:
|
||||||
|
err = fmt.Errorf("ent: Float64s returned %d results when one was expected", len(v))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Float64X is like Float64, but panics if an error occurs.
|
||||||
|
func (s *selector) Float64X(ctx context.Context) float64 {
|
||||||
|
v, err := s.Float64(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bools returns list of bools from a selector. It is only allowed when selecting one field.
|
||||||
|
func (s *selector) Bools(ctx context.Context) ([]bool, error) {
|
||||||
|
if len(*s.flds) > 1 {
|
||||||
|
return nil, errors.New("ent: Bools is not achievable when selecting more than 1 field")
|
||||||
|
}
|
||||||
|
var v []bool
|
||||||
|
if err := s.scan(ctx, &v); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return v, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// BoolsX is like Bools, but panics if an error occurs.
|
||||||
|
func (s *selector) BoolsX(ctx context.Context) []bool {
|
||||||
|
v, err := s.Bools(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bool returns a single bool from a selector. It is only allowed when selecting one field.
|
||||||
|
func (s *selector) Bool(ctx context.Context) (_ bool, err error) {
|
||||||
|
var v []bool
|
||||||
|
if v, err = s.Bools(ctx); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch len(v) {
|
||||||
|
case 1:
|
||||||
|
return v[0], nil
|
||||||
|
case 0:
|
||||||
|
err = &NotFoundError{s.label}
|
||||||
|
default:
|
||||||
|
err = fmt.Errorf("ent: Bools returned %d results when one was expected", len(v))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// BoolX is like Bool, but panics if an error occurs.
|
||||||
|
func (s *selector) BoolX(ctx context.Context) bool {
|
||||||
|
v, err := s.Bool(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// withHooks invokes the builder operation with the given hooks, if any.
|
||||||
|
func withHooks[V Value, M any, PM interface {
|
||||||
|
*M
|
||||||
|
Mutation
|
||||||
|
}](ctx context.Context, exec func(context.Context) (V, error), mutation PM, hooks []Hook) (value V, err error) {
|
||||||
|
if len(hooks) == 0 {
|
||||||
|
return exec(ctx)
|
||||||
|
}
|
||||||
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||||
|
mutationT, ok := any(m).(PM)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||||
|
}
|
||||||
|
// Set the mutation to the builder.
|
||||||
|
*mutation = *mutationT
|
||||||
|
return exec(ctx)
|
||||||
|
})
|
||||||
|
for i := len(hooks) - 1; i >= 0; i-- {
|
||||||
|
if hooks[i] == nil {
|
||||||
|
return value, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
||||||
|
}
|
||||||
|
mut = hooks[i](mut)
|
||||||
|
}
|
||||||
|
v, err := mut.Mutate(ctx, mutation)
|
||||||
|
if err != nil {
|
||||||
|
return value, err
|
||||||
|
}
|
||||||
|
nv, ok := v.(V)
|
||||||
|
if !ok {
|
||||||
|
return value, fmt.Errorf("unexpected node type %T returned from %T", v, mutation)
|
||||||
|
}
|
||||||
|
return nv, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// setContextOp returns a new context with the given QueryContext attached (including its op) in case it does not exist.
|
||||||
|
func setContextOp(ctx context.Context, qc *QueryContext, op string) context.Context {
|
||||||
|
if ent.QueryFromContext(ctx) == nil {
|
||||||
|
qc.Op = op
|
||||||
|
ctx = ent.NewQueryContext(ctx, qc)
|
||||||
|
}
|
||||||
|
return ctx
|
||||||
|
}
|
||||||
|
|
||||||
|
func querierAll[V Value, Q interface {
|
||||||
|
sqlAll(context.Context, ...queryHook) (V, error)
|
||||||
|
}]() Querier {
|
||||||
|
return QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
|
||||||
|
query, ok := q.(Q)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected query type %T", q)
|
||||||
|
}
|
||||||
|
return query.sqlAll(ctx)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func querierCount[Q interface {
|
||||||
|
sqlCount(context.Context) (int, error)
|
||||||
|
}]() Querier {
|
||||||
|
return QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
|
||||||
|
query, ok := q.(Q)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected query type %T", q)
|
||||||
|
}
|
||||||
|
return query.sqlCount(ctx)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func withInterceptors[V Value](ctx context.Context, q Query, qr Querier, inters []Interceptor) (v V, err error) {
|
||||||
|
for i := len(inters) - 1; i >= 0; i-- {
|
||||||
|
qr = inters[i].Intercept(qr)
|
||||||
|
}
|
||||||
|
rv, err := qr.Query(ctx, q)
|
||||||
|
if err != nil {
|
||||||
|
return v, err
|
||||||
|
}
|
||||||
|
vt, ok := rv.(V)
|
||||||
|
if !ok {
|
||||||
|
return v, fmt.Errorf("unexpected type %T returned from %T. expected type: %T", vt, q, v)
|
||||||
|
}
|
||||||
|
return vt, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func scanWithInterceptors[Q1 ent.Query, Q2 interface {
|
||||||
|
sqlScan(context.Context, Q1, any) error
|
||||||
|
}](ctx context.Context, rootQuery Q1, selectOrGroup Q2, inters []Interceptor, v any) error {
|
||||||
|
rv := reflect.ValueOf(v)
|
||||||
|
var qr Querier = QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
|
||||||
|
query, ok := q.(Q1)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected query type %T", q)
|
||||||
|
}
|
||||||
|
if err := selectOrGroup.sqlScan(ctx, query, v); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if k := rv.Kind(); k == reflect.Pointer && rv.Elem().CanInterface() {
|
||||||
|
return rv.Elem().Interface(), nil
|
||||||
|
}
|
||||||
|
return v, nil
|
||||||
|
})
|
||||||
|
for i := len(inters) - 1; i >= 0; i-- {
|
||||||
|
qr = inters[i].Intercept(qr)
|
||||||
|
}
|
||||||
|
vv, err := qr.Query(ctx, rootQuery)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
switch rv2 := reflect.ValueOf(vv); {
|
||||||
|
case rv.IsNil(), rv2.IsNil(), rv.Kind() != reflect.Pointer:
|
||||||
|
case rv.Type() == rv2.Type():
|
||||||
|
rv.Elem().Set(rv2.Elem())
|
||||||
|
case rv.Elem().Type() == rv2.Type():
|
||||||
|
rv.Elem().Set(rv2)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// queryHook describes an internal hook for the different sqlAll methods.
|
||||||
|
type queryHook func(context.Context, *sqlgraph.QuerySpec)
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package enttest
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent"
|
||||||
|
// required by schema hooks.
|
||||||
|
_ "github.com/fatedier/frp/pkg/db/ent/runtime"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql/schema"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/migrate"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
// TestingT is the interface that is shared between
|
||||||
|
// testing.T and testing.B and used by enttest.
|
||||||
|
TestingT interface {
|
||||||
|
FailNow()
|
||||||
|
Error(...any)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Option configures client creation.
|
||||||
|
Option func(*options)
|
||||||
|
|
||||||
|
options struct {
|
||||||
|
opts []ent.Option
|
||||||
|
migrateOpts []schema.MigrateOption
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// WithOptions forwards options to client creation.
|
||||||
|
func WithOptions(opts ...ent.Option) Option {
|
||||||
|
return func(o *options) {
|
||||||
|
o.opts = append(o.opts, opts...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithMigrateOptions forwards options to auto migration.
|
||||||
|
func WithMigrateOptions(opts ...schema.MigrateOption) Option {
|
||||||
|
return func(o *options) {
|
||||||
|
o.migrateOpts = append(o.migrateOpts, opts...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newOptions(opts []Option) *options {
|
||||||
|
o := &options{}
|
||||||
|
for _, opt := range opts {
|
||||||
|
opt(o)
|
||||||
|
}
|
||||||
|
return o
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open calls ent.Open and auto-run migration.
|
||||||
|
func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Client {
|
||||||
|
o := newOptions(opts)
|
||||||
|
c, err := ent.Open(driverName, dataSourceName, o.opts...)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
migrateSchema(t, c, o)
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewClient calls ent.NewClient and auto-run migration.
|
||||||
|
func NewClient(t TestingT, opts ...Option) *ent.Client {
|
||||||
|
o := newOptions(opts)
|
||||||
|
c := ent.NewClient(o.opts...)
|
||||||
|
migrateSchema(t, c, o)
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
func migrateSchema(t TestingT, c *ent.Client, o *options) {
|
||||||
|
tables, err := schema.CopyTables(migrate.Tables)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
if err := migrate.Create(context.Background(), c.Schema, tables, o.migrateOpts...); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,194 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/frpcclient"
|
||||||
|
)
|
||||||
|
|
||||||
|
// FrpcClient is the model entity for the FrpcClient schema.
|
||||||
|
type FrpcClient struct {
|
||||||
|
config `json:"-"`
|
||||||
|
// ID of the ent.
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
// Name holds the value of the "name" field.
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
// Key holds the value of the "key" field.
|
||||||
|
Key string `json:"key,omitempty"`
|
||||||
|
// Addr holds the value of the "addr" field.
|
||||||
|
Addr string `json:"addr,omitempty"`
|
||||||
|
// Port holds the value of the "port" field.
|
||||||
|
Port int `json:"port,omitempty"`
|
||||||
|
// Status holds the value of the "status" field.
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
// Metadata holds the value of the "metadata" field.
|
||||||
|
Metadata string `json:"metadata,omitempty"`
|
||||||
|
// CreatedAt holds the value of the "created_at" field.
|
||||||
|
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||||
|
// UpdatedAt holds the value of the "updated_at" field.
|
||||||
|
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||||
|
// LastSeen holds the value of the "last_seen" field.
|
||||||
|
LastSeen time.Time `json:"last_seen,omitempty"`
|
||||||
|
selectValues sql.SelectValues
|
||||||
|
}
|
||||||
|
|
||||||
|
// scanValues returns the types for scanning values from sql.Rows.
|
||||||
|
func (*FrpcClient) scanValues(columns []string) ([]any, error) {
|
||||||
|
values := make([]any, len(columns))
|
||||||
|
for i := range columns {
|
||||||
|
switch columns[i] {
|
||||||
|
case frpcclient.FieldID, frpcclient.FieldPort:
|
||||||
|
values[i] = new(sql.NullInt64)
|
||||||
|
case frpcclient.FieldName, frpcclient.FieldKey, frpcclient.FieldAddr, frpcclient.FieldStatus, frpcclient.FieldMetadata:
|
||||||
|
values[i] = new(sql.NullString)
|
||||||
|
case frpcclient.FieldCreatedAt, frpcclient.FieldUpdatedAt, frpcclient.FieldLastSeen:
|
||||||
|
values[i] = new(sql.NullTime)
|
||||||
|
default:
|
||||||
|
values[i] = new(sql.UnknownType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return values, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||||
|
// to the FrpcClient fields.
|
||||||
|
func (_m *FrpcClient) assignValues(columns []string, values []any) error {
|
||||||
|
if m, n := len(values), len(columns); m < n {
|
||||||
|
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||||
|
}
|
||||||
|
for i := range columns {
|
||||||
|
switch columns[i] {
|
||||||
|
case frpcclient.FieldID:
|
||||||
|
value, ok := values[i].(*sql.NullInt64)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field id", value)
|
||||||
|
}
|
||||||
|
_m.ID = int(value.Int64)
|
||||||
|
case frpcclient.FieldName:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.Name = value.String
|
||||||
|
}
|
||||||
|
case frpcclient.FieldKey:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field key", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.Key = value.String
|
||||||
|
}
|
||||||
|
case frpcclient.FieldAddr:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field addr", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.Addr = value.String
|
||||||
|
}
|
||||||
|
case frpcclient.FieldPort:
|
||||||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field port", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.Port = int(value.Int64)
|
||||||
|
}
|
||||||
|
case frpcclient.FieldStatus:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field status", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.Status = value.String
|
||||||
|
}
|
||||||
|
case frpcclient.FieldMetadata:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field metadata", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.Metadata = value.String
|
||||||
|
}
|
||||||
|
case frpcclient.FieldCreatedAt:
|
||||||
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.CreatedAt = value.Time
|
||||||
|
}
|
||||||
|
case frpcclient.FieldUpdatedAt:
|
||||||
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.UpdatedAt = value.Time
|
||||||
|
}
|
||||||
|
case frpcclient.FieldLastSeen:
|
||||||
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field last_seen", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.LastSeen = value.Time
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
_m.selectValues.Set(columns[i], values[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value returns the ent.Value that was dynamically selected and assigned to the FrpcClient.
|
||||||
|
// This includes values selected through modifiers, order, etc.
|
||||||
|
func (_m *FrpcClient) Value(name string) (ent.Value, error) {
|
||||||
|
return _m.selectValues.Get(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update returns a builder for updating this FrpcClient.
|
||||||
|
// Note that you need to call FrpcClient.Unwrap() before calling this method if this FrpcClient
|
||||||
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||||
|
func (_m *FrpcClient) Update() *FrpcClientUpdateOne {
|
||||||
|
return NewFrpcClientClient(_m.config).UpdateOne(_m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unwrap unwraps the FrpcClient entity that was returned from a transaction after it was closed,
|
||||||
|
// so that all future queries will be executed through the driver which created the transaction.
|
||||||
|
func (_m *FrpcClient) Unwrap() *FrpcClient {
|
||||||
|
_tx, ok := _m.config.driver.(*txDriver)
|
||||||
|
if !ok {
|
||||||
|
panic("ent: FrpcClient is not a transactional entity")
|
||||||
|
}
|
||||||
|
_m.config.driver = _tx.drv
|
||||||
|
return _m
|
||||||
|
}
|
||||||
|
|
||||||
|
// String implements the fmt.Stringer.
|
||||||
|
func (_m *FrpcClient) String() string {
|
||||||
|
var builder strings.Builder
|
||||||
|
builder.WriteString("FrpcClient(")
|
||||||
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||||
|
builder.WriteString("name=")
|
||||||
|
builder.WriteString(_m.Name)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("key=")
|
||||||
|
builder.WriteString(_m.Key)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("addr=")
|
||||||
|
builder.WriteString(_m.Addr)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("port=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", _m.Port))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("status=")
|
||||||
|
builder.WriteString(_m.Status)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("metadata=")
|
||||||
|
builder.WriteString(_m.Metadata)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("created_at=")
|
||||||
|
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("updated_at=")
|
||||||
|
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("last_seen=")
|
||||||
|
builder.WriteString(_m.LastSeen.Format(time.ANSIC))
|
||||||
|
builder.WriteByte(')')
|
||||||
|
return builder.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// FrpcClients is a parsable slice of FrpcClient.
|
||||||
|
type FrpcClients []*FrpcClient
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package frpcclient
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Label holds the string label denoting the frpcclient type in the database.
|
||||||
|
Label = "frpc_client"
|
||||||
|
// FieldID holds the string denoting the id field in the database.
|
||||||
|
FieldID = "id"
|
||||||
|
// FieldName holds the string denoting the name field in the database.
|
||||||
|
FieldName = "name"
|
||||||
|
// FieldKey holds the string denoting the key field in the database.
|
||||||
|
FieldKey = "key"
|
||||||
|
// FieldAddr holds the string denoting the addr field in the database.
|
||||||
|
FieldAddr = "addr"
|
||||||
|
// FieldPort holds the string denoting the port field in the database.
|
||||||
|
FieldPort = "port"
|
||||||
|
// FieldStatus holds the string denoting the status field in the database.
|
||||||
|
FieldStatus = "status"
|
||||||
|
// FieldMetadata holds the string denoting the metadata field in the database.
|
||||||
|
FieldMetadata = "metadata"
|
||||||
|
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||||
|
FieldCreatedAt = "created_at"
|
||||||
|
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||||
|
FieldUpdatedAt = "updated_at"
|
||||||
|
// FieldLastSeen holds the string denoting the last_seen field in the database.
|
||||||
|
FieldLastSeen = "last_seen"
|
||||||
|
// Table holds the table name of the frpcclient in the database.
|
||||||
|
Table = "frpc_clients"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Columns holds all SQL columns for frpcclient fields.
|
||||||
|
var Columns = []string{
|
||||||
|
FieldID,
|
||||||
|
FieldName,
|
||||||
|
FieldKey,
|
||||||
|
FieldAddr,
|
||||||
|
FieldPort,
|
||||||
|
FieldStatus,
|
||||||
|
FieldMetadata,
|
||||||
|
FieldCreatedAt,
|
||||||
|
FieldUpdatedAt,
|
||||||
|
FieldLastSeen,
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||||
|
func ValidColumn(column string) bool {
|
||||||
|
for i := range Columns {
|
||||||
|
if column == Columns[i] {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// DefaultKey holds the default value on creation for the "key" field.
|
||||||
|
DefaultKey string
|
||||||
|
// DefaultAddr holds the default value on creation for the "addr" field.
|
||||||
|
DefaultAddr string
|
||||||
|
// DefaultPort holds the default value on creation for the "port" field.
|
||||||
|
DefaultPort int
|
||||||
|
// DefaultStatus holds the default value on creation for the "status" field.
|
||||||
|
DefaultStatus string
|
||||||
|
// DefaultMetadata holds the default value on creation for the "metadata" field.
|
||||||
|
DefaultMetadata string
|
||||||
|
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||||
|
DefaultCreatedAt func() time.Time
|
||||||
|
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
||||||
|
DefaultUpdatedAt func() time.Time
|
||||||
|
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
|
||||||
|
UpdateDefaultUpdatedAt func() time.Time
|
||||||
|
// DefaultLastSeen holds the default value on creation for the "last_seen" field.
|
||||||
|
DefaultLastSeen func() time.Time
|
||||||
|
)
|
||||||
|
|
||||||
|
// OrderOption defines the ordering options for the FrpcClient queries.
|
||||||
|
type OrderOption func(*sql.Selector)
|
||||||
|
|
||||||
|
// ByID orders the results by the id field.
|
||||||
|
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByName orders the results by the name field.
|
||||||
|
func ByName(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldName, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByKey orders the results by the key field.
|
||||||
|
func ByKey(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldKey, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByAddr orders the results by the addr field.
|
||||||
|
func ByAddr(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldAddr, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByPort orders the results by the port field.
|
||||||
|
func ByPort(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldPort, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByStatus orders the results by the status field.
|
||||||
|
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldStatus, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByMetadata orders the results by the metadata field.
|
||||||
|
func ByMetadata(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldMetadata, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByCreatedAt orders the results by the created_at field.
|
||||||
|
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByUpdatedAt orders the results by the updated_at field.
|
||||||
|
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByLastSeen orders the results by the last_seen field.
|
||||||
|
func ByLastSeen(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldLastSeen, opts...).ToFunc()
|
||||||
|
}
|
||||||
@@ -0,0 +1,610 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package frpcclient
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/predicate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ID filters vertices based on their ID field.
|
||||||
|
func ID(id int) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDEQ applies the EQ predicate on the ID field.
|
||||||
|
func IDEQ(id int) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDNEQ applies the NEQ predicate on the ID field.
|
||||||
|
func IDNEQ(id int) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldNEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDIn applies the In predicate on the ID field.
|
||||||
|
func IDIn(ids ...int) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldIn(FieldID, ids...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDNotIn applies the NotIn predicate on the ID field.
|
||||||
|
func IDNotIn(ids ...int) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldNotIn(FieldID, ids...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDGT applies the GT predicate on the ID field.
|
||||||
|
func IDGT(id int) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldGT(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDGTE applies the GTE predicate on the ID field.
|
||||||
|
func IDGTE(id int) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldGTE(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDLT applies the LT predicate on the ID field.
|
||||||
|
func IDLT(id int) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldLT(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDLTE applies the LTE predicate on the ID field.
|
||||||
|
func IDLTE(id int) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldLTE(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
|
||||||
|
func Name(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldEQ(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Key applies equality check predicate on the "key" field. It's identical to KeyEQ.
|
||||||
|
func Key(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldEQ(FieldKey, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Addr applies equality check predicate on the "addr" field. It's identical to AddrEQ.
|
||||||
|
func Addr(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldEQ(FieldAddr, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Port applies equality check predicate on the "port" field. It's identical to PortEQ.
|
||||||
|
func Port(v int) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldEQ(FieldPort, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Status applies equality check predicate on the "status" field. It's identical to StatusEQ.
|
||||||
|
func Status(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldEQ(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Metadata applies equality check predicate on the "metadata" field. It's identical to MetadataEQ.
|
||||||
|
func Metadata(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldEQ(FieldMetadata, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||||
|
func CreatedAt(v time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldEQ(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
|
||||||
|
func UpdatedAt(v time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldEQ(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastSeen applies equality check predicate on the "last_seen" field. It's identical to LastSeenEQ.
|
||||||
|
func LastSeen(v time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldEQ(FieldLastSeen, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameEQ applies the EQ predicate on the "name" field.
|
||||||
|
func NameEQ(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldEQ(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameNEQ applies the NEQ predicate on the "name" field.
|
||||||
|
func NameNEQ(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldNEQ(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameIn applies the In predicate on the "name" field.
|
||||||
|
func NameIn(vs ...string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldIn(FieldName, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameNotIn applies the NotIn predicate on the "name" field.
|
||||||
|
func NameNotIn(vs ...string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldNotIn(FieldName, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameGT applies the GT predicate on the "name" field.
|
||||||
|
func NameGT(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldGT(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameGTE applies the GTE predicate on the "name" field.
|
||||||
|
func NameGTE(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldGTE(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameLT applies the LT predicate on the "name" field.
|
||||||
|
func NameLT(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldLT(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameLTE applies the LTE predicate on the "name" field.
|
||||||
|
func NameLTE(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldLTE(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameContains applies the Contains predicate on the "name" field.
|
||||||
|
func NameContains(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldContains(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
|
||||||
|
func NameHasPrefix(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldHasPrefix(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
|
||||||
|
func NameHasSuffix(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldHasSuffix(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameEqualFold applies the EqualFold predicate on the "name" field.
|
||||||
|
func NameEqualFold(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldEqualFold(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameContainsFold applies the ContainsFold predicate on the "name" field.
|
||||||
|
func NameContainsFold(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldContainsFold(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyEQ applies the EQ predicate on the "key" field.
|
||||||
|
func KeyEQ(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldEQ(FieldKey, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyNEQ applies the NEQ predicate on the "key" field.
|
||||||
|
func KeyNEQ(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldNEQ(FieldKey, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyIn applies the In predicate on the "key" field.
|
||||||
|
func KeyIn(vs ...string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldIn(FieldKey, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyNotIn applies the NotIn predicate on the "key" field.
|
||||||
|
func KeyNotIn(vs ...string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldNotIn(FieldKey, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyGT applies the GT predicate on the "key" field.
|
||||||
|
func KeyGT(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldGT(FieldKey, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyGTE applies the GTE predicate on the "key" field.
|
||||||
|
func KeyGTE(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldGTE(FieldKey, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyLT applies the LT predicate on the "key" field.
|
||||||
|
func KeyLT(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldLT(FieldKey, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyLTE applies the LTE predicate on the "key" field.
|
||||||
|
func KeyLTE(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldLTE(FieldKey, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyContains applies the Contains predicate on the "key" field.
|
||||||
|
func KeyContains(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldContains(FieldKey, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyHasPrefix applies the HasPrefix predicate on the "key" field.
|
||||||
|
func KeyHasPrefix(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldHasPrefix(FieldKey, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyHasSuffix applies the HasSuffix predicate on the "key" field.
|
||||||
|
func KeyHasSuffix(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldHasSuffix(FieldKey, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyEqualFold applies the EqualFold predicate on the "key" field.
|
||||||
|
func KeyEqualFold(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldEqualFold(FieldKey, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyContainsFold applies the ContainsFold predicate on the "key" field.
|
||||||
|
func KeyContainsFold(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldContainsFold(FieldKey, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddrEQ applies the EQ predicate on the "addr" field.
|
||||||
|
func AddrEQ(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldEQ(FieldAddr, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddrNEQ applies the NEQ predicate on the "addr" field.
|
||||||
|
func AddrNEQ(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldNEQ(FieldAddr, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddrIn applies the In predicate on the "addr" field.
|
||||||
|
func AddrIn(vs ...string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldIn(FieldAddr, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddrNotIn applies the NotIn predicate on the "addr" field.
|
||||||
|
func AddrNotIn(vs ...string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldNotIn(FieldAddr, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddrGT applies the GT predicate on the "addr" field.
|
||||||
|
func AddrGT(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldGT(FieldAddr, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddrGTE applies the GTE predicate on the "addr" field.
|
||||||
|
func AddrGTE(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldGTE(FieldAddr, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddrLT applies the LT predicate on the "addr" field.
|
||||||
|
func AddrLT(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldLT(FieldAddr, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddrLTE applies the LTE predicate on the "addr" field.
|
||||||
|
func AddrLTE(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldLTE(FieldAddr, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddrContains applies the Contains predicate on the "addr" field.
|
||||||
|
func AddrContains(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldContains(FieldAddr, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddrHasPrefix applies the HasPrefix predicate on the "addr" field.
|
||||||
|
func AddrHasPrefix(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldHasPrefix(FieldAddr, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddrHasSuffix applies the HasSuffix predicate on the "addr" field.
|
||||||
|
func AddrHasSuffix(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldHasSuffix(FieldAddr, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddrEqualFold applies the EqualFold predicate on the "addr" field.
|
||||||
|
func AddrEqualFold(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldEqualFold(FieldAddr, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddrContainsFold applies the ContainsFold predicate on the "addr" field.
|
||||||
|
func AddrContainsFold(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldContainsFold(FieldAddr, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PortEQ applies the EQ predicate on the "port" field.
|
||||||
|
func PortEQ(v int) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldEQ(FieldPort, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PortNEQ applies the NEQ predicate on the "port" field.
|
||||||
|
func PortNEQ(v int) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldNEQ(FieldPort, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PortIn applies the In predicate on the "port" field.
|
||||||
|
func PortIn(vs ...int) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldIn(FieldPort, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PortNotIn applies the NotIn predicate on the "port" field.
|
||||||
|
func PortNotIn(vs ...int) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldNotIn(FieldPort, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PortGT applies the GT predicate on the "port" field.
|
||||||
|
func PortGT(v int) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldGT(FieldPort, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PortGTE applies the GTE predicate on the "port" field.
|
||||||
|
func PortGTE(v int) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldGTE(FieldPort, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PortLT applies the LT predicate on the "port" field.
|
||||||
|
func PortLT(v int) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldLT(FieldPort, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PortLTE applies the LTE predicate on the "port" field.
|
||||||
|
func PortLTE(v int) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldLTE(FieldPort, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusEQ applies the EQ predicate on the "status" field.
|
||||||
|
func StatusEQ(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldEQ(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusNEQ applies the NEQ predicate on the "status" field.
|
||||||
|
func StatusNEQ(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldNEQ(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusIn applies the In predicate on the "status" field.
|
||||||
|
func StatusIn(vs ...string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldIn(FieldStatus, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusNotIn applies the NotIn predicate on the "status" field.
|
||||||
|
func StatusNotIn(vs ...string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldNotIn(FieldStatus, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusGT applies the GT predicate on the "status" field.
|
||||||
|
func StatusGT(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldGT(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusGTE applies the GTE predicate on the "status" field.
|
||||||
|
func StatusGTE(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldGTE(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusLT applies the LT predicate on the "status" field.
|
||||||
|
func StatusLT(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldLT(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusLTE applies the LTE predicate on the "status" field.
|
||||||
|
func StatusLTE(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldLTE(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusContains applies the Contains predicate on the "status" field.
|
||||||
|
func StatusContains(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldContains(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusHasPrefix applies the HasPrefix predicate on the "status" field.
|
||||||
|
func StatusHasPrefix(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldHasPrefix(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusHasSuffix applies the HasSuffix predicate on the "status" field.
|
||||||
|
func StatusHasSuffix(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldHasSuffix(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusEqualFold applies the EqualFold predicate on the "status" field.
|
||||||
|
func StatusEqualFold(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldEqualFold(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusContainsFold applies the ContainsFold predicate on the "status" field.
|
||||||
|
func StatusContainsFold(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldContainsFold(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataEQ applies the EQ predicate on the "metadata" field.
|
||||||
|
func MetadataEQ(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldEQ(FieldMetadata, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataNEQ applies the NEQ predicate on the "metadata" field.
|
||||||
|
func MetadataNEQ(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldNEQ(FieldMetadata, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataIn applies the In predicate on the "metadata" field.
|
||||||
|
func MetadataIn(vs ...string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldIn(FieldMetadata, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataNotIn applies the NotIn predicate on the "metadata" field.
|
||||||
|
func MetadataNotIn(vs ...string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldNotIn(FieldMetadata, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataGT applies the GT predicate on the "metadata" field.
|
||||||
|
func MetadataGT(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldGT(FieldMetadata, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataGTE applies the GTE predicate on the "metadata" field.
|
||||||
|
func MetadataGTE(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldGTE(FieldMetadata, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataLT applies the LT predicate on the "metadata" field.
|
||||||
|
func MetadataLT(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldLT(FieldMetadata, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataLTE applies the LTE predicate on the "metadata" field.
|
||||||
|
func MetadataLTE(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldLTE(FieldMetadata, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataContains applies the Contains predicate on the "metadata" field.
|
||||||
|
func MetadataContains(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldContains(FieldMetadata, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataHasPrefix applies the HasPrefix predicate on the "metadata" field.
|
||||||
|
func MetadataHasPrefix(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldHasPrefix(FieldMetadata, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataHasSuffix applies the HasSuffix predicate on the "metadata" field.
|
||||||
|
func MetadataHasSuffix(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldHasSuffix(FieldMetadata, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataEqualFold applies the EqualFold predicate on the "metadata" field.
|
||||||
|
func MetadataEqualFold(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldEqualFold(FieldMetadata, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataContainsFold applies the ContainsFold predicate on the "metadata" field.
|
||||||
|
func MetadataContainsFold(v string) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldContainsFold(FieldMetadata, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||||
|
func CreatedAtEQ(v time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldEQ(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
|
||||||
|
func CreatedAtNEQ(v time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldNEQ(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||||
|
func CreatedAtIn(vs ...time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldIn(FieldCreatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||||
|
func CreatedAtNotIn(vs ...time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldNotIn(FieldCreatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtGT applies the GT predicate on the "created_at" field.
|
||||||
|
func CreatedAtGT(v time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldGT(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
|
||||||
|
func CreatedAtGTE(v time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldGTE(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtLT applies the LT predicate on the "created_at" field.
|
||||||
|
func CreatedAtLT(v time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldLT(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
|
||||||
|
func CreatedAtLTE(v time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldLTE(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtEQ(v time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldEQ(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtNEQ(v time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldNEQ(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtIn(vs ...time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldIn(FieldUpdatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtNotIn(vs ...time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldNotIn(FieldUpdatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtGT(v time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldGT(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtGTE(v time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldGTE(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtLT(v time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldLT(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtLTE(v time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldLTE(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastSeenEQ applies the EQ predicate on the "last_seen" field.
|
||||||
|
func LastSeenEQ(v time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldEQ(FieldLastSeen, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastSeenNEQ applies the NEQ predicate on the "last_seen" field.
|
||||||
|
func LastSeenNEQ(v time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldNEQ(FieldLastSeen, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastSeenIn applies the In predicate on the "last_seen" field.
|
||||||
|
func LastSeenIn(vs ...time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldIn(FieldLastSeen, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastSeenNotIn applies the NotIn predicate on the "last_seen" field.
|
||||||
|
func LastSeenNotIn(vs ...time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldNotIn(FieldLastSeen, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastSeenGT applies the GT predicate on the "last_seen" field.
|
||||||
|
func LastSeenGT(v time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldGT(FieldLastSeen, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastSeenGTE applies the GTE predicate on the "last_seen" field.
|
||||||
|
func LastSeenGTE(v time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldGTE(FieldLastSeen, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastSeenLT applies the LT predicate on the "last_seen" field.
|
||||||
|
func LastSeenLT(v time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldLT(FieldLastSeen, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastSeenLTE applies the LTE predicate on the "last_seen" field.
|
||||||
|
func LastSeenLTE(v time.Time) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldLTE(FieldLastSeen, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastSeenIsNil applies the IsNil predicate on the "last_seen" field.
|
||||||
|
func LastSeenIsNil() predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldIsNull(FieldLastSeen))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastSeenNotNil applies the NotNil predicate on the "last_seen" field.
|
||||||
|
func LastSeenNotNil() predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.FieldNotNull(FieldLastSeen))
|
||||||
|
}
|
||||||
|
|
||||||
|
// And groups predicates with the AND operator between them.
|
||||||
|
func And(predicates ...predicate.FrpcClient) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.AndPredicates(predicates...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Or groups predicates with the OR operator between them.
|
||||||
|
func Or(predicates ...predicate.FrpcClient) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.OrPredicates(predicates...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not applies the not operator on the given predicate.
|
||||||
|
func Not(p predicate.FrpcClient) predicate.FrpcClient {
|
||||||
|
return predicate.FrpcClient(sql.NotPredicates(p))
|
||||||
|
}
|
||||||
@@ -0,0 +1,387 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/frpcclient"
|
||||||
|
)
|
||||||
|
|
||||||
|
// FrpcClientCreate is the builder for creating a FrpcClient entity.
|
||||||
|
type FrpcClientCreate struct {
|
||||||
|
config
|
||||||
|
mutation *FrpcClientMutation
|
||||||
|
hooks []Hook
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetName sets the "name" field.
|
||||||
|
func (_c *FrpcClientCreate) SetName(v string) *FrpcClientCreate {
|
||||||
|
_c.mutation.SetName(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetKey sets the "key" field.
|
||||||
|
func (_c *FrpcClientCreate) SetKey(v string) *FrpcClientCreate {
|
||||||
|
_c.mutation.SetKey(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableKey sets the "key" field if the given value is not nil.
|
||||||
|
func (_c *FrpcClientCreate) SetNillableKey(v *string) *FrpcClientCreate {
|
||||||
|
if v != nil {
|
||||||
|
_c.SetKey(*v)
|
||||||
|
}
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAddr sets the "addr" field.
|
||||||
|
func (_c *FrpcClientCreate) SetAddr(v string) *FrpcClientCreate {
|
||||||
|
_c.mutation.SetAddr(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableAddr sets the "addr" field if the given value is not nil.
|
||||||
|
func (_c *FrpcClientCreate) SetNillableAddr(v *string) *FrpcClientCreate {
|
||||||
|
if v != nil {
|
||||||
|
_c.SetAddr(*v)
|
||||||
|
}
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPort sets the "port" field.
|
||||||
|
func (_c *FrpcClientCreate) SetPort(v int) *FrpcClientCreate {
|
||||||
|
_c.mutation.SetPort(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillablePort sets the "port" field if the given value is not nil.
|
||||||
|
func (_c *FrpcClientCreate) SetNillablePort(v *int) *FrpcClientCreate {
|
||||||
|
if v != nil {
|
||||||
|
_c.SetPort(*v)
|
||||||
|
}
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetStatus sets the "status" field.
|
||||||
|
func (_c *FrpcClientCreate) SetStatus(v string) *FrpcClientCreate {
|
||||||
|
_c.mutation.SetStatus(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
||||||
|
func (_c *FrpcClientCreate) SetNillableStatus(v *string) *FrpcClientCreate {
|
||||||
|
if v != nil {
|
||||||
|
_c.SetStatus(*v)
|
||||||
|
}
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetMetadata sets the "metadata" field.
|
||||||
|
func (_c *FrpcClientCreate) SetMetadata(v string) *FrpcClientCreate {
|
||||||
|
_c.mutation.SetMetadata(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableMetadata sets the "metadata" field if the given value is not nil.
|
||||||
|
func (_c *FrpcClientCreate) SetNillableMetadata(v *string) *FrpcClientCreate {
|
||||||
|
if v != nil {
|
||||||
|
_c.SetMetadata(*v)
|
||||||
|
}
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCreatedAt sets the "created_at" field.
|
||||||
|
func (_c *FrpcClientCreate) SetCreatedAt(v time.Time) *FrpcClientCreate {
|
||||||
|
_c.mutation.SetCreatedAt(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||||
|
func (_c *FrpcClientCreate) SetNillableCreatedAt(v *time.Time) *FrpcClientCreate {
|
||||||
|
if v != nil {
|
||||||
|
_c.SetCreatedAt(*v)
|
||||||
|
}
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUpdatedAt sets the "updated_at" field.
|
||||||
|
func (_c *FrpcClientCreate) SetUpdatedAt(v time.Time) *FrpcClientCreate {
|
||||||
|
_c.mutation.SetUpdatedAt(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||||
|
func (_c *FrpcClientCreate) SetNillableUpdatedAt(v *time.Time) *FrpcClientCreate {
|
||||||
|
if v != nil {
|
||||||
|
_c.SetUpdatedAt(*v)
|
||||||
|
}
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetLastSeen sets the "last_seen" field.
|
||||||
|
func (_c *FrpcClientCreate) SetLastSeen(v time.Time) *FrpcClientCreate {
|
||||||
|
_c.mutation.SetLastSeen(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableLastSeen sets the "last_seen" field if the given value is not nil.
|
||||||
|
func (_c *FrpcClientCreate) SetNillableLastSeen(v *time.Time) *FrpcClientCreate {
|
||||||
|
if v != nil {
|
||||||
|
_c.SetLastSeen(*v)
|
||||||
|
}
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the FrpcClientMutation object of the builder.
|
||||||
|
func (_c *FrpcClientCreate) Mutation() *FrpcClientMutation {
|
||||||
|
return _c.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save creates the FrpcClient in the database.
|
||||||
|
func (_c *FrpcClientCreate) Save(ctx context.Context) (*FrpcClient, error) {
|
||||||
|
_c.defaults()
|
||||||
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX calls Save and panics if Save returns an error.
|
||||||
|
func (_c *FrpcClientCreate) SaveX(ctx context.Context) *FrpcClient {
|
||||||
|
v, err := _c.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (_c *FrpcClientCreate) Exec(ctx context.Context) error {
|
||||||
|
_, err := _c.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_c *FrpcClientCreate) ExecX(ctx context.Context) {
|
||||||
|
if err := _c.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// defaults sets the default values of the builder before save.
|
||||||
|
func (_c *FrpcClientCreate) defaults() {
|
||||||
|
if _, ok := _c.mutation.Key(); !ok {
|
||||||
|
v := frpcclient.DefaultKey
|
||||||
|
_c.mutation.SetKey(v)
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.Addr(); !ok {
|
||||||
|
v := frpcclient.DefaultAddr
|
||||||
|
_c.mutation.SetAddr(v)
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.Port(); !ok {
|
||||||
|
v := frpcclient.DefaultPort
|
||||||
|
_c.mutation.SetPort(v)
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.Status(); !ok {
|
||||||
|
v := frpcclient.DefaultStatus
|
||||||
|
_c.mutation.SetStatus(v)
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.Metadata(); !ok {
|
||||||
|
v := frpcclient.DefaultMetadata
|
||||||
|
_c.mutation.SetMetadata(v)
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||||
|
v := frpcclient.DefaultCreatedAt()
|
||||||
|
_c.mutation.SetCreatedAt(v)
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||||
|
v := frpcclient.DefaultUpdatedAt()
|
||||||
|
_c.mutation.SetUpdatedAt(v)
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.LastSeen(); !ok {
|
||||||
|
v := frpcclient.DefaultLastSeen()
|
||||||
|
_c.mutation.SetLastSeen(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check runs all checks and user-defined validators on the builder.
|
||||||
|
func (_c *FrpcClientCreate) check() error {
|
||||||
|
if _, ok := _c.mutation.Name(); !ok {
|
||||||
|
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "FrpcClient.name"`)}
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.Key(); !ok {
|
||||||
|
return &ValidationError{Name: "key", err: errors.New(`ent: missing required field "FrpcClient.key"`)}
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.Addr(); !ok {
|
||||||
|
return &ValidationError{Name: "addr", err: errors.New(`ent: missing required field "FrpcClient.addr"`)}
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.Port(); !ok {
|
||||||
|
return &ValidationError{Name: "port", err: errors.New(`ent: missing required field "FrpcClient.port"`)}
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.Status(); !ok {
|
||||||
|
return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "FrpcClient.status"`)}
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.Metadata(); !ok {
|
||||||
|
return &ValidationError{Name: "metadata", err: errors.New(`ent: missing required field "FrpcClient.metadata"`)}
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||||
|
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "FrpcClient.created_at"`)}
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||||
|
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "FrpcClient.updated_at"`)}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_c *FrpcClientCreate) sqlSave(ctx context.Context) (*FrpcClient, error) {
|
||||||
|
if err := _c.check(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_node, _spec := _c.createSpec()
|
||||||
|
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||||
|
if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
id := _spec.ID.Value.(int64)
|
||||||
|
_node.ID = int(id)
|
||||||
|
_c.mutation.id = &_node.ID
|
||||||
|
_c.mutation.done = true
|
||||||
|
return _node, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_c *FrpcClientCreate) createSpec() (*FrpcClient, *sqlgraph.CreateSpec) {
|
||||||
|
var (
|
||||||
|
_node = &FrpcClient{config: _c.config}
|
||||||
|
_spec = sqlgraph.NewCreateSpec(frpcclient.Table, sqlgraph.NewFieldSpec(frpcclient.FieldID, field.TypeInt))
|
||||||
|
)
|
||||||
|
if value, ok := _c.mutation.Name(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldName, field.TypeString, value)
|
||||||
|
_node.Name = value
|
||||||
|
}
|
||||||
|
if value, ok := _c.mutation.Key(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldKey, field.TypeString, value)
|
||||||
|
_node.Key = value
|
||||||
|
}
|
||||||
|
if value, ok := _c.mutation.Addr(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldAddr, field.TypeString, value)
|
||||||
|
_node.Addr = value
|
||||||
|
}
|
||||||
|
if value, ok := _c.mutation.Port(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldPort, field.TypeInt, value)
|
||||||
|
_node.Port = value
|
||||||
|
}
|
||||||
|
if value, ok := _c.mutation.Status(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldStatus, field.TypeString, value)
|
||||||
|
_node.Status = value
|
||||||
|
}
|
||||||
|
if value, ok := _c.mutation.Metadata(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldMetadata, field.TypeString, value)
|
||||||
|
_node.Metadata = value
|
||||||
|
}
|
||||||
|
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldCreatedAt, field.TypeTime, value)
|
||||||
|
_node.CreatedAt = value
|
||||||
|
}
|
||||||
|
if value, ok := _c.mutation.UpdatedAt(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldUpdatedAt, field.TypeTime, value)
|
||||||
|
_node.UpdatedAt = value
|
||||||
|
}
|
||||||
|
if value, ok := _c.mutation.LastSeen(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldLastSeen, field.TypeTime, value)
|
||||||
|
_node.LastSeen = value
|
||||||
|
}
|
||||||
|
return _node, _spec
|
||||||
|
}
|
||||||
|
|
||||||
|
// FrpcClientCreateBulk is the builder for creating many FrpcClient entities in bulk.
|
||||||
|
type FrpcClientCreateBulk struct {
|
||||||
|
config
|
||||||
|
err error
|
||||||
|
builders []*FrpcClientCreate
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save creates the FrpcClient entities in the database.
|
||||||
|
func (_c *FrpcClientCreateBulk) Save(ctx context.Context) ([]*FrpcClient, error) {
|
||||||
|
if _c.err != nil {
|
||||||
|
return nil, _c.err
|
||||||
|
}
|
||||||
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||||
|
nodes := make([]*FrpcClient, len(_c.builders))
|
||||||
|
mutators := make([]Mutator, len(_c.builders))
|
||||||
|
for i := range _c.builders {
|
||||||
|
func(i int, root context.Context) {
|
||||||
|
builder := _c.builders[i]
|
||||||
|
builder.defaults()
|
||||||
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||||
|
mutation, ok := m.(*FrpcClientMutation)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||||
|
}
|
||||||
|
if err := builder.check(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
builder.mutation = mutation
|
||||||
|
var err error
|
||||||
|
nodes[i], specs[i] = builder.createSpec()
|
||||||
|
if i < len(mutators)-1 {
|
||||||
|
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||||
|
} else {
|
||||||
|
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||||
|
// Invoke the actual operation on the latest mutation in the chain.
|
||||||
|
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||||
|
if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
mutation.id = &nodes[i].ID
|
||||||
|
if specs[i].ID.Value != nil {
|
||||||
|
id := specs[i].ID.Value.(int64)
|
||||||
|
nodes[i].ID = int(id)
|
||||||
|
}
|
||||||
|
mutation.done = true
|
||||||
|
return nodes[i], nil
|
||||||
|
})
|
||||||
|
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||||
|
mut = builder.hooks[i](mut)
|
||||||
|
}
|
||||||
|
mutators[i] = mut
|
||||||
|
}(i, ctx)
|
||||||
|
}
|
||||||
|
if len(mutators) > 0 {
|
||||||
|
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (_c *FrpcClientCreateBulk) SaveX(ctx context.Context) []*FrpcClient {
|
||||||
|
v, err := _c.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (_c *FrpcClientCreateBulk) Exec(ctx context.Context) error {
|
||||||
|
_, err := _c.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_c *FrpcClientCreateBulk) ExecX(ctx context.Context) {
|
||||||
|
if err := _c.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/frpcclient"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/predicate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// FrpcClientDelete is the builder for deleting a FrpcClient entity.
|
||||||
|
type FrpcClientDelete struct {
|
||||||
|
config
|
||||||
|
hooks []Hook
|
||||||
|
mutation *FrpcClientMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the FrpcClientDelete builder.
|
||||||
|
func (_d *FrpcClientDelete) Where(ps ...predicate.FrpcClient) *FrpcClientDelete {
|
||||||
|
_d.mutation.Where(ps...)
|
||||||
|
return _d
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||||
|
func (_d *FrpcClientDelete) Exec(ctx context.Context) (int, error) {
|
||||||
|
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_d *FrpcClientDelete) ExecX(ctx context.Context) int {
|
||||||
|
n, err := _d.Exec(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_d *FrpcClientDelete) sqlExec(ctx context.Context) (int, error) {
|
||||||
|
_spec := sqlgraph.NewDeleteSpec(frpcclient.Table, sqlgraph.NewFieldSpec(frpcclient.FieldID, field.TypeInt))
|
||||||
|
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||||
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
_d.mutation.done = true
|
||||||
|
return affected, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// FrpcClientDeleteOne is the builder for deleting a single FrpcClient entity.
|
||||||
|
type FrpcClientDeleteOne struct {
|
||||||
|
_d *FrpcClientDelete
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the FrpcClientDelete builder.
|
||||||
|
func (_d *FrpcClientDeleteOne) Where(ps ...predicate.FrpcClient) *FrpcClientDeleteOne {
|
||||||
|
_d._d.mutation.Where(ps...)
|
||||||
|
return _d
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query.
|
||||||
|
func (_d *FrpcClientDeleteOne) Exec(ctx context.Context) error {
|
||||||
|
n, err := _d._d.Exec(ctx)
|
||||||
|
switch {
|
||||||
|
case err != nil:
|
||||||
|
return err
|
||||||
|
case n == 0:
|
||||||
|
return &NotFoundError{frpcclient.Label}
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_d *FrpcClientDeleteOne) ExecX(ctx context.Context) {
|
||||||
|
if err := _d.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,527 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"math"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/frpcclient"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/predicate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// FrpcClientQuery is the builder for querying FrpcClient entities.
|
||||||
|
type FrpcClientQuery struct {
|
||||||
|
config
|
||||||
|
ctx *QueryContext
|
||||||
|
order []frpcclient.OrderOption
|
||||||
|
inters []Interceptor
|
||||||
|
predicates []predicate.FrpcClient
|
||||||
|
// intermediate query (i.e. traversal path).
|
||||||
|
sql *sql.Selector
|
||||||
|
path func(context.Context) (*sql.Selector, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where adds a new predicate for the FrpcClientQuery builder.
|
||||||
|
func (_q *FrpcClientQuery) Where(ps ...predicate.FrpcClient) *FrpcClientQuery {
|
||||||
|
_q.predicates = append(_q.predicates, ps...)
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// Limit the number of records to be returned by this query.
|
||||||
|
func (_q *FrpcClientQuery) Limit(limit int) *FrpcClientQuery {
|
||||||
|
_q.ctx.Limit = &limit
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// Offset to start from.
|
||||||
|
func (_q *FrpcClientQuery) Offset(offset int) *FrpcClientQuery {
|
||||||
|
_q.ctx.Offset = &offset
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unique configures the query builder to filter duplicate records on query.
|
||||||
|
// By default, unique is set to true, and can be disabled using this method.
|
||||||
|
func (_q *FrpcClientQuery) Unique(unique bool) *FrpcClientQuery {
|
||||||
|
_q.ctx.Unique = &unique
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// Order specifies how the records should be ordered.
|
||||||
|
func (_q *FrpcClientQuery) Order(o ...frpcclient.OrderOption) *FrpcClientQuery {
|
||||||
|
_q.order = append(_q.order, o...)
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// First returns the first FrpcClient entity from the query.
|
||||||
|
// Returns a *NotFoundError when no FrpcClient was found.
|
||||||
|
func (_q *FrpcClientQuery) First(ctx context.Context) (*FrpcClient, error) {
|
||||||
|
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return nil, &NotFoundError{frpcclient.Label}
|
||||||
|
}
|
||||||
|
return nodes[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstX is like First, but panics if an error occurs.
|
||||||
|
func (_q *FrpcClientQuery) FirstX(ctx context.Context) *FrpcClient {
|
||||||
|
node, err := _q.First(ctx)
|
||||||
|
if err != nil && !IsNotFound(err) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstID returns the first FrpcClient ID from the query.
|
||||||
|
// Returns a *NotFoundError when no FrpcClient ID was found.
|
||||||
|
func (_q *FrpcClientQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||||
|
var ids []int
|
||||||
|
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(ids) == 0 {
|
||||||
|
err = &NotFoundError{frpcclient.Label}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return ids[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||||
|
func (_q *FrpcClientQuery) FirstIDX(ctx context.Context) int {
|
||||||
|
id, err := _q.FirstID(ctx)
|
||||||
|
if err != nil && !IsNotFound(err) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only returns a single FrpcClient entity found by the query, ensuring it only returns one.
|
||||||
|
// Returns a *NotSingularError when more than one FrpcClient entity is found.
|
||||||
|
// Returns a *NotFoundError when no FrpcClient entities are found.
|
||||||
|
func (_q *FrpcClientQuery) Only(ctx context.Context) (*FrpcClient, error) {
|
||||||
|
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
switch len(nodes) {
|
||||||
|
case 1:
|
||||||
|
return nodes[0], nil
|
||||||
|
case 0:
|
||||||
|
return nil, &NotFoundError{frpcclient.Label}
|
||||||
|
default:
|
||||||
|
return nil, &NotSingularError{frpcclient.Label}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyX is like Only, but panics if an error occurs.
|
||||||
|
func (_q *FrpcClientQuery) OnlyX(ctx context.Context) *FrpcClient {
|
||||||
|
node, err := _q.Only(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyID is like Only, but returns the only FrpcClient ID in the query.
|
||||||
|
// Returns a *NotSingularError when more than one FrpcClient ID is found.
|
||||||
|
// Returns a *NotFoundError when no entities are found.
|
||||||
|
func (_q *FrpcClientQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||||
|
var ids []int
|
||||||
|
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch len(ids) {
|
||||||
|
case 1:
|
||||||
|
id = ids[0]
|
||||||
|
case 0:
|
||||||
|
err = &NotFoundError{frpcclient.Label}
|
||||||
|
default:
|
||||||
|
err = &NotSingularError{frpcclient.Label}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||||
|
func (_q *FrpcClientQuery) OnlyIDX(ctx context.Context) int {
|
||||||
|
id, err := _q.OnlyID(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// All executes the query and returns a list of FrpcClients.
|
||||||
|
func (_q *FrpcClientQuery) All(ctx context.Context) ([]*FrpcClient, error) {
|
||||||
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||||
|
if err := _q.prepareQuery(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
qr := querierAll[[]*FrpcClient, *FrpcClientQuery]()
|
||||||
|
return withInterceptors[[]*FrpcClient](ctx, _q, qr, _q.inters)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AllX is like All, but panics if an error occurs.
|
||||||
|
func (_q *FrpcClientQuery) AllX(ctx context.Context) []*FrpcClient {
|
||||||
|
nodes, err := _q.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return nodes
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs executes the query and returns a list of FrpcClient IDs.
|
||||||
|
func (_q *FrpcClientQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||||
|
if _q.ctx.Unique == nil && _q.path != nil {
|
||||||
|
_q.Unique(true)
|
||||||
|
}
|
||||||
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||||
|
if err = _q.Select(frpcclient.FieldID).Scan(ctx, &ids); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ids, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDsX is like IDs, but panics if an error occurs.
|
||||||
|
func (_q *FrpcClientQuery) IDsX(ctx context.Context) []int {
|
||||||
|
ids, err := _q.IDs(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return ids
|
||||||
|
}
|
||||||
|
|
||||||
|
// Count returns the count of the given query.
|
||||||
|
func (_q *FrpcClientQuery) Count(ctx context.Context) (int, error) {
|
||||||
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||||
|
if err := _q.prepareQuery(ctx); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return withInterceptors[int](ctx, _q, querierCount[*FrpcClientQuery](), _q.inters)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountX is like Count, but panics if an error occurs.
|
||||||
|
func (_q *FrpcClientQuery) CountX(ctx context.Context) int {
|
||||||
|
count, err := _q.Count(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exist returns true if the query has elements in the graph.
|
||||||
|
func (_q *FrpcClientQuery) Exist(ctx context.Context) (bool, error) {
|
||||||
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||||
|
switch _, err := _q.FirstID(ctx); {
|
||||||
|
case IsNotFound(err):
|
||||||
|
return false, nil
|
||||||
|
case err != nil:
|
||||||
|
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||||
|
default:
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExistX is like Exist, but panics if an error occurs.
|
||||||
|
func (_q *FrpcClientQuery) ExistX(ctx context.Context) bool {
|
||||||
|
exist, err := _q.Exist(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return exist
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clone returns a duplicate of the FrpcClientQuery builder, including all associated steps. It can be
|
||||||
|
// used to prepare common query builders and use them differently after the clone is made.
|
||||||
|
func (_q *FrpcClientQuery) Clone() *FrpcClientQuery {
|
||||||
|
if _q == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &FrpcClientQuery{
|
||||||
|
config: _q.config,
|
||||||
|
ctx: _q.ctx.Clone(),
|
||||||
|
order: append([]frpcclient.OrderOption{}, _q.order...),
|
||||||
|
inters: append([]Interceptor{}, _q.inters...),
|
||||||
|
predicates: append([]predicate.FrpcClient{}, _q.predicates...),
|
||||||
|
// clone intermediate query.
|
||||||
|
sql: _q.sql.Clone(),
|
||||||
|
path: _q.path,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GroupBy is used to group vertices by one or more fields/columns.
|
||||||
|
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
//
|
||||||
|
// var v []struct {
|
||||||
|
// Name string `json:"name,omitempty"`
|
||||||
|
// Count int `json:"count,omitempty"`
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// client.FrpcClient.Query().
|
||||||
|
// GroupBy(frpcclient.FieldName).
|
||||||
|
// Aggregate(ent.Count()).
|
||||||
|
// Scan(ctx, &v)
|
||||||
|
func (_q *FrpcClientQuery) GroupBy(field string, fields ...string) *FrpcClientGroupBy {
|
||||||
|
_q.ctx.Fields = append([]string{field}, fields...)
|
||||||
|
grbuild := &FrpcClientGroupBy{build: _q}
|
||||||
|
grbuild.flds = &_q.ctx.Fields
|
||||||
|
grbuild.label = frpcclient.Label
|
||||||
|
grbuild.scan = grbuild.Scan
|
||||||
|
return grbuild
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select allows the selection one or more fields/columns for the given query,
|
||||||
|
// instead of selecting all fields in the entity.
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
//
|
||||||
|
// var v []struct {
|
||||||
|
// Name string `json:"name,omitempty"`
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// client.FrpcClient.Query().
|
||||||
|
// Select(frpcclient.FieldName).
|
||||||
|
// Scan(ctx, &v)
|
||||||
|
func (_q *FrpcClientQuery) Select(fields ...string) *FrpcClientSelect {
|
||||||
|
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||||
|
sbuild := &FrpcClientSelect{FrpcClientQuery: _q}
|
||||||
|
sbuild.label = frpcclient.Label
|
||||||
|
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||||
|
return sbuild
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate returns a FrpcClientSelect configured with the given aggregations.
|
||||||
|
func (_q *FrpcClientQuery) Aggregate(fns ...AggregateFunc) *FrpcClientSelect {
|
||||||
|
return _q.Select().Aggregate(fns...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *FrpcClientQuery) prepareQuery(ctx context.Context) error {
|
||||||
|
for _, inter := range _q.inters {
|
||||||
|
if inter == nil {
|
||||||
|
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||||
|
}
|
||||||
|
if trv, ok := inter.(Traverser); ok {
|
||||||
|
if err := trv.Traverse(ctx, _q); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, f := range _q.ctx.Fields {
|
||||||
|
if !frpcclient.ValidColumn(f) {
|
||||||
|
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _q.path != nil {
|
||||||
|
prev, err := _q.path(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_q.sql = prev
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *FrpcClientQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*FrpcClient, error) {
|
||||||
|
var (
|
||||||
|
nodes = []*FrpcClient{}
|
||||||
|
_spec = _q.querySpec()
|
||||||
|
)
|
||||||
|
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||||
|
return (*FrpcClient).scanValues(nil, columns)
|
||||||
|
}
|
||||||
|
_spec.Assign = func(columns []string, values []any) error {
|
||||||
|
node := &FrpcClient{config: _q.config}
|
||||||
|
nodes = append(nodes, node)
|
||||||
|
return node.assignValues(columns, values)
|
||||||
|
}
|
||||||
|
for i := range hooks {
|
||||||
|
hooks[i](ctx, _spec)
|
||||||
|
}
|
||||||
|
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *FrpcClientQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
|
_spec := _q.querySpec()
|
||||||
|
_spec.Node.Columns = _q.ctx.Fields
|
||||||
|
if len(_q.ctx.Fields) > 0 {
|
||||||
|
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||||
|
}
|
||||||
|
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *FrpcClientQuery) querySpec() *sqlgraph.QuerySpec {
|
||||||
|
_spec := sqlgraph.NewQuerySpec(frpcclient.Table, frpcclient.Columns, sqlgraph.NewFieldSpec(frpcclient.FieldID, field.TypeInt))
|
||||||
|
_spec.From = _q.sql
|
||||||
|
if unique := _q.ctx.Unique; unique != nil {
|
||||||
|
_spec.Unique = *unique
|
||||||
|
} else if _q.path != nil {
|
||||||
|
_spec.Unique = true
|
||||||
|
}
|
||||||
|
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||||
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, frpcclient.FieldID)
|
||||||
|
for i := range fields {
|
||||||
|
if fields[i] != frpcclient.FieldID {
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ps := _q.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if limit := _q.ctx.Limit; limit != nil {
|
||||||
|
_spec.Limit = *limit
|
||||||
|
}
|
||||||
|
if offset := _q.ctx.Offset; offset != nil {
|
||||||
|
_spec.Offset = *offset
|
||||||
|
}
|
||||||
|
if ps := _q.order; len(ps) > 0 {
|
||||||
|
_spec.Order = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _spec
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *FrpcClientQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||||
|
builder := sql.Dialect(_q.driver.Dialect())
|
||||||
|
t1 := builder.Table(frpcclient.Table)
|
||||||
|
columns := _q.ctx.Fields
|
||||||
|
if len(columns) == 0 {
|
||||||
|
columns = frpcclient.Columns
|
||||||
|
}
|
||||||
|
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||||
|
if _q.sql != nil {
|
||||||
|
selector = _q.sql
|
||||||
|
selector.Select(selector.Columns(columns...)...)
|
||||||
|
}
|
||||||
|
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||||
|
selector.Distinct()
|
||||||
|
}
|
||||||
|
for _, p := range _q.predicates {
|
||||||
|
p(selector)
|
||||||
|
}
|
||||||
|
for _, p := range _q.order {
|
||||||
|
p(selector)
|
||||||
|
}
|
||||||
|
if offset := _q.ctx.Offset; offset != nil {
|
||||||
|
// limit is mandatory for offset clause. We start
|
||||||
|
// with default value, and override it below if needed.
|
||||||
|
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||||
|
}
|
||||||
|
if limit := _q.ctx.Limit; limit != nil {
|
||||||
|
selector.Limit(*limit)
|
||||||
|
}
|
||||||
|
return selector
|
||||||
|
}
|
||||||
|
|
||||||
|
// FrpcClientGroupBy is the group-by builder for FrpcClient entities.
|
||||||
|
type FrpcClientGroupBy struct {
|
||||||
|
selector
|
||||||
|
build *FrpcClientQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the group-by query.
|
||||||
|
func (_g *FrpcClientGroupBy) Aggregate(fns ...AggregateFunc) *FrpcClientGroupBy {
|
||||||
|
_g.fns = append(_g.fns, fns...)
|
||||||
|
return _g
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (_g *FrpcClientGroupBy) Scan(ctx context.Context, v any) error {
|
||||||
|
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||||
|
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return scanWithInterceptors[*FrpcClientQuery, *FrpcClientGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_g *FrpcClientGroupBy) sqlScan(ctx context.Context, root *FrpcClientQuery, v any) error {
|
||||||
|
selector := root.sqlQuery(ctx).Select()
|
||||||
|
aggregation := make([]string, 0, len(_g.fns))
|
||||||
|
for _, fn := range _g.fns {
|
||||||
|
aggregation = append(aggregation, fn(selector))
|
||||||
|
}
|
||||||
|
if len(selector.SelectedColumns()) == 0 {
|
||||||
|
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||||
|
for _, f := range *_g.flds {
|
||||||
|
columns = append(columns, selector.C(f))
|
||||||
|
}
|
||||||
|
columns = append(columns, aggregation...)
|
||||||
|
selector.Select(columns...)
|
||||||
|
}
|
||||||
|
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||||
|
if err := selector.Err(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
rows := &sql.Rows{}
|
||||||
|
query, args := selector.Query()
|
||||||
|
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
return sql.ScanSlice(rows, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FrpcClientSelect is the builder for selecting fields of FrpcClient entities.
|
||||||
|
type FrpcClientSelect struct {
|
||||||
|
*FrpcClientQuery
|
||||||
|
selector
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the selector query.
|
||||||
|
func (_s *FrpcClientSelect) Aggregate(fns ...AggregateFunc) *FrpcClientSelect {
|
||||||
|
_s.fns = append(_s.fns, fns...)
|
||||||
|
return _s
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (_s *FrpcClientSelect) Scan(ctx context.Context, v any) error {
|
||||||
|
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||||
|
if err := _s.prepareQuery(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return scanWithInterceptors[*FrpcClientQuery, *FrpcClientSelect](ctx, _s.FrpcClientQuery, _s, _s.inters, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_s *FrpcClientSelect) sqlScan(ctx context.Context, root *FrpcClientQuery, v any) error {
|
||||||
|
selector := root.sqlQuery(ctx)
|
||||||
|
aggregation := make([]string, 0, len(_s.fns))
|
||||||
|
for _, fn := range _s.fns {
|
||||||
|
aggregation = append(aggregation, fn(selector))
|
||||||
|
}
|
||||||
|
switch n := len(*_s.selector.flds); {
|
||||||
|
case n == 0 && len(aggregation) > 0:
|
||||||
|
selector.Select(aggregation...)
|
||||||
|
case n != 0 && len(aggregation) > 0:
|
||||||
|
selector.AppendSelect(aggregation...)
|
||||||
|
}
|
||||||
|
rows := &sql.Rows{}
|
||||||
|
query, args := selector.Query()
|
||||||
|
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
return sql.ScanSlice(rows, v)
|
||||||
|
}
|
||||||
@@ -0,0 +1,522 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/frpcclient"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/predicate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// FrpcClientUpdate is the builder for updating FrpcClient entities.
|
||||||
|
type FrpcClientUpdate struct {
|
||||||
|
config
|
||||||
|
hooks []Hook
|
||||||
|
mutation *FrpcClientMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the FrpcClientUpdate builder.
|
||||||
|
func (_u *FrpcClientUpdate) Where(ps ...predicate.FrpcClient) *FrpcClientUpdate {
|
||||||
|
_u.mutation.Where(ps...)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetName sets the "name" field.
|
||||||
|
func (_u *FrpcClientUpdate) SetName(v string) *FrpcClientUpdate {
|
||||||
|
_u.mutation.SetName(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableName sets the "name" field if the given value is not nil.
|
||||||
|
func (_u *FrpcClientUpdate) SetNillableName(v *string) *FrpcClientUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetName(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetKey sets the "key" field.
|
||||||
|
func (_u *FrpcClientUpdate) SetKey(v string) *FrpcClientUpdate {
|
||||||
|
_u.mutation.SetKey(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableKey sets the "key" field if the given value is not nil.
|
||||||
|
func (_u *FrpcClientUpdate) SetNillableKey(v *string) *FrpcClientUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetKey(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAddr sets the "addr" field.
|
||||||
|
func (_u *FrpcClientUpdate) SetAddr(v string) *FrpcClientUpdate {
|
||||||
|
_u.mutation.SetAddr(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableAddr sets the "addr" field if the given value is not nil.
|
||||||
|
func (_u *FrpcClientUpdate) SetNillableAddr(v *string) *FrpcClientUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetAddr(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPort sets the "port" field.
|
||||||
|
func (_u *FrpcClientUpdate) SetPort(v int) *FrpcClientUpdate {
|
||||||
|
_u.mutation.ResetPort()
|
||||||
|
_u.mutation.SetPort(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillablePort sets the "port" field if the given value is not nil.
|
||||||
|
func (_u *FrpcClientUpdate) SetNillablePort(v *int) *FrpcClientUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetPort(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddPort adds value to the "port" field.
|
||||||
|
func (_u *FrpcClientUpdate) AddPort(v int) *FrpcClientUpdate {
|
||||||
|
_u.mutation.AddPort(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetStatus sets the "status" field.
|
||||||
|
func (_u *FrpcClientUpdate) SetStatus(v string) *FrpcClientUpdate {
|
||||||
|
_u.mutation.SetStatus(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
||||||
|
func (_u *FrpcClientUpdate) SetNillableStatus(v *string) *FrpcClientUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetStatus(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetMetadata sets the "metadata" field.
|
||||||
|
func (_u *FrpcClientUpdate) SetMetadata(v string) *FrpcClientUpdate {
|
||||||
|
_u.mutation.SetMetadata(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableMetadata sets the "metadata" field if the given value is not nil.
|
||||||
|
func (_u *FrpcClientUpdate) SetNillableMetadata(v *string) *FrpcClientUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetMetadata(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCreatedAt sets the "created_at" field.
|
||||||
|
func (_u *FrpcClientUpdate) SetCreatedAt(v time.Time) *FrpcClientUpdate {
|
||||||
|
_u.mutation.SetCreatedAt(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||||
|
func (_u *FrpcClientUpdate) SetNillableCreatedAt(v *time.Time) *FrpcClientUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetCreatedAt(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUpdatedAt sets the "updated_at" field.
|
||||||
|
func (_u *FrpcClientUpdate) SetUpdatedAt(v time.Time) *FrpcClientUpdate {
|
||||||
|
_u.mutation.SetUpdatedAt(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetLastSeen sets the "last_seen" field.
|
||||||
|
func (_u *FrpcClientUpdate) SetLastSeen(v time.Time) *FrpcClientUpdate {
|
||||||
|
_u.mutation.SetLastSeen(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableLastSeen sets the "last_seen" field if the given value is not nil.
|
||||||
|
func (_u *FrpcClientUpdate) SetNillableLastSeen(v *time.Time) *FrpcClientUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetLastSeen(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearLastSeen clears the value of the "last_seen" field.
|
||||||
|
func (_u *FrpcClientUpdate) ClearLastSeen() *FrpcClientUpdate {
|
||||||
|
_u.mutation.ClearLastSeen()
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the FrpcClientMutation object of the builder.
|
||||||
|
func (_u *FrpcClientUpdate) Mutation() *FrpcClientMutation {
|
||||||
|
return _u.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||||
|
func (_u *FrpcClientUpdate) Save(ctx context.Context) (int, error) {
|
||||||
|
_u.defaults()
|
||||||
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (_u *FrpcClientUpdate) SaveX(ctx context.Context) int {
|
||||||
|
affected, err := _u.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return affected
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (_u *FrpcClientUpdate) Exec(ctx context.Context) error {
|
||||||
|
_, err := _u.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_u *FrpcClientUpdate) ExecX(ctx context.Context) {
|
||||||
|
if err := _u.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// defaults sets the default values of the builder before save.
|
||||||
|
func (_u *FrpcClientUpdate) defaults() {
|
||||||
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||||
|
v := frpcclient.UpdateDefaultUpdatedAt()
|
||||||
|
_u.mutation.SetUpdatedAt(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_u *FrpcClientUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||||
|
_spec := sqlgraph.NewUpdateSpec(frpcclient.Table, frpcclient.Columns, sqlgraph.NewFieldSpec(frpcclient.FieldID, field.TypeInt))
|
||||||
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Name(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldName, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Key(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldKey, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Addr(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldAddr, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Port(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldPort, field.TypeInt, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.AddedPort(); ok {
|
||||||
|
_spec.AddField(frpcclient.FieldPort, field.TypeInt, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Status(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldStatus, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Metadata(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldMetadata, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldCreatedAt, field.TypeTime, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldUpdatedAt, field.TypeTime, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.LastSeen(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldLastSeen, field.TypeTime, value)
|
||||||
|
}
|
||||||
|
if _u.mutation.LastSeenCleared() {
|
||||||
|
_spec.ClearField(frpcclient.FieldLastSeen, field.TypeTime)
|
||||||
|
}
|
||||||
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||||
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
|
err = &NotFoundError{frpcclient.Label}
|
||||||
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
_u.mutation.done = true
|
||||||
|
return _node, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FrpcClientUpdateOne is the builder for updating a single FrpcClient entity.
|
||||||
|
type FrpcClientUpdateOne struct {
|
||||||
|
config
|
||||||
|
fields []string
|
||||||
|
hooks []Hook
|
||||||
|
mutation *FrpcClientMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetName sets the "name" field.
|
||||||
|
func (_u *FrpcClientUpdateOne) SetName(v string) *FrpcClientUpdateOne {
|
||||||
|
_u.mutation.SetName(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableName sets the "name" field if the given value is not nil.
|
||||||
|
func (_u *FrpcClientUpdateOne) SetNillableName(v *string) *FrpcClientUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetName(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetKey sets the "key" field.
|
||||||
|
func (_u *FrpcClientUpdateOne) SetKey(v string) *FrpcClientUpdateOne {
|
||||||
|
_u.mutation.SetKey(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableKey sets the "key" field if the given value is not nil.
|
||||||
|
func (_u *FrpcClientUpdateOne) SetNillableKey(v *string) *FrpcClientUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetKey(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAddr sets the "addr" field.
|
||||||
|
func (_u *FrpcClientUpdateOne) SetAddr(v string) *FrpcClientUpdateOne {
|
||||||
|
_u.mutation.SetAddr(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableAddr sets the "addr" field if the given value is not nil.
|
||||||
|
func (_u *FrpcClientUpdateOne) SetNillableAddr(v *string) *FrpcClientUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetAddr(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPort sets the "port" field.
|
||||||
|
func (_u *FrpcClientUpdateOne) SetPort(v int) *FrpcClientUpdateOne {
|
||||||
|
_u.mutation.ResetPort()
|
||||||
|
_u.mutation.SetPort(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillablePort sets the "port" field if the given value is not nil.
|
||||||
|
func (_u *FrpcClientUpdateOne) SetNillablePort(v *int) *FrpcClientUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetPort(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddPort adds value to the "port" field.
|
||||||
|
func (_u *FrpcClientUpdateOne) AddPort(v int) *FrpcClientUpdateOne {
|
||||||
|
_u.mutation.AddPort(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetStatus sets the "status" field.
|
||||||
|
func (_u *FrpcClientUpdateOne) SetStatus(v string) *FrpcClientUpdateOne {
|
||||||
|
_u.mutation.SetStatus(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
||||||
|
func (_u *FrpcClientUpdateOne) SetNillableStatus(v *string) *FrpcClientUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetStatus(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetMetadata sets the "metadata" field.
|
||||||
|
func (_u *FrpcClientUpdateOne) SetMetadata(v string) *FrpcClientUpdateOne {
|
||||||
|
_u.mutation.SetMetadata(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableMetadata sets the "metadata" field if the given value is not nil.
|
||||||
|
func (_u *FrpcClientUpdateOne) SetNillableMetadata(v *string) *FrpcClientUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetMetadata(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCreatedAt sets the "created_at" field.
|
||||||
|
func (_u *FrpcClientUpdateOne) SetCreatedAt(v time.Time) *FrpcClientUpdateOne {
|
||||||
|
_u.mutation.SetCreatedAt(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||||
|
func (_u *FrpcClientUpdateOne) SetNillableCreatedAt(v *time.Time) *FrpcClientUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetCreatedAt(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUpdatedAt sets the "updated_at" field.
|
||||||
|
func (_u *FrpcClientUpdateOne) SetUpdatedAt(v time.Time) *FrpcClientUpdateOne {
|
||||||
|
_u.mutation.SetUpdatedAt(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetLastSeen sets the "last_seen" field.
|
||||||
|
func (_u *FrpcClientUpdateOne) SetLastSeen(v time.Time) *FrpcClientUpdateOne {
|
||||||
|
_u.mutation.SetLastSeen(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableLastSeen sets the "last_seen" field if the given value is not nil.
|
||||||
|
func (_u *FrpcClientUpdateOne) SetNillableLastSeen(v *time.Time) *FrpcClientUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetLastSeen(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearLastSeen clears the value of the "last_seen" field.
|
||||||
|
func (_u *FrpcClientUpdateOne) ClearLastSeen() *FrpcClientUpdateOne {
|
||||||
|
_u.mutation.ClearLastSeen()
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the FrpcClientMutation object of the builder.
|
||||||
|
func (_u *FrpcClientUpdateOne) Mutation() *FrpcClientMutation {
|
||||||
|
return _u.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the FrpcClientUpdate builder.
|
||||||
|
func (_u *FrpcClientUpdateOne) Where(ps ...predicate.FrpcClient) *FrpcClientUpdateOne {
|
||||||
|
_u.mutation.Where(ps...)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||||
|
// The default is selecting all fields defined in the entity schema.
|
||||||
|
func (_u *FrpcClientUpdateOne) Select(field string, fields ...string) *FrpcClientUpdateOne {
|
||||||
|
_u.fields = append([]string{field}, fields...)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save executes the query and returns the updated FrpcClient entity.
|
||||||
|
func (_u *FrpcClientUpdateOne) Save(ctx context.Context) (*FrpcClient, error) {
|
||||||
|
_u.defaults()
|
||||||
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (_u *FrpcClientUpdateOne) SaveX(ctx context.Context) *FrpcClient {
|
||||||
|
node, err := _u.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query on the entity.
|
||||||
|
func (_u *FrpcClientUpdateOne) Exec(ctx context.Context) error {
|
||||||
|
_, err := _u.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_u *FrpcClientUpdateOne) ExecX(ctx context.Context) {
|
||||||
|
if err := _u.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// defaults sets the default values of the builder before save.
|
||||||
|
func (_u *FrpcClientUpdateOne) defaults() {
|
||||||
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||||
|
v := frpcclient.UpdateDefaultUpdatedAt()
|
||||||
|
_u.mutation.SetUpdatedAt(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_u *FrpcClientUpdateOne) sqlSave(ctx context.Context) (_node *FrpcClient, err error) {
|
||||||
|
_spec := sqlgraph.NewUpdateSpec(frpcclient.Table, frpcclient.Columns, sqlgraph.NewFieldSpec(frpcclient.FieldID, field.TypeInt))
|
||||||
|
id, ok := _u.mutation.ID()
|
||||||
|
if !ok {
|
||||||
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "FrpcClient.id" for update`)}
|
||||||
|
}
|
||||||
|
_spec.Node.ID.Value = id
|
||||||
|
if fields := _u.fields; len(fields) > 0 {
|
||||||
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, frpcclient.FieldID)
|
||||||
|
for _, f := range fields {
|
||||||
|
if !frpcclient.ValidColumn(f) {
|
||||||
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||||
|
}
|
||||||
|
if f != frpcclient.FieldID {
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Name(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldName, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Key(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldKey, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Addr(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldAddr, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Port(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldPort, field.TypeInt, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.AddedPort(); ok {
|
||||||
|
_spec.AddField(frpcclient.FieldPort, field.TypeInt, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Status(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldStatus, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Metadata(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldMetadata, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldCreatedAt, field.TypeTime, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldUpdatedAt, field.TypeTime, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.LastSeen(); ok {
|
||||||
|
_spec.SetField(frpcclient.FieldLastSeen, field.TypeTime, value)
|
||||||
|
}
|
||||||
|
if _u.mutation.LastSeenCleared() {
|
||||||
|
_spec.ClearField(frpcclient.FieldLastSeen, field.TypeTime)
|
||||||
|
}
|
||||||
|
_node = &FrpcClient{config: _u.config}
|
||||||
|
_spec.Assign = _node.assignValues
|
||||||
|
_spec.ScanValues = _node.scanValues
|
||||||
|
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
||||||
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
|
err = &NotFoundError{frpcclient.Label}
|
||||||
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_u.mutation.done = true
|
||||||
|
return _node, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
package ent
|
||||||
|
|
||||||
|
//go:generate go run entgo.io/ent/cmd/ent generate ./schema
|
||||||
@@ -0,0 +1,235 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package hook
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent"
|
||||||
|
)
|
||||||
|
|
||||||
|
// The FrpcClientFunc type is an adapter to allow the use of ordinary
|
||||||
|
// function as FrpcClient mutator.
|
||||||
|
type FrpcClientFunc func(context.Context, *ent.FrpcClientMutation) (ent.Value, error)
|
||||||
|
|
||||||
|
// Mutate calls f(ctx, m).
|
||||||
|
func (f FrpcClientFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||||
|
if mv, ok := m.(*ent.FrpcClientMutation); ok {
|
||||||
|
return f(ctx, mv)
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.FrpcClientMutation", m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// The ProxyFunc type is an adapter to allow the use of ordinary
|
||||||
|
// function as Proxy mutator.
|
||||||
|
type ProxyFunc func(context.Context, *ent.ProxyMutation) (ent.Value, error)
|
||||||
|
|
||||||
|
// Mutate calls f(ctx, m).
|
||||||
|
func (f ProxyFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||||
|
if mv, ok := m.(*ent.ProxyMutation); ok {
|
||||||
|
return f(ctx, mv)
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ProxyMutation", m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// The ServerConfigFunc type is an adapter to allow the use of ordinary
|
||||||
|
// function as ServerConfig mutator.
|
||||||
|
type ServerConfigFunc func(context.Context, *ent.ServerConfigMutation) (ent.Value, error)
|
||||||
|
|
||||||
|
// Mutate calls f(ctx, m).
|
||||||
|
func (f ServerConfigFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||||
|
if mv, ok := m.(*ent.ServerConfigMutation); ok {
|
||||||
|
return f(ctx, mv)
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ServerConfigMutation", m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// The UserFunc type is an adapter to allow the use of ordinary
|
||||||
|
// function as User mutator.
|
||||||
|
type UserFunc func(context.Context, *ent.UserMutation) (ent.Value, error)
|
||||||
|
|
||||||
|
// Mutate calls f(ctx, m).
|
||||||
|
func (f UserFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||||
|
if mv, ok := m.(*ent.UserMutation); ok {
|
||||||
|
return f(ctx, mv)
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UserMutation", m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Condition is a hook condition function.
|
||||||
|
type Condition func(context.Context, ent.Mutation) bool
|
||||||
|
|
||||||
|
// And groups conditions with the AND operator.
|
||||||
|
func And(first, second Condition, rest ...Condition) Condition {
|
||||||
|
return func(ctx context.Context, m ent.Mutation) bool {
|
||||||
|
if !first(ctx, m) || !second(ctx, m) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for _, cond := range rest {
|
||||||
|
if !cond(ctx, m) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Or groups conditions with the OR operator.
|
||||||
|
func Or(first, second Condition, rest ...Condition) Condition {
|
||||||
|
return func(ctx context.Context, m ent.Mutation) bool {
|
||||||
|
if first(ctx, m) || second(ctx, m) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
for _, cond := range rest {
|
||||||
|
if cond(ctx, m) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not negates a given condition.
|
||||||
|
func Not(cond Condition) Condition {
|
||||||
|
return func(ctx context.Context, m ent.Mutation) bool {
|
||||||
|
return !cond(ctx, m)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasOp is a condition testing mutation operation.
|
||||||
|
func HasOp(op ent.Op) Condition {
|
||||||
|
return func(_ context.Context, m ent.Mutation) bool {
|
||||||
|
return m.Op().Is(op)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasAddedFields is a condition validating `.AddedField` on fields.
|
||||||
|
func HasAddedFields(field string, fields ...string) Condition {
|
||||||
|
return func(_ context.Context, m ent.Mutation) bool {
|
||||||
|
if _, exists := m.AddedField(field); !exists {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for _, field := range fields {
|
||||||
|
if _, exists := m.AddedField(field); !exists {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasClearedFields is a condition validating `.FieldCleared` on fields.
|
||||||
|
func HasClearedFields(field string, fields ...string) Condition {
|
||||||
|
return func(_ context.Context, m ent.Mutation) bool {
|
||||||
|
if exists := m.FieldCleared(field); !exists {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for _, field := range fields {
|
||||||
|
if exists := m.FieldCleared(field); !exists {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasFields is a condition validating `.Field` on fields.
|
||||||
|
func HasFields(field string, fields ...string) Condition {
|
||||||
|
return func(_ context.Context, m ent.Mutation) bool {
|
||||||
|
if _, exists := m.Field(field); !exists {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for _, field := range fields {
|
||||||
|
if _, exists := m.Field(field); !exists {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If executes the given hook under condition.
|
||||||
|
//
|
||||||
|
// hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...)))
|
||||||
|
func If(hk ent.Hook, cond Condition) ent.Hook {
|
||||||
|
return func(next ent.Mutator) ent.Mutator {
|
||||||
|
return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||||
|
if cond(ctx, m) {
|
||||||
|
return hk(next).Mutate(ctx, m)
|
||||||
|
}
|
||||||
|
return next.Mutate(ctx, m)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// On executes the given hook only for the given operation.
|
||||||
|
//
|
||||||
|
// hook.On(Log, ent.Delete|ent.Create)
|
||||||
|
func On(hk ent.Hook, op ent.Op) ent.Hook {
|
||||||
|
return If(hk, HasOp(op))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unless skips the given hook only for the given operation.
|
||||||
|
//
|
||||||
|
// hook.Unless(Log, ent.Update|ent.UpdateOne)
|
||||||
|
func Unless(hk ent.Hook, op ent.Op) ent.Hook {
|
||||||
|
return If(hk, Not(HasOp(op)))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FixedError is a hook returning a fixed error.
|
||||||
|
func FixedError(err error) ent.Hook {
|
||||||
|
return func(ent.Mutator) ent.Mutator {
|
||||||
|
return ent.MutateFunc(func(context.Context, ent.Mutation) (ent.Value, error) {
|
||||||
|
return nil, err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reject returns a hook that rejects all operations that match op.
|
||||||
|
//
|
||||||
|
// func (T) Hooks() []ent.Hook {
|
||||||
|
// return []ent.Hook{
|
||||||
|
// Reject(ent.Delete|ent.Update),
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
func Reject(op ent.Op) ent.Hook {
|
||||||
|
hk := FixedError(fmt.Errorf("%s operation is not allowed", op))
|
||||||
|
return On(hk, op)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Chain acts as a list of hooks and is effectively immutable.
|
||||||
|
// Once created, it will always hold the same set of hooks in the same order.
|
||||||
|
type Chain struct {
|
||||||
|
hooks []ent.Hook
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewChain creates a new chain of hooks.
|
||||||
|
func NewChain(hooks ...ent.Hook) Chain {
|
||||||
|
return Chain{append([]ent.Hook(nil), hooks...)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hook chains the list of hooks and returns the final hook.
|
||||||
|
func (c Chain) Hook() ent.Hook {
|
||||||
|
return func(mutator ent.Mutator) ent.Mutator {
|
||||||
|
for i := len(c.hooks) - 1; i >= 0; i-- {
|
||||||
|
mutator = c.hooks[i](mutator)
|
||||||
|
}
|
||||||
|
return mutator
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Append extends a chain, adding the specified hook
|
||||||
|
// as the last ones in the mutation flow.
|
||||||
|
func (c Chain) Append(hooks ...ent.Hook) Chain {
|
||||||
|
newHooks := make([]ent.Hook, 0, len(c.hooks)+len(hooks))
|
||||||
|
newHooks = append(newHooks, c.hooks...)
|
||||||
|
newHooks = append(newHooks, hooks...)
|
||||||
|
return Chain{newHooks}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extend extends a chain, adding the specified chain
|
||||||
|
// as the last ones in the mutation flow.
|
||||||
|
func (c Chain) Extend(chain Chain) Chain {
|
||||||
|
return c.Append(chain.hooks...)
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package migrate
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect"
|
||||||
|
"entgo.io/ent/dialect/sql/schema"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// WithGlobalUniqueID sets the universal ids options to the migration.
|
||||||
|
// If this option is enabled, ent migration will allocate a 1<<32 range
|
||||||
|
// for the ids of each entity (table).
|
||||||
|
// Note that this option cannot be applied on tables that already exist.
|
||||||
|
WithGlobalUniqueID = schema.WithGlobalUniqueID
|
||||||
|
// WithDropColumn sets the drop column option to the migration.
|
||||||
|
// If this option is enabled, ent migration will drop old columns
|
||||||
|
// that were used for both fields and edges. This defaults to false.
|
||||||
|
WithDropColumn = schema.WithDropColumn
|
||||||
|
// WithDropIndex sets the drop index option to the migration.
|
||||||
|
// If this option is enabled, ent migration will drop old indexes
|
||||||
|
// that were defined in the schema. This defaults to false.
|
||||||
|
// Note that unique constraints are defined using `UNIQUE INDEX`,
|
||||||
|
// and therefore, it's recommended to enable this option to get more
|
||||||
|
// flexibility in the schema changes.
|
||||||
|
WithDropIndex = schema.WithDropIndex
|
||||||
|
// WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true.
|
||||||
|
WithForeignKeys = schema.WithForeignKeys
|
||||||
|
)
|
||||||
|
|
||||||
|
// Schema is the API for creating, migrating and dropping a schema.
|
||||||
|
type Schema struct {
|
||||||
|
drv dialect.Driver
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSchema creates a new schema client.
|
||||||
|
func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} }
|
||||||
|
|
||||||
|
// Create creates all schema resources.
|
||||||
|
func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error {
|
||||||
|
return Create(ctx, s, Tables, opts...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create creates all table resources using the given schema driver.
|
||||||
|
func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error {
|
||||||
|
migrate, err := schema.NewMigrate(s.drv, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("ent/migrate: %w", err)
|
||||||
|
}
|
||||||
|
return migrate.Create(ctx, tables...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteTo writes the schema changes to w instead of running them against the database.
|
||||||
|
//
|
||||||
|
// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil {
|
||||||
|
// log.Fatal(err)
|
||||||
|
// }
|
||||||
|
func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error {
|
||||||
|
return Create(ctx, &Schema{drv: &schema.WriteDriver{Writer: w, Driver: s.drv}}, Tables, opts...)
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package migrate
|
||||||
|
|
||||||
|
import (
|
||||||
|
"entgo.io/ent/dialect/sql/schema"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// FrpcClientsColumns holds the columns for the "frpc_clients" table.
|
||||||
|
FrpcClientsColumns = []*schema.Column{
|
||||||
|
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||||
|
{Name: "name", Type: field.TypeString, Unique: true},
|
||||||
|
{Name: "key", Type: field.TypeString, Default: ""},
|
||||||
|
{Name: "addr", Type: field.TypeString, Default: ""},
|
||||||
|
{Name: "port", Type: field.TypeInt, Default: 0},
|
||||||
|
{Name: "status", Type: field.TypeString, Default: "offline"},
|
||||||
|
{Name: "metadata", Type: field.TypeString, Default: "{}"},
|
||||||
|
{Name: "created_at", Type: field.TypeTime},
|
||||||
|
{Name: "updated_at", Type: field.TypeTime},
|
||||||
|
{Name: "last_seen", Type: field.TypeTime, Nullable: true},
|
||||||
|
}
|
||||||
|
// FrpcClientsTable holds the schema information for the "frpc_clients" table.
|
||||||
|
FrpcClientsTable = &schema.Table{
|
||||||
|
Name: "frpc_clients",
|
||||||
|
Columns: FrpcClientsColumns,
|
||||||
|
PrimaryKey: []*schema.Column{FrpcClientsColumns[0]},
|
||||||
|
}
|
||||||
|
// ProxiesColumns holds the columns for the "proxies" table.
|
||||||
|
ProxiesColumns = []*schema.Column{
|
||||||
|
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||||
|
{Name: "name", Type: field.TypeString},
|
||||||
|
{Name: "proxy_type", Type: field.TypeString, Default: "tcp"},
|
||||||
|
{Name: "local_ip", Type: field.TypeString, Default: "127.0.0.1"},
|
||||||
|
{Name: "local_port", Type: field.TypeInt},
|
||||||
|
{Name: "remote_port", Type: field.TypeInt, Default: 0},
|
||||||
|
{Name: "status", Type: field.TypeString, Default: "inactive"},
|
||||||
|
{Name: "custom_domains", Type: field.TypeString, Default: ""},
|
||||||
|
{Name: "metadata", Type: field.TypeString, Default: "{}"},
|
||||||
|
{Name: "client_id", Type: field.TypeInt, Default: 0},
|
||||||
|
{Name: "created_at", Type: field.TypeTime},
|
||||||
|
{Name: "updated_at", Type: field.TypeTime},
|
||||||
|
}
|
||||||
|
// ProxiesTable holds the schema information for the "proxies" table.
|
||||||
|
ProxiesTable = &schema.Table{
|
||||||
|
Name: "proxies",
|
||||||
|
Columns: ProxiesColumns,
|
||||||
|
PrimaryKey: []*schema.Column{ProxiesColumns[0]},
|
||||||
|
}
|
||||||
|
// ServerConfigsColumns holds the columns for the "server_configs" table.
|
||||||
|
ServerConfigsColumns = []*schema.Column{
|
||||||
|
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||||
|
{Name: "key", Type: field.TypeString, Unique: true},
|
||||||
|
{Name: "value", Type: field.TypeString},
|
||||||
|
}
|
||||||
|
// ServerConfigsTable holds the schema information for the "server_configs" table.
|
||||||
|
ServerConfigsTable = &schema.Table{
|
||||||
|
Name: "server_configs",
|
||||||
|
Columns: ServerConfigsColumns,
|
||||||
|
PrimaryKey: []*schema.Column{ServerConfigsColumns[0]},
|
||||||
|
}
|
||||||
|
// UsersColumns holds the columns for the "users" table.
|
||||||
|
UsersColumns = []*schema.Column{
|
||||||
|
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||||
|
{Name: "username", Type: field.TypeString, Unique: true},
|
||||||
|
{Name: "password", Type: field.TypeString},
|
||||||
|
{Name: "name", Type: field.TypeString, Default: ""},
|
||||||
|
{Name: "role", Type: field.TypeString, Default: "admin"},
|
||||||
|
{Name: "created_at", Type: field.TypeTime},
|
||||||
|
{Name: "updated_at", Type: field.TypeTime},
|
||||||
|
}
|
||||||
|
// UsersTable holds the schema information for the "users" table.
|
||||||
|
UsersTable = &schema.Table{
|
||||||
|
Name: "users",
|
||||||
|
Columns: UsersColumns,
|
||||||
|
PrimaryKey: []*schema.Column{UsersColumns[0]},
|
||||||
|
}
|
||||||
|
// Tables holds all the tables in the schema.
|
||||||
|
Tables = []*schema.Table{
|
||||||
|
FrpcClientsTable,
|
||||||
|
ProxiesTable,
|
||||||
|
ServerConfigsTable,
|
||||||
|
UsersTable,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package predicate
|
||||||
|
|
||||||
|
import (
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
)
|
||||||
|
|
||||||
|
// FrpcClient is the predicate function for frpcclient builders.
|
||||||
|
type FrpcClient func(*sql.Selector)
|
||||||
|
|
||||||
|
// Proxy is the predicate function for proxy builders.
|
||||||
|
type Proxy func(*sql.Selector)
|
||||||
|
|
||||||
|
// ServerConfig is the predicate function for serverconfig builders.
|
||||||
|
type ServerConfig func(*sql.Selector)
|
||||||
|
|
||||||
|
// User is the predicate function for user builders.
|
||||||
|
type User func(*sql.Selector)
|
||||||
@@ -0,0 +1,216 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/proxy"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Proxy is the model entity for the Proxy schema.
|
||||||
|
type Proxy struct {
|
||||||
|
config `json:"-"`
|
||||||
|
// ID of the ent.
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
// Name holds the value of the "name" field.
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
// ProxyType holds the value of the "proxy_type" field.
|
||||||
|
ProxyType string `json:"proxy_type,omitempty"`
|
||||||
|
// LocalIP holds the value of the "local_ip" field.
|
||||||
|
LocalIP string `json:"local_ip,omitempty"`
|
||||||
|
// LocalPort holds the value of the "local_port" field.
|
||||||
|
LocalPort int `json:"local_port,omitempty"`
|
||||||
|
// RemotePort holds the value of the "remote_port" field.
|
||||||
|
RemotePort int `json:"remote_port,omitempty"`
|
||||||
|
// Status holds the value of the "status" field.
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
// CustomDomains holds the value of the "custom_domains" field.
|
||||||
|
CustomDomains string `json:"custom_domains,omitempty"`
|
||||||
|
// Metadata holds the value of the "metadata" field.
|
||||||
|
Metadata string `json:"metadata,omitempty"`
|
||||||
|
// ClientID holds the value of the "client_id" field.
|
||||||
|
ClientID int `json:"client_id,omitempty"`
|
||||||
|
// CreatedAt holds the value of the "created_at" field.
|
||||||
|
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||||
|
// UpdatedAt holds the value of the "updated_at" field.
|
||||||
|
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||||
|
selectValues sql.SelectValues
|
||||||
|
}
|
||||||
|
|
||||||
|
// scanValues returns the types for scanning values from sql.Rows.
|
||||||
|
func (*Proxy) scanValues(columns []string) ([]any, error) {
|
||||||
|
values := make([]any, len(columns))
|
||||||
|
for i := range columns {
|
||||||
|
switch columns[i] {
|
||||||
|
case proxy.FieldID, proxy.FieldLocalPort, proxy.FieldRemotePort, proxy.FieldClientID:
|
||||||
|
values[i] = new(sql.NullInt64)
|
||||||
|
case proxy.FieldName, proxy.FieldProxyType, proxy.FieldLocalIP, proxy.FieldStatus, proxy.FieldCustomDomains, proxy.FieldMetadata:
|
||||||
|
values[i] = new(sql.NullString)
|
||||||
|
case proxy.FieldCreatedAt, proxy.FieldUpdatedAt:
|
||||||
|
values[i] = new(sql.NullTime)
|
||||||
|
default:
|
||||||
|
values[i] = new(sql.UnknownType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return values, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||||
|
// to the Proxy fields.
|
||||||
|
func (_m *Proxy) assignValues(columns []string, values []any) error {
|
||||||
|
if m, n := len(values), len(columns); m < n {
|
||||||
|
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||||
|
}
|
||||||
|
for i := range columns {
|
||||||
|
switch columns[i] {
|
||||||
|
case proxy.FieldID:
|
||||||
|
value, ok := values[i].(*sql.NullInt64)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field id", value)
|
||||||
|
}
|
||||||
|
_m.ID = int(value.Int64)
|
||||||
|
case proxy.FieldName:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.Name = value.String
|
||||||
|
}
|
||||||
|
case proxy.FieldProxyType:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field proxy_type", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.ProxyType = value.String
|
||||||
|
}
|
||||||
|
case proxy.FieldLocalIP:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field local_ip", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.LocalIP = value.String
|
||||||
|
}
|
||||||
|
case proxy.FieldLocalPort:
|
||||||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field local_port", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.LocalPort = int(value.Int64)
|
||||||
|
}
|
||||||
|
case proxy.FieldRemotePort:
|
||||||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field remote_port", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.RemotePort = int(value.Int64)
|
||||||
|
}
|
||||||
|
case proxy.FieldStatus:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field status", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.Status = value.String
|
||||||
|
}
|
||||||
|
case proxy.FieldCustomDomains:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field custom_domains", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.CustomDomains = value.String
|
||||||
|
}
|
||||||
|
case proxy.FieldMetadata:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field metadata", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.Metadata = value.String
|
||||||
|
}
|
||||||
|
case proxy.FieldClientID:
|
||||||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field client_id", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.ClientID = int(value.Int64)
|
||||||
|
}
|
||||||
|
case proxy.FieldCreatedAt:
|
||||||
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.CreatedAt = value.Time
|
||||||
|
}
|
||||||
|
case proxy.FieldUpdatedAt:
|
||||||
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.UpdatedAt = value.Time
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
_m.selectValues.Set(columns[i], values[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value returns the ent.Value that was dynamically selected and assigned to the Proxy.
|
||||||
|
// This includes values selected through modifiers, order, etc.
|
||||||
|
func (_m *Proxy) Value(name string) (ent.Value, error) {
|
||||||
|
return _m.selectValues.Get(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update returns a builder for updating this Proxy.
|
||||||
|
// Note that you need to call Proxy.Unwrap() before calling this method if this Proxy
|
||||||
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||||
|
func (_m *Proxy) Update() *ProxyUpdateOne {
|
||||||
|
return NewProxyClient(_m.config).UpdateOne(_m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unwrap unwraps the Proxy entity that was returned from a transaction after it was closed,
|
||||||
|
// so that all future queries will be executed through the driver which created the transaction.
|
||||||
|
func (_m *Proxy) Unwrap() *Proxy {
|
||||||
|
_tx, ok := _m.config.driver.(*txDriver)
|
||||||
|
if !ok {
|
||||||
|
panic("ent: Proxy is not a transactional entity")
|
||||||
|
}
|
||||||
|
_m.config.driver = _tx.drv
|
||||||
|
return _m
|
||||||
|
}
|
||||||
|
|
||||||
|
// String implements the fmt.Stringer.
|
||||||
|
func (_m *Proxy) String() string {
|
||||||
|
var builder strings.Builder
|
||||||
|
builder.WriteString("Proxy(")
|
||||||
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||||
|
builder.WriteString("name=")
|
||||||
|
builder.WriteString(_m.Name)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("proxy_type=")
|
||||||
|
builder.WriteString(_m.ProxyType)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("local_ip=")
|
||||||
|
builder.WriteString(_m.LocalIP)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("local_port=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", _m.LocalPort))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("remote_port=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", _m.RemotePort))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("status=")
|
||||||
|
builder.WriteString(_m.Status)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("custom_domains=")
|
||||||
|
builder.WriteString(_m.CustomDomains)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("metadata=")
|
||||||
|
builder.WriteString(_m.Metadata)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("client_id=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", _m.ClientID))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("created_at=")
|
||||||
|
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("updated_at=")
|
||||||
|
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
||||||
|
builder.WriteByte(')')
|
||||||
|
return builder.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Proxies is a parsable slice of Proxy.
|
||||||
|
type Proxies []*Proxy
|
||||||
@@ -0,0 +1,152 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package proxy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Label holds the string label denoting the proxy type in the database.
|
||||||
|
Label = "proxy"
|
||||||
|
// FieldID holds the string denoting the id field in the database.
|
||||||
|
FieldID = "id"
|
||||||
|
// FieldName holds the string denoting the name field in the database.
|
||||||
|
FieldName = "name"
|
||||||
|
// FieldProxyType holds the string denoting the proxy_type field in the database.
|
||||||
|
FieldProxyType = "proxy_type"
|
||||||
|
// FieldLocalIP holds the string denoting the local_ip field in the database.
|
||||||
|
FieldLocalIP = "local_ip"
|
||||||
|
// FieldLocalPort holds the string denoting the local_port field in the database.
|
||||||
|
FieldLocalPort = "local_port"
|
||||||
|
// FieldRemotePort holds the string denoting the remote_port field in the database.
|
||||||
|
FieldRemotePort = "remote_port"
|
||||||
|
// FieldStatus holds the string denoting the status field in the database.
|
||||||
|
FieldStatus = "status"
|
||||||
|
// FieldCustomDomains holds the string denoting the custom_domains field in the database.
|
||||||
|
FieldCustomDomains = "custom_domains"
|
||||||
|
// FieldMetadata holds the string denoting the metadata field in the database.
|
||||||
|
FieldMetadata = "metadata"
|
||||||
|
// FieldClientID holds the string denoting the client_id field in the database.
|
||||||
|
FieldClientID = "client_id"
|
||||||
|
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||||
|
FieldCreatedAt = "created_at"
|
||||||
|
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||||
|
FieldUpdatedAt = "updated_at"
|
||||||
|
// Table holds the table name of the proxy in the database.
|
||||||
|
Table = "proxies"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Columns holds all SQL columns for proxy fields.
|
||||||
|
var Columns = []string{
|
||||||
|
FieldID,
|
||||||
|
FieldName,
|
||||||
|
FieldProxyType,
|
||||||
|
FieldLocalIP,
|
||||||
|
FieldLocalPort,
|
||||||
|
FieldRemotePort,
|
||||||
|
FieldStatus,
|
||||||
|
FieldCustomDomains,
|
||||||
|
FieldMetadata,
|
||||||
|
FieldClientID,
|
||||||
|
FieldCreatedAt,
|
||||||
|
FieldUpdatedAt,
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||||
|
func ValidColumn(column string) bool {
|
||||||
|
for i := range Columns {
|
||||||
|
if column == Columns[i] {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// DefaultProxyType holds the default value on creation for the "proxy_type" field.
|
||||||
|
DefaultProxyType string
|
||||||
|
// DefaultLocalIP holds the default value on creation for the "local_ip" field.
|
||||||
|
DefaultLocalIP string
|
||||||
|
// DefaultRemotePort holds the default value on creation for the "remote_port" field.
|
||||||
|
DefaultRemotePort int
|
||||||
|
// DefaultStatus holds the default value on creation for the "status" field.
|
||||||
|
DefaultStatus string
|
||||||
|
// DefaultCustomDomains holds the default value on creation for the "custom_domains" field.
|
||||||
|
DefaultCustomDomains string
|
||||||
|
// DefaultMetadata holds the default value on creation for the "metadata" field.
|
||||||
|
DefaultMetadata string
|
||||||
|
// DefaultClientID holds the default value on creation for the "client_id" field.
|
||||||
|
DefaultClientID int
|
||||||
|
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||||
|
DefaultCreatedAt func() time.Time
|
||||||
|
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
||||||
|
DefaultUpdatedAt func() time.Time
|
||||||
|
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
|
||||||
|
UpdateDefaultUpdatedAt func() time.Time
|
||||||
|
)
|
||||||
|
|
||||||
|
// OrderOption defines the ordering options for the Proxy queries.
|
||||||
|
type OrderOption func(*sql.Selector)
|
||||||
|
|
||||||
|
// ByID orders the results by the id field.
|
||||||
|
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByName orders the results by the name field.
|
||||||
|
func ByName(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldName, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByProxyType orders the results by the proxy_type field.
|
||||||
|
func ByProxyType(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldProxyType, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByLocalIP orders the results by the local_ip field.
|
||||||
|
func ByLocalIP(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldLocalIP, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByLocalPort orders the results by the local_port field.
|
||||||
|
func ByLocalPort(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldLocalPort, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByRemotePort orders the results by the remote_port field.
|
||||||
|
func ByRemotePort(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldRemotePort, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByStatus orders the results by the status field.
|
||||||
|
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldStatus, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByCustomDomains orders the results by the custom_domains field.
|
||||||
|
func ByCustomDomains(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldCustomDomains, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByMetadata orders the results by the metadata field.
|
||||||
|
func ByMetadata(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldMetadata, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByClientID orders the results by the client_id field.
|
||||||
|
func ByClientID(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldClientID, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByCreatedAt orders the results by the created_at field.
|
||||||
|
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByUpdatedAt orders the results by the updated_at field.
|
||||||
|
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
|
||||||
|
}
|
||||||
@@ -0,0 +1,715 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package proxy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/predicate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ID filters vertices based on their ID field.
|
||||||
|
func ID(id int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDEQ applies the EQ predicate on the ID field.
|
||||||
|
func IDEQ(id int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDNEQ applies the NEQ predicate on the ID field.
|
||||||
|
func IDNEQ(id int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldNEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDIn applies the In predicate on the ID field.
|
||||||
|
func IDIn(ids ...int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldIn(FieldID, ids...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDNotIn applies the NotIn predicate on the ID field.
|
||||||
|
func IDNotIn(ids ...int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldNotIn(FieldID, ids...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDGT applies the GT predicate on the ID field.
|
||||||
|
func IDGT(id int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldGT(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDGTE applies the GTE predicate on the ID field.
|
||||||
|
func IDGTE(id int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldGTE(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDLT applies the LT predicate on the ID field.
|
||||||
|
func IDLT(id int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldLT(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDLTE applies the LTE predicate on the ID field.
|
||||||
|
func IDLTE(id int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldLTE(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
|
||||||
|
func Name(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEQ(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProxyType applies equality check predicate on the "proxy_type" field. It's identical to ProxyTypeEQ.
|
||||||
|
func ProxyType(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEQ(FieldProxyType, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LocalIP applies equality check predicate on the "local_ip" field. It's identical to LocalIPEQ.
|
||||||
|
func LocalIP(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEQ(FieldLocalIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LocalPort applies equality check predicate on the "local_port" field. It's identical to LocalPortEQ.
|
||||||
|
func LocalPort(v int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEQ(FieldLocalPort, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemotePort applies equality check predicate on the "remote_port" field. It's identical to RemotePortEQ.
|
||||||
|
func RemotePort(v int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEQ(FieldRemotePort, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Status applies equality check predicate on the "status" field. It's identical to StatusEQ.
|
||||||
|
func Status(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEQ(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CustomDomains applies equality check predicate on the "custom_domains" field. It's identical to CustomDomainsEQ.
|
||||||
|
func CustomDomains(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEQ(FieldCustomDomains, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Metadata applies equality check predicate on the "metadata" field. It's identical to MetadataEQ.
|
||||||
|
func Metadata(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEQ(FieldMetadata, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClientID applies equality check predicate on the "client_id" field. It's identical to ClientIDEQ.
|
||||||
|
func ClientID(v int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEQ(FieldClientID, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||||
|
func CreatedAt(v time.Time) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEQ(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
|
||||||
|
func UpdatedAt(v time.Time) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEQ(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameEQ applies the EQ predicate on the "name" field.
|
||||||
|
func NameEQ(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEQ(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameNEQ applies the NEQ predicate on the "name" field.
|
||||||
|
func NameNEQ(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldNEQ(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameIn applies the In predicate on the "name" field.
|
||||||
|
func NameIn(vs ...string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldIn(FieldName, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameNotIn applies the NotIn predicate on the "name" field.
|
||||||
|
func NameNotIn(vs ...string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldNotIn(FieldName, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameGT applies the GT predicate on the "name" field.
|
||||||
|
func NameGT(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldGT(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameGTE applies the GTE predicate on the "name" field.
|
||||||
|
func NameGTE(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldGTE(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameLT applies the LT predicate on the "name" field.
|
||||||
|
func NameLT(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldLT(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameLTE applies the LTE predicate on the "name" field.
|
||||||
|
func NameLTE(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldLTE(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameContains applies the Contains predicate on the "name" field.
|
||||||
|
func NameContains(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldContains(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
|
||||||
|
func NameHasPrefix(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldHasPrefix(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
|
||||||
|
func NameHasSuffix(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldHasSuffix(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameEqualFold applies the EqualFold predicate on the "name" field.
|
||||||
|
func NameEqualFold(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEqualFold(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameContainsFold applies the ContainsFold predicate on the "name" field.
|
||||||
|
func NameContainsFold(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldContainsFold(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProxyTypeEQ applies the EQ predicate on the "proxy_type" field.
|
||||||
|
func ProxyTypeEQ(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEQ(FieldProxyType, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProxyTypeNEQ applies the NEQ predicate on the "proxy_type" field.
|
||||||
|
func ProxyTypeNEQ(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldNEQ(FieldProxyType, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProxyTypeIn applies the In predicate on the "proxy_type" field.
|
||||||
|
func ProxyTypeIn(vs ...string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldIn(FieldProxyType, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProxyTypeNotIn applies the NotIn predicate on the "proxy_type" field.
|
||||||
|
func ProxyTypeNotIn(vs ...string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldNotIn(FieldProxyType, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProxyTypeGT applies the GT predicate on the "proxy_type" field.
|
||||||
|
func ProxyTypeGT(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldGT(FieldProxyType, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProxyTypeGTE applies the GTE predicate on the "proxy_type" field.
|
||||||
|
func ProxyTypeGTE(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldGTE(FieldProxyType, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProxyTypeLT applies the LT predicate on the "proxy_type" field.
|
||||||
|
func ProxyTypeLT(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldLT(FieldProxyType, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProxyTypeLTE applies the LTE predicate on the "proxy_type" field.
|
||||||
|
func ProxyTypeLTE(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldLTE(FieldProxyType, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProxyTypeContains applies the Contains predicate on the "proxy_type" field.
|
||||||
|
func ProxyTypeContains(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldContains(FieldProxyType, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProxyTypeHasPrefix applies the HasPrefix predicate on the "proxy_type" field.
|
||||||
|
func ProxyTypeHasPrefix(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldHasPrefix(FieldProxyType, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProxyTypeHasSuffix applies the HasSuffix predicate on the "proxy_type" field.
|
||||||
|
func ProxyTypeHasSuffix(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldHasSuffix(FieldProxyType, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProxyTypeEqualFold applies the EqualFold predicate on the "proxy_type" field.
|
||||||
|
func ProxyTypeEqualFold(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEqualFold(FieldProxyType, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProxyTypeContainsFold applies the ContainsFold predicate on the "proxy_type" field.
|
||||||
|
func ProxyTypeContainsFold(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldContainsFold(FieldProxyType, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LocalIPEQ applies the EQ predicate on the "local_ip" field.
|
||||||
|
func LocalIPEQ(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEQ(FieldLocalIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LocalIPNEQ applies the NEQ predicate on the "local_ip" field.
|
||||||
|
func LocalIPNEQ(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldNEQ(FieldLocalIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LocalIPIn applies the In predicate on the "local_ip" field.
|
||||||
|
func LocalIPIn(vs ...string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldIn(FieldLocalIP, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LocalIPNotIn applies the NotIn predicate on the "local_ip" field.
|
||||||
|
func LocalIPNotIn(vs ...string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldNotIn(FieldLocalIP, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LocalIPGT applies the GT predicate on the "local_ip" field.
|
||||||
|
func LocalIPGT(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldGT(FieldLocalIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LocalIPGTE applies the GTE predicate on the "local_ip" field.
|
||||||
|
func LocalIPGTE(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldGTE(FieldLocalIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LocalIPLT applies the LT predicate on the "local_ip" field.
|
||||||
|
func LocalIPLT(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldLT(FieldLocalIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LocalIPLTE applies the LTE predicate on the "local_ip" field.
|
||||||
|
func LocalIPLTE(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldLTE(FieldLocalIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LocalIPContains applies the Contains predicate on the "local_ip" field.
|
||||||
|
func LocalIPContains(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldContains(FieldLocalIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LocalIPHasPrefix applies the HasPrefix predicate on the "local_ip" field.
|
||||||
|
func LocalIPHasPrefix(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldHasPrefix(FieldLocalIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LocalIPHasSuffix applies the HasSuffix predicate on the "local_ip" field.
|
||||||
|
func LocalIPHasSuffix(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldHasSuffix(FieldLocalIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LocalIPEqualFold applies the EqualFold predicate on the "local_ip" field.
|
||||||
|
func LocalIPEqualFold(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEqualFold(FieldLocalIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LocalIPContainsFold applies the ContainsFold predicate on the "local_ip" field.
|
||||||
|
func LocalIPContainsFold(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldContainsFold(FieldLocalIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LocalPortEQ applies the EQ predicate on the "local_port" field.
|
||||||
|
func LocalPortEQ(v int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEQ(FieldLocalPort, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LocalPortNEQ applies the NEQ predicate on the "local_port" field.
|
||||||
|
func LocalPortNEQ(v int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldNEQ(FieldLocalPort, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LocalPortIn applies the In predicate on the "local_port" field.
|
||||||
|
func LocalPortIn(vs ...int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldIn(FieldLocalPort, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LocalPortNotIn applies the NotIn predicate on the "local_port" field.
|
||||||
|
func LocalPortNotIn(vs ...int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldNotIn(FieldLocalPort, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LocalPortGT applies the GT predicate on the "local_port" field.
|
||||||
|
func LocalPortGT(v int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldGT(FieldLocalPort, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LocalPortGTE applies the GTE predicate on the "local_port" field.
|
||||||
|
func LocalPortGTE(v int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldGTE(FieldLocalPort, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LocalPortLT applies the LT predicate on the "local_port" field.
|
||||||
|
func LocalPortLT(v int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldLT(FieldLocalPort, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LocalPortLTE applies the LTE predicate on the "local_port" field.
|
||||||
|
func LocalPortLTE(v int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldLTE(FieldLocalPort, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemotePortEQ applies the EQ predicate on the "remote_port" field.
|
||||||
|
func RemotePortEQ(v int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEQ(FieldRemotePort, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemotePortNEQ applies the NEQ predicate on the "remote_port" field.
|
||||||
|
func RemotePortNEQ(v int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldNEQ(FieldRemotePort, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemotePortIn applies the In predicate on the "remote_port" field.
|
||||||
|
func RemotePortIn(vs ...int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldIn(FieldRemotePort, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemotePortNotIn applies the NotIn predicate on the "remote_port" field.
|
||||||
|
func RemotePortNotIn(vs ...int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldNotIn(FieldRemotePort, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemotePortGT applies the GT predicate on the "remote_port" field.
|
||||||
|
func RemotePortGT(v int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldGT(FieldRemotePort, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemotePortGTE applies the GTE predicate on the "remote_port" field.
|
||||||
|
func RemotePortGTE(v int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldGTE(FieldRemotePort, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemotePortLT applies the LT predicate on the "remote_port" field.
|
||||||
|
func RemotePortLT(v int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldLT(FieldRemotePort, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemotePortLTE applies the LTE predicate on the "remote_port" field.
|
||||||
|
func RemotePortLTE(v int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldLTE(FieldRemotePort, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusEQ applies the EQ predicate on the "status" field.
|
||||||
|
func StatusEQ(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEQ(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusNEQ applies the NEQ predicate on the "status" field.
|
||||||
|
func StatusNEQ(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldNEQ(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusIn applies the In predicate on the "status" field.
|
||||||
|
func StatusIn(vs ...string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldIn(FieldStatus, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusNotIn applies the NotIn predicate on the "status" field.
|
||||||
|
func StatusNotIn(vs ...string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldNotIn(FieldStatus, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusGT applies the GT predicate on the "status" field.
|
||||||
|
func StatusGT(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldGT(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusGTE applies the GTE predicate on the "status" field.
|
||||||
|
func StatusGTE(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldGTE(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusLT applies the LT predicate on the "status" field.
|
||||||
|
func StatusLT(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldLT(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusLTE applies the LTE predicate on the "status" field.
|
||||||
|
func StatusLTE(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldLTE(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusContains applies the Contains predicate on the "status" field.
|
||||||
|
func StatusContains(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldContains(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusHasPrefix applies the HasPrefix predicate on the "status" field.
|
||||||
|
func StatusHasPrefix(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldHasPrefix(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusHasSuffix applies the HasSuffix predicate on the "status" field.
|
||||||
|
func StatusHasSuffix(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldHasSuffix(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusEqualFold applies the EqualFold predicate on the "status" field.
|
||||||
|
func StatusEqualFold(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEqualFold(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusContainsFold applies the ContainsFold predicate on the "status" field.
|
||||||
|
func StatusContainsFold(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldContainsFold(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CustomDomainsEQ applies the EQ predicate on the "custom_domains" field.
|
||||||
|
func CustomDomainsEQ(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEQ(FieldCustomDomains, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CustomDomainsNEQ applies the NEQ predicate on the "custom_domains" field.
|
||||||
|
func CustomDomainsNEQ(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldNEQ(FieldCustomDomains, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CustomDomainsIn applies the In predicate on the "custom_domains" field.
|
||||||
|
func CustomDomainsIn(vs ...string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldIn(FieldCustomDomains, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CustomDomainsNotIn applies the NotIn predicate on the "custom_domains" field.
|
||||||
|
func CustomDomainsNotIn(vs ...string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldNotIn(FieldCustomDomains, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CustomDomainsGT applies the GT predicate on the "custom_domains" field.
|
||||||
|
func CustomDomainsGT(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldGT(FieldCustomDomains, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CustomDomainsGTE applies the GTE predicate on the "custom_domains" field.
|
||||||
|
func CustomDomainsGTE(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldGTE(FieldCustomDomains, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CustomDomainsLT applies the LT predicate on the "custom_domains" field.
|
||||||
|
func CustomDomainsLT(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldLT(FieldCustomDomains, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CustomDomainsLTE applies the LTE predicate on the "custom_domains" field.
|
||||||
|
func CustomDomainsLTE(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldLTE(FieldCustomDomains, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CustomDomainsContains applies the Contains predicate on the "custom_domains" field.
|
||||||
|
func CustomDomainsContains(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldContains(FieldCustomDomains, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CustomDomainsHasPrefix applies the HasPrefix predicate on the "custom_domains" field.
|
||||||
|
func CustomDomainsHasPrefix(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldHasPrefix(FieldCustomDomains, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CustomDomainsHasSuffix applies the HasSuffix predicate on the "custom_domains" field.
|
||||||
|
func CustomDomainsHasSuffix(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldHasSuffix(FieldCustomDomains, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CustomDomainsEqualFold applies the EqualFold predicate on the "custom_domains" field.
|
||||||
|
func CustomDomainsEqualFold(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEqualFold(FieldCustomDomains, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CustomDomainsContainsFold applies the ContainsFold predicate on the "custom_domains" field.
|
||||||
|
func CustomDomainsContainsFold(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldContainsFold(FieldCustomDomains, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataEQ applies the EQ predicate on the "metadata" field.
|
||||||
|
func MetadataEQ(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEQ(FieldMetadata, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataNEQ applies the NEQ predicate on the "metadata" field.
|
||||||
|
func MetadataNEQ(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldNEQ(FieldMetadata, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataIn applies the In predicate on the "metadata" field.
|
||||||
|
func MetadataIn(vs ...string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldIn(FieldMetadata, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataNotIn applies the NotIn predicate on the "metadata" field.
|
||||||
|
func MetadataNotIn(vs ...string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldNotIn(FieldMetadata, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataGT applies the GT predicate on the "metadata" field.
|
||||||
|
func MetadataGT(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldGT(FieldMetadata, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataGTE applies the GTE predicate on the "metadata" field.
|
||||||
|
func MetadataGTE(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldGTE(FieldMetadata, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataLT applies the LT predicate on the "metadata" field.
|
||||||
|
func MetadataLT(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldLT(FieldMetadata, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataLTE applies the LTE predicate on the "metadata" field.
|
||||||
|
func MetadataLTE(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldLTE(FieldMetadata, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataContains applies the Contains predicate on the "metadata" field.
|
||||||
|
func MetadataContains(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldContains(FieldMetadata, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataHasPrefix applies the HasPrefix predicate on the "metadata" field.
|
||||||
|
func MetadataHasPrefix(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldHasPrefix(FieldMetadata, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataHasSuffix applies the HasSuffix predicate on the "metadata" field.
|
||||||
|
func MetadataHasSuffix(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldHasSuffix(FieldMetadata, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataEqualFold applies the EqualFold predicate on the "metadata" field.
|
||||||
|
func MetadataEqualFold(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEqualFold(FieldMetadata, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MetadataContainsFold applies the ContainsFold predicate on the "metadata" field.
|
||||||
|
func MetadataContainsFold(v string) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldContainsFold(FieldMetadata, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClientIDEQ applies the EQ predicate on the "client_id" field.
|
||||||
|
func ClientIDEQ(v int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEQ(FieldClientID, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClientIDNEQ applies the NEQ predicate on the "client_id" field.
|
||||||
|
func ClientIDNEQ(v int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldNEQ(FieldClientID, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClientIDIn applies the In predicate on the "client_id" field.
|
||||||
|
func ClientIDIn(vs ...int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldIn(FieldClientID, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClientIDNotIn applies the NotIn predicate on the "client_id" field.
|
||||||
|
func ClientIDNotIn(vs ...int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldNotIn(FieldClientID, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClientIDGT applies the GT predicate on the "client_id" field.
|
||||||
|
func ClientIDGT(v int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldGT(FieldClientID, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClientIDGTE applies the GTE predicate on the "client_id" field.
|
||||||
|
func ClientIDGTE(v int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldGTE(FieldClientID, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClientIDLT applies the LT predicate on the "client_id" field.
|
||||||
|
func ClientIDLT(v int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldLT(FieldClientID, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClientIDLTE applies the LTE predicate on the "client_id" field.
|
||||||
|
func ClientIDLTE(v int) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldLTE(FieldClientID, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||||
|
func CreatedAtEQ(v time.Time) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEQ(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
|
||||||
|
func CreatedAtNEQ(v time.Time) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldNEQ(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||||
|
func CreatedAtIn(vs ...time.Time) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldIn(FieldCreatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||||
|
func CreatedAtNotIn(vs ...time.Time) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldNotIn(FieldCreatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtGT applies the GT predicate on the "created_at" field.
|
||||||
|
func CreatedAtGT(v time.Time) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldGT(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
|
||||||
|
func CreatedAtGTE(v time.Time) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldGTE(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtLT applies the LT predicate on the "created_at" field.
|
||||||
|
func CreatedAtLT(v time.Time) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldLT(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
|
||||||
|
func CreatedAtLTE(v time.Time) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldLTE(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtEQ(v time.Time) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldEQ(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtNEQ(v time.Time) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldNEQ(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtIn(vs ...time.Time) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldIn(FieldUpdatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtNotIn(vs ...time.Time) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldNotIn(FieldUpdatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtGT(v time.Time) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldGT(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtGTE(v time.Time) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldGTE(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtLT(v time.Time) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldLT(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtLTE(v time.Time) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.FieldLTE(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// And groups predicates with the AND operator between them.
|
||||||
|
func And(predicates ...predicate.Proxy) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.AndPredicates(predicates...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Or groups predicates with the OR operator between them.
|
||||||
|
func Or(predicates ...predicate.Proxy) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.OrPredicates(predicates...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not applies the not operator on the given predicate.
|
||||||
|
func Not(p predicate.Proxy) predicate.Proxy {
|
||||||
|
return predicate.Proxy(sql.NotPredicates(p))
|
||||||
|
}
|
||||||
@@ -0,0 +1,428 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/proxy"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ProxyCreate is the builder for creating a Proxy entity.
|
||||||
|
type ProxyCreate struct {
|
||||||
|
config
|
||||||
|
mutation *ProxyMutation
|
||||||
|
hooks []Hook
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetName sets the "name" field.
|
||||||
|
func (_c *ProxyCreate) SetName(v string) *ProxyCreate {
|
||||||
|
_c.mutation.SetName(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetProxyType sets the "proxy_type" field.
|
||||||
|
func (_c *ProxyCreate) SetProxyType(v string) *ProxyCreate {
|
||||||
|
_c.mutation.SetProxyType(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableProxyType sets the "proxy_type" field if the given value is not nil.
|
||||||
|
func (_c *ProxyCreate) SetNillableProxyType(v *string) *ProxyCreate {
|
||||||
|
if v != nil {
|
||||||
|
_c.SetProxyType(*v)
|
||||||
|
}
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetLocalIP sets the "local_ip" field.
|
||||||
|
func (_c *ProxyCreate) SetLocalIP(v string) *ProxyCreate {
|
||||||
|
_c.mutation.SetLocalIP(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableLocalIP sets the "local_ip" field if the given value is not nil.
|
||||||
|
func (_c *ProxyCreate) SetNillableLocalIP(v *string) *ProxyCreate {
|
||||||
|
if v != nil {
|
||||||
|
_c.SetLocalIP(*v)
|
||||||
|
}
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetLocalPort sets the "local_port" field.
|
||||||
|
func (_c *ProxyCreate) SetLocalPort(v int) *ProxyCreate {
|
||||||
|
_c.mutation.SetLocalPort(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRemotePort sets the "remote_port" field.
|
||||||
|
func (_c *ProxyCreate) SetRemotePort(v int) *ProxyCreate {
|
||||||
|
_c.mutation.SetRemotePort(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableRemotePort sets the "remote_port" field if the given value is not nil.
|
||||||
|
func (_c *ProxyCreate) SetNillableRemotePort(v *int) *ProxyCreate {
|
||||||
|
if v != nil {
|
||||||
|
_c.SetRemotePort(*v)
|
||||||
|
}
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetStatus sets the "status" field.
|
||||||
|
func (_c *ProxyCreate) SetStatus(v string) *ProxyCreate {
|
||||||
|
_c.mutation.SetStatus(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
||||||
|
func (_c *ProxyCreate) SetNillableStatus(v *string) *ProxyCreate {
|
||||||
|
if v != nil {
|
||||||
|
_c.SetStatus(*v)
|
||||||
|
}
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCustomDomains sets the "custom_domains" field.
|
||||||
|
func (_c *ProxyCreate) SetCustomDomains(v string) *ProxyCreate {
|
||||||
|
_c.mutation.SetCustomDomains(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableCustomDomains sets the "custom_domains" field if the given value is not nil.
|
||||||
|
func (_c *ProxyCreate) SetNillableCustomDomains(v *string) *ProxyCreate {
|
||||||
|
if v != nil {
|
||||||
|
_c.SetCustomDomains(*v)
|
||||||
|
}
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetMetadata sets the "metadata" field.
|
||||||
|
func (_c *ProxyCreate) SetMetadata(v string) *ProxyCreate {
|
||||||
|
_c.mutation.SetMetadata(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableMetadata sets the "metadata" field if the given value is not nil.
|
||||||
|
func (_c *ProxyCreate) SetNillableMetadata(v *string) *ProxyCreate {
|
||||||
|
if v != nil {
|
||||||
|
_c.SetMetadata(*v)
|
||||||
|
}
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetClientID sets the "client_id" field.
|
||||||
|
func (_c *ProxyCreate) SetClientID(v int) *ProxyCreate {
|
||||||
|
_c.mutation.SetClientID(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableClientID sets the "client_id" field if the given value is not nil.
|
||||||
|
func (_c *ProxyCreate) SetNillableClientID(v *int) *ProxyCreate {
|
||||||
|
if v != nil {
|
||||||
|
_c.SetClientID(*v)
|
||||||
|
}
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCreatedAt sets the "created_at" field.
|
||||||
|
func (_c *ProxyCreate) SetCreatedAt(v time.Time) *ProxyCreate {
|
||||||
|
_c.mutation.SetCreatedAt(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||||
|
func (_c *ProxyCreate) SetNillableCreatedAt(v *time.Time) *ProxyCreate {
|
||||||
|
if v != nil {
|
||||||
|
_c.SetCreatedAt(*v)
|
||||||
|
}
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUpdatedAt sets the "updated_at" field.
|
||||||
|
func (_c *ProxyCreate) SetUpdatedAt(v time.Time) *ProxyCreate {
|
||||||
|
_c.mutation.SetUpdatedAt(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||||
|
func (_c *ProxyCreate) SetNillableUpdatedAt(v *time.Time) *ProxyCreate {
|
||||||
|
if v != nil {
|
||||||
|
_c.SetUpdatedAt(*v)
|
||||||
|
}
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the ProxyMutation object of the builder.
|
||||||
|
func (_c *ProxyCreate) Mutation() *ProxyMutation {
|
||||||
|
return _c.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save creates the Proxy in the database.
|
||||||
|
func (_c *ProxyCreate) Save(ctx context.Context) (*Proxy, error) {
|
||||||
|
_c.defaults()
|
||||||
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX calls Save and panics if Save returns an error.
|
||||||
|
func (_c *ProxyCreate) SaveX(ctx context.Context) *Proxy {
|
||||||
|
v, err := _c.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (_c *ProxyCreate) Exec(ctx context.Context) error {
|
||||||
|
_, err := _c.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_c *ProxyCreate) ExecX(ctx context.Context) {
|
||||||
|
if err := _c.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// defaults sets the default values of the builder before save.
|
||||||
|
func (_c *ProxyCreate) defaults() {
|
||||||
|
if _, ok := _c.mutation.ProxyType(); !ok {
|
||||||
|
v := proxy.DefaultProxyType
|
||||||
|
_c.mutation.SetProxyType(v)
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.LocalIP(); !ok {
|
||||||
|
v := proxy.DefaultLocalIP
|
||||||
|
_c.mutation.SetLocalIP(v)
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.RemotePort(); !ok {
|
||||||
|
v := proxy.DefaultRemotePort
|
||||||
|
_c.mutation.SetRemotePort(v)
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.Status(); !ok {
|
||||||
|
v := proxy.DefaultStatus
|
||||||
|
_c.mutation.SetStatus(v)
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.CustomDomains(); !ok {
|
||||||
|
v := proxy.DefaultCustomDomains
|
||||||
|
_c.mutation.SetCustomDomains(v)
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.Metadata(); !ok {
|
||||||
|
v := proxy.DefaultMetadata
|
||||||
|
_c.mutation.SetMetadata(v)
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.ClientID(); !ok {
|
||||||
|
v := proxy.DefaultClientID
|
||||||
|
_c.mutation.SetClientID(v)
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||||
|
v := proxy.DefaultCreatedAt()
|
||||||
|
_c.mutation.SetCreatedAt(v)
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||||
|
v := proxy.DefaultUpdatedAt()
|
||||||
|
_c.mutation.SetUpdatedAt(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check runs all checks and user-defined validators on the builder.
|
||||||
|
func (_c *ProxyCreate) check() error {
|
||||||
|
if _, ok := _c.mutation.Name(); !ok {
|
||||||
|
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Proxy.name"`)}
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.ProxyType(); !ok {
|
||||||
|
return &ValidationError{Name: "proxy_type", err: errors.New(`ent: missing required field "Proxy.proxy_type"`)}
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.LocalIP(); !ok {
|
||||||
|
return &ValidationError{Name: "local_ip", err: errors.New(`ent: missing required field "Proxy.local_ip"`)}
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.LocalPort(); !ok {
|
||||||
|
return &ValidationError{Name: "local_port", err: errors.New(`ent: missing required field "Proxy.local_port"`)}
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.RemotePort(); !ok {
|
||||||
|
return &ValidationError{Name: "remote_port", err: errors.New(`ent: missing required field "Proxy.remote_port"`)}
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.Status(); !ok {
|
||||||
|
return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Proxy.status"`)}
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.CustomDomains(); !ok {
|
||||||
|
return &ValidationError{Name: "custom_domains", err: errors.New(`ent: missing required field "Proxy.custom_domains"`)}
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.Metadata(); !ok {
|
||||||
|
return &ValidationError{Name: "metadata", err: errors.New(`ent: missing required field "Proxy.metadata"`)}
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.ClientID(); !ok {
|
||||||
|
return &ValidationError{Name: "client_id", err: errors.New(`ent: missing required field "Proxy.client_id"`)}
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||||
|
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Proxy.created_at"`)}
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||||
|
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Proxy.updated_at"`)}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_c *ProxyCreate) sqlSave(ctx context.Context) (*Proxy, error) {
|
||||||
|
if err := _c.check(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_node, _spec := _c.createSpec()
|
||||||
|
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||||
|
if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
id := _spec.ID.Value.(int64)
|
||||||
|
_node.ID = int(id)
|
||||||
|
_c.mutation.id = &_node.ID
|
||||||
|
_c.mutation.done = true
|
||||||
|
return _node, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_c *ProxyCreate) createSpec() (*Proxy, *sqlgraph.CreateSpec) {
|
||||||
|
var (
|
||||||
|
_node = &Proxy{config: _c.config}
|
||||||
|
_spec = sqlgraph.NewCreateSpec(proxy.Table, sqlgraph.NewFieldSpec(proxy.FieldID, field.TypeInt))
|
||||||
|
)
|
||||||
|
if value, ok := _c.mutation.Name(); ok {
|
||||||
|
_spec.SetField(proxy.FieldName, field.TypeString, value)
|
||||||
|
_node.Name = value
|
||||||
|
}
|
||||||
|
if value, ok := _c.mutation.ProxyType(); ok {
|
||||||
|
_spec.SetField(proxy.FieldProxyType, field.TypeString, value)
|
||||||
|
_node.ProxyType = value
|
||||||
|
}
|
||||||
|
if value, ok := _c.mutation.LocalIP(); ok {
|
||||||
|
_spec.SetField(proxy.FieldLocalIP, field.TypeString, value)
|
||||||
|
_node.LocalIP = value
|
||||||
|
}
|
||||||
|
if value, ok := _c.mutation.LocalPort(); ok {
|
||||||
|
_spec.SetField(proxy.FieldLocalPort, field.TypeInt, value)
|
||||||
|
_node.LocalPort = value
|
||||||
|
}
|
||||||
|
if value, ok := _c.mutation.RemotePort(); ok {
|
||||||
|
_spec.SetField(proxy.FieldRemotePort, field.TypeInt, value)
|
||||||
|
_node.RemotePort = value
|
||||||
|
}
|
||||||
|
if value, ok := _c.mutation.Status(); ok {
|
||||||
|
_spec.SetField(proxy.FieldStatus, field.TypeString, value)
|
||||||
|
_node.Status = value
|
||||||
|
}
|
||||||
|
if value, ok := _c.mutation.CustomDomains(); ok {
|
||||||
|
_spec.SetField(proxy.FieldCustomDomains, field.TypeString, value)
|
||||||
|
_node.CustomDomains = value
|
||||||
|
}
|
||||||
|
if value, ok := _c.mutation.Metadata(); ok {
|
||||||
|
_spec.SetField(proxy.FieldMetadata, field.TypeString, value)
|
||||||
|
_node.Metadata = value
|
||||||
|
}
|
||||||
|
if value, ok := _c.mutation.ClientID(); ok {
|
||||||
|
_spec.SetField(proxy.FieldClientID, field.TypeInt, value)
|
||||||
|
_node.ClientID = value
|
||||||
|
}
|
||||||
|
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||||
|
_spec.SetField(proxy.FieldCreatedAt, field.TypeTime, value)
|
||||||
|
_node.CreatedAt = value
|
||||||
|
}
|
||||||
|
if value, ok := _c.mutation.UpdatedAt(); ok {
|
||||||
|
_spec.SetField(proxy.FieldUpdatedAt, field.TypeTime, value)
|
||||||
|
_node.UpdatedAt = value
|
||||||
|
}
|
||||||
|
return _node, _spec
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProxyCreateBulk is the builder for creating many Proxy entities in bulk.
|
||||||
|
type ProxyCreateBulk struct {
|
||||||
|
config
|
||||||
|
err error
|
||||||
|
builders []*ProxyCreate
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save creates the Proxy entities in the database.
|
||||||
|
func (_c *ProxyCreateBulk) Save(ctx context.Context) ([]*Proxy, error) {
|
||||||
|
if _c.err != nil {
|
||||||
|
return nil, _c.err
|
||||||
|
}
|
||||||
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||||
|
nodes := make([]*Proxy, len(_c.builders))
|
||||||
|
mutators := make([]Mutator, len(_c.builders))
|
||||||
|
for i := range _c.builders {
|
||||||
|
func(i int, root context.Context) {
|
||||||
|
builder := _c.builders[i]
|
||||||
|
builder.defaults()
|
||||||
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||||
|
mutation, ok := m.(*ProxyMutation)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||||
|
}
|
||||||
|
if err := builder.check(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
builder.mutation = mutation
|
||||||
|
var err error
|
||||||
|
nodes[i], specs[i] = builder.createSpec()
|
||||||
|
if i < len(mutators)-1 {
|
||||||
|
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||||
|
} else {
|
||||||
|
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||||
|
// Invoke the actual operation on the latest mutation in the chain.
|
||||||
|
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||||
|
if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
mutation.id = &nodes[i].ID
|
||||||
|
if specs[i].ID.Value != nil {
|
||||||
|
id := specs[i].ID.Value.(int64)
|
||||||
|
nodes[i].ID = int(id)
|
||||||
|
}
|
||||||
|
mutation.done = true
|
||||||
|
return nodes[i], nil
|
||||||
|
})
|
||||||
|
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||||
|
mut = builder.hooks[i](mut)
|
||||||
|
}
|
||||||
|
mutators[i] = mut
|
||||||
|
}(i, ctx)
|
||||||
|
}
|
||||||
|
if len(mutators) > 0 {
|
||||||
|
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (_c *ProxyCreateBulk) SaveX(ctx context.Context) []*Proxy {
|
||||||
|
v, err := _c.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (_c *ProxyCreateBulk) Exec(ctx context.Context) error {
|
||||||
|
_, err := _c.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_c *ProxyCreateBulk) ExecX(ctx context.Context) {
|
||||||
|
if err := _c.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/predicate"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/proxy"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ProxyDelete is the builder for deleting a Proxy entity.
|
||||||
|
type ProxyDelete struct {
|
||||||
|
config
|
||||||
|
hooks []Hook
|
||||||
|
mutation *ProxyMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the ProxyDelete builder.
|
||||||
|
func (_d *ProxyDelete) Where(ps ...predicate.Proxy) *ProxyDelete {
|
||||||
|
_d.mutation.Where(ps...)
|
||||||
|
return _d
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||||
|
func (_d *ProxyDelete) Exec(ctx context.Context) (int, error) {
|
||||||
|
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_d *ProxyDelete) ExecX(ctx context.Context) int {
|
||||||
|
n, err := _d.Exec(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_d *ProxyDelete) sqlExec(ctx context.Context) (int, error) {
|
||||||
|
_spec := sqlgraph.NewDeleteSpec(proxy.Table, sqlgraph.NewFieldSpec(proxy.FieldID, field.TypeInt))
|
||||||
|
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||||
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
_d.mutation.done = true
|
||||||
|
return affected, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProxyDeleteOne is the builder for deleting a single Proxy entity.
|
||||||
|
type ProxyDeleteOne struct {
|
||||||
|
_d *ProxyDelete
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the ProxyDelete builder.
|
||||||
|
func (_d *ProxyDeleteOne) Where(ps ...predicate.Proxy) *ProxyDeleteOne {
|
||||||
|
_d._d.mutation.Where(ps...)
|
||||||
|
return _d
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query.
|
||||||
|
func (_d *ProxyDeleteOne) Exec(ctx context.Context) error {
|
||||||
|
n, err := _d._d.Exec(ctx)
|
||||||
|
switch {
|
||||||
|
case err != nil:
|
||||||
|
return err
|
||||||
|
case n == 0:
|
||||||
|
return &NotFoundError{proxy.Label}
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_d *ProxyDeleteOne) ExecX(ctx context.Context) {
|
||||||
|
if err := _d.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,527 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"math"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/predicate"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/proxy"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ProxyQuery is the builder for querying Proxy entities.
|
||||||
|
type ProxyQuery struct {
|
||||||
|
config
|
||||||
|
ctx *QueryContext
|
||||||
|
order []proxy.OrderOption
|
||||||
|
inters []Interceptor
|
||||||
|
predicates []predicate.Proxy
|
||||||
|
// intermediate query (i.e. traversal path).
|
||||||
|
sql *sql.Selector
|
||||||
|
path func(context.Context) (*sql.Selector, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where adds a new predicate for the ProxyQuery builder.
|
||||||
|
func (_q *ProxyQuery) Where(ps ...predicate.Proxy) *ProxyQuery {
|
||||||
|
_q.predicates = append(_q.predicates, ps...)
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// Limit the number of records to be returned by this query.
|
||||||
|
func (_q *ProxyQuery) Limit(limit int) *ProxyQuery {
|
||||||
|
_q.ctx.Limit = &limit
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// Offset to start from.
|
||||||
|
func (_q *ProxyQuery) Offset(offset int) *ProxyQuery {
|
||||||
|
_q.ctx.Offset = &offset
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unique configures the query builder to filter duplicate records on query.
|
||||||
|
// By default, unique is set to true, and can be disabled using this method.
|
||||||
|
func (_q *ProxyQuery) Unique(unique bool) *ProxyQuery {
|
||||||
|
_q.ctx.Unique = &unique
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// Order specifies how the records should be ordered.
|
||||||
|
func (_q *ProxyQuery) Order(o ...proxy.OrderOption) *ProxyQuery {
|
||||||
|
_q.order = append(_q.order, o...)
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// First returns the first Proxy entity from the query.
|
||||||
|
// Returns a *NotFoundError when no Proxy was found.
|
||||||
|
func (_q *ProxyQuery) First(ctx context.Context) (*Proxy, error) {
|
||||||
|
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return nil, &NotFoundError{proxy.Label}
|
||||||
|
}
|
||||||
|
return nodes[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstX is like First, but panics if an error occurs.
|
||||||
|
func (_q *ProxyQuery) FirstX(ctx context.Context) *Proxy {
|
||||||
|
node, err := _q.First(ctx)
|
||||||
|
if err != nil && !IsNotFound(err) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstID returns the first Proxy ID from the query.
|
||||||
|
// Returns a *NotFoundError when no Proxy ID was found.
|
||||||
|
func (_q *ProxyQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||||
|
var ids []int
|
||||||
|
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(ids) == 0 {
|
||||||
|
err = &NotFoundError{proxy.Label}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return ids[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||||
|
func (_q *ProxyQuery) FirstIDX(ctx context.Context) int {
|
||||||
|
id, err := _q.FirstID(ctx)
|
||||||
|
if err != nil && !IsNotFound(err) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only returns a single Proxy entity found by the query, ensuring it only returns one.
|
||||||
|
// Returns a *NotSingularError when more than one Proxy entity is found.
|
||||||
|
// Returns a *NotFoundError when no Proxy entities are found.
|
||||||
|
func (_q *ProxyQuery) Only(ctx context.Context) (*Proxy, error) {
|
||||||
|
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
switch len(nodes) {
|
||||||
|
case 1:
|
||||||
|
return nodes[0], nil
|
||||||
|
case 0:
|
||||||
|
return nil, &NotFoundError{proxy.Label}
|
||||||
|
default:
|
||||||
|
return nil, &NotSingularError{proxy.Label}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyX is like Only, but panics if an error occurs.
|
||||||
|
func (_q *ProxyQuery) OnlyX(ctx context.Context) *Proxy {
|
||||||
|
node, err := _q.Only(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyID is like Only, but returns the only Proxy ID in the query.
|
||||||
|
// Returns a *NotSingularError when more than one Proxy ID is found.
|
||||||
|
// Returns a *NotFoundError when no entities are found.
|
||||||
|
func (_q *ProxyQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||||
|
var ids []int
|
||||||
|
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch len(ids) {
|
||||||
|
case 1:
|
||||||
|
id = ids[0]
|
||||||
|
case 0:
|
||||||
|
err = &NotFoundError{proxy.Label}
|
||||||
|
default:
|
||||||
|
err = &NotSingularError{proxy.Label}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||||
|
func (_q *ProxyQuery) OnlyIDX(ctx context.Context) int {
|
||||||
|
id, err := _q.OnlyID(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// All executes the query and returns a list of Proxies.
|
||||||
|
func (_q *ProxyQuery) All(ctx context.Context) ([]*Proxy, error) {
|
||||||
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||||
|
if err := _q.prepareQuery(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
qr := querierAll[[]*Proxy, *ProxyQuery]()
|
||||||
|
return withInterceptors[[]*Proxy](ctx, _q, qr, _q.inters)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AllX is like All, but panics if an error occurs.
|
||||||
|
func (_q *ProxyQuery) AllX(ctx context.Context) []*Proxy {
|
||||||
|
nodes, err := _q.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return nodes
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs executes the query and returns a list of Proxy IDs.
|
||||||
|
func (_q *ProxyQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||||
|
if _q.ctx.Unique == nil && _q.path != nil {
|
||||||
|
_q.Unique(true)
|
||||||
|
}
|
||||||
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||||
|
if err = _q.Select(proxy.FieldID).Scan(ctx, &ids); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ids, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDsX is like IDs, but panics if an error occurs.
|
||||||
|
func (_q *ProxyQuery) IDsX(ctx context.Context) []int {
|
||||||
|
ids, err := _q.IDs(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return ids
|
||||||
|
}
|
||||||
|
|
||||||
|
// Count returns the count of the given query.
|
||||||
|
func (_q *ProxyQuery) Count(ctx context.Context) (int, error) {
|
||||||
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||||
|
if err := _q.prepareQuery(ctx); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return withInterceptors[int](ctx, _q, querierCount[*ProxyQuery](), _q.inters)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountX is like Count, but panics if an error occurs.
|
||||||
|
func (_q *ProxyQuery) CountX(ctx context.Context) int {
|
||||||
|
count, err := _q.Count(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exist returns true if the query has elements in the graph.
|
||||||
|
func (_q *ProxyQuery) Exist(ctx context.Context) (bool, error) {
|
||||||
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||||
|
switch _, err := _q.FirstID(ctx); {
|
||||||
|
case IsNotFound(err):
|
||||||
|
return false, nil
|
||||||
|
case err != nil:
|
||||||
|
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||||
|
default:
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExistX is like Exist, but panics if an error occurs.
|
||||||
|
func (_q *ProxyQuery) ExistX(ctx context.Context) bool {
|
||||||
|
exist, err := _q.Exist(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return exist
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clone returns a duplicate of the ProxyQuery builder, including all associated steps. It can be
|
||||||
|
// used to prepare common query builders and use them differently after the clone is made.
|
||||||
|
func (_q *ProxyQuery) Clone() *ProxyQuery {
|
||||||
|
if _q == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &ProxyQuery{
|
||||||
|
config: _q.config,
|
||||||
|
ctx: _q.ctx.Clone(),
|
||||||
|
order: append([]proxy.OrderOption{}, _q.order...),
|
||||||
|
inters: append([]Interceptor{}, _q.inters...),
|
||||||
|
predicates: append([]predicate.Proxy{}, _q.predicates...),
|
||||||
|
// clone intermediate query.
|
||||||
|
sql: _q.sql.Clone(),
|
||||||
|
path: _q.path,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GroupBy is used to group vertices by one or more fields/columns.
|
||||||
|
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
//
|
||||||
|
// var v []struct {
|
||||||
|
// Name string `json:"name,omitempty"`
|
||||||
|
// Count int `json:"count,omitempty"`
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// client.Proxy.Query().
|
||||||
|
// GroupBy(proxy.FieldName).
|
||||||
|
// Aggregate(ent.Count()).
|
||||||
|
// Scan(ctx, &v)
|
||||||
|
func (_q *ProxyQuery) GroupBy(field string, fields ...string) *ProxyGroupBy {
|
||||||
|
_q.ctx.Fields = append([]string{field}, fields...)
|
||||||
|
grbuild := &ProxyGroupBy{build: _q}
|
||||||
|
grbuild.flds = &_q.ctx.Fields
|
||||||
|
grbuild.label = proxy.Label
|
||||||
|
grbuild.scan = grbuild.Scan
|
||||||
|
return grbuild
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select allows the selection one or more fields/columns for the given query,
|
||||||
|
// instead of selecting all fields in the entity.
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
//
|
||||||
|
// var v []struct {
|
||||||
|
// Name string `json:"name,omitempty"`
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// client.Proxy.Query().
|
||||||
|
// Select(proxy.FieldName).
|
||||||
|
// Scan(ctx, &v)
|
||||||
|
func (_q *ProxyQuery) Select(fields ...string) *ProxySelect {
|
||||||
|
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||||
|
sbuild := &ProxySelect{ProxyQuery: _q}
|
||||||
|
sbuild.label = proxy.Label
|
||||||
|
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||||
|
return sbuild
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate returns a ProxySelect configured with the given aggregations.
|
||||||
|
func (_q *ProxyQuery) Aggregate(fns ...AggregateFunc) *ProxySelect {
|
||||||
|
return _q.Select().Aggregate(fns...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *ProxyQuery) prepareQuery(ctx context.Context) error {
|
||||||
|
for _, inter := range _q.inters {
|
||||||
|
if inter == nil {
|
||||||
|
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||||
|
}
|
||||||
|
if trv, ok := inter.(Traverser); ok {
|
||||||
|
if err := trv.Traverse(ctx, _q); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, f := range _q.ctx.Fields {
|
||||||
|
if !proxy.ValidColumn(f) {
|
||||||
|
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _q.path != nil {
|
||||||
|
prev, err := _q.path(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_q.sql = prev
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *ProxyQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Proxy, error) {
|
||||||
|
var (
|
||||||
|
nodes = []*Proxy{}
|
||||||
|
_spec = _q.querySpec()
|
||||||
|
)
|
||||||
|
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||||
|
return (*Proxy).scanValues(nil, columns)
|
||||||
|
}
|
||||||
|
_spec.Assign = func(columns []string, values []any) error {
|
||||||
|
node := &Proxy{config: _q.config}
|
||||||
|
nodes = append(nodes, node)
|
||||||
|
return node.assignValues(columns, values)
|
||||||
|
}
|
||||||
|
for i := range hooks {
|
||||||
|
hooks[i](ctx, _spec)
|
||||||
|
}
|
||||||
|
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *ProxyQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
|
_spec := _q.querySpec()
|
||||||
|
_spec.Node.Columns = _q.ctx.Fields
|
||||||
|
if len(_q.ctx.Fields) > 0 {
|
||||||
|
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||||
|
}
|
||||||
|
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *ProxyQuery) querySpec() *sqlgraph.QuerySpec {
|
||||||
|
_spec := sqlgraph.NewQuerySpec(proxy.Table, proxy.Columns, sqlgraph.NewFieldSpec(proxy.FieldID, field.TypeInt))
|
||||||
|
_spec.From = _q.sql
|
||||||
|
if unique := _q.ctx.Unique; unique != nil {
|
||||||
|
_spec.Unique = *unique
|
||||||
|
} else if _q.path != nil {
|
||||||
|
_spec.Unique = true
|
||||||
|
}
|
||||||
|
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||||
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, proxy.FieldID)
|
||||||
|
for i := range fields {
|
||||||
|
if fields[i] != proxy.FieldID {
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ps := _q.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if limit := _q.ctx.Limit; limit != nil {
|
||||||
|
_spec.Limit = *limit
|
||||||
|
}
|
||||||
|
if offset := _q.ctx.Offset; offset != nil {
|
||||||
|
_spec.Offset = *offset
|
||||||
|
}
|
||||||
|
if ps := _q.order; len(ps) > 0 {
|
||||||
|
_spec.Order = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _spec
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *ProxyQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||||
|
builder := sql.Dialect(_q.driver.Dialect())
|
||||||
|
t1 := builder.Table(proxy.Table)
|
||||||
|
columns := _q.ctx.Fields
|
||||||
|
if len(columns) == 0 {
|
||||||
|
columns = proxy.Columns
|
||||||
|
}
|
||||||
|
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||||
|
if _q.sql != nil {
|
||||||
|
selector = _q.sql
|
||||||
|
selector.Select(selector.Columns(columns...)...)
|
||||||
|
}
|
||||||
|
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||||
|
selector.Distinct()
|
||||||
|
}
|
||||||
|
for _, p := range _q.predicates {
|
||||||
|
p(selector)
|
||||||
|
}
|
||||||
|
for _, p := range _q.order {
|
||||||
|
p(selector)
|
||||||
|
}
|
||||||
|
if offset := _q.ctx.Offset; offset != nil {
|
||||||
|
// limit is mandatory for offset clause. We start
|
||||||
|
// with default value, and override it below if needed.
|
||||||
|
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||||
|
}
|
||||||
|
if limit := _q.ctx.Limit; limit != nil {
|
||||||
|
selector.Limit(*limit)
|
||||||
|
}
|
||||||
|
return selector
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProxyGroupBy is the group-by builder for Proxy entities.
|
||||||
|
type ProxyGroupBy struct {
|
||||||
|
selector
|
||||||
|
build *ProxyQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the group-by query.
|
||||||
|
func (_g *ProxyGroupBy) Aggregate(fns ...AggregateFunc) *ProxyGroupBy {
|
||||||
|
_g.fns = append(_g.fns, fns...)
|
||||||
|
return _g
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (_g *ProxyGroupBy) Scan(ctx context.Context, v any) error {
|
||||||
|
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||||
|
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return scanWithInterceptors[*ProxyQuery, *ProxyGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_g *ProxyGroupBy) sqlScan(ctx context.Context, root *ProxyQuery, v any) error {
|
||||||
|
selector := root.sqlQuery(ctx).Select()
|
||||||
|
aggregation := make([]string, 0, len(_g.fns))
|
||||||
|
for _, fn := range _g.fns {
|
||||||
|
aggregation = append(aggregation, fn(selector))
|
||||||
|
}
|
||||||
|
if len(selector.SelectedColumns()) == 0 {
|
||||||
|
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||||
|
for _, f := range *_g.flds {
|
||||||
|
columns = append(columns, selector.C(f))
|
||||||
|
}
|
||||||
|
columns = append(columns, aggregation...)
|
||||||
|
selector.Select(columns...)
|
||||||
|
}
|
||||||
|
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||||
|
if err := selector.Err(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
rows := &sql.Rows{}
|
||||||
|
query, args := selector.Query()
|
||||||
|
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
return sql.ScanSlice(rows, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProxySelect is the builder for selecting fields of Proxy entities.
|
||||||
|
type ProxySelect struct {
|
||||||
|
*ProxyQuery
|
||||||
|
selector
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the selector query.
|
||||||
|
func (_s *ProxySelect) Aggregate(fns ...AggregateFunc) *ProxySelect {
|
||||||
|
_s.fns = append(_s.fns, fns...)
|
||||||
|
return _s
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (_s *ProxySelect) Scan(ctx context.Context, v any) error {
|
||||||
|
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||||
|
if err := _s.prepareQuery(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return scanWithInterceptors[*ProxyQuery, *ProxySelect](ctx, _s.ProxyQuery, _s, _s.inters, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_s *ProxySelect) sqlScan(ctx context.Context, root *ProxyQuery, v any) error {
|
||||||
|
selector := root.sqlQuery(ctx)
|
||||||
|
aggregation := make([]string, 0, len(_s.fns))
|
||||||
|
for _, fn := range _s.fns {
|
||||||
|
aggregation = append(aggregation, fn(selector))
|
||||||
|
}
|
||||||
|
switch n := len(*_s.selector.flds); {
|
||||||
|
case n == 0 && len(aggregation) > 0:
|
||||||
|
selector.Select(aggregation...)
|
||||||
|
case n != 0 && len(aggregation) > 0:
|
||||||
|
selector.AppendSelect(aggregation...)
|
||||||
|
}
|
||||||
|
rows := &sql.Rows{}
|
||||||
|
query, args := selector.Query()
|
||||||
|
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
return sql.ScanSlice(rows, v)
|
||||||
|
}
|
||||||
@@ -0,0 +1,612 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/predicate"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/proxy"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ProxyUpdate is the builder for updating Proxy entities.
|
||||||
|
type ProxyUpdate struct {
|
||||||
|
config
|
||||||
|
hooks []Hook
|
||||||
|
mutation *ProxyMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the ProxyUpdate builder.
|
||||||
|
func (_u *ProxyUpdate) Where(ps ...predicate.Proxy) *ProxyUpdate {
|
||||||
|
_u.mutation.Where(ps...)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetName sets the "name" field.
|
||||||
|
func (_u *ProxyUpdate) SetName(v string) *ProxyUpdate {
|
||||||
|
_u.mutation.SetName(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableName sets the "name" field if the given value is not nil.
|
||||||
|
func (_u *ProxyUpdate) SetNillableName(v *string) *ProxyUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetName(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetProxyType sets the "proxy_type" field.
|
||||||
|
func (_u *ProxyUpdate) SetProxyType(v string) *ProxyUpdate {
|
||||||
|
_u.mutation.SetProxyType(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableProxyType sets the "proxy_type" field if the given value is not nil.
|
||||||
|
func (_u *ProxyUpdate) SetNillableProxyType(v *string) *ProxyUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetProxyType(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetLocalIP sets the "local_ip" field.
|
||||||
|
func (_u *ProxyUpdate) SetLocalIP(v string) *ProxyUpdate {
|
||||||
|
_u.mutation.SetLocalIP(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableLocalIP sets the "local_ip" field if the given value is not nil.
|
||||||
|
func (_u *ProxyUpdate) SetNillableLocalIP(v *string) *ProxyUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetLocalIP(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetLocalPort sets the "local_port" field.
|
||||||
|
func (_u *ProxyUpdate) SetLocalPort(v int) *ProxyUpdate {
|
||||||
|
_u.mutation.ResetLocalPort()
|
||||||
|
_u.mutation.SetLocalPort(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableLocalPort sets the "local_port" field if the given value is not nil.
|
||||||
|
func (_u *ProxyUpdate) SetNillableLocalPort(v *int) *ProxyUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetLocalPort(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddLocalPort adds value to the "local_port" field.
|
||||||
|
func (_u *ProxyUpdate) AddLocalPort(v int) *ProxyUpdate {
|
||||||
|
_u.mutation.AddLocalPort(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRemotePort sets the "remote_port" field.
|
||||||
|
func (_u *ProxyUpdate) SetRemotePort(v int) *ProxyUpdate {
|
||||||
|
_u.mutation.ResetRemotePort()
|
||||||
|
_u.mutation.SetRemotePort(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableRemotePort sets the "remote_port" field if the given value is not nil.
|
||||||
|
func (_u *ProxyUpdate) SetNillableRemotePort(v *int) *ProxyUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetRemotePort(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddRemotePort adds value to the "remote_port" field.
|
||||||
|
func (_u *ProxyUpdate) AddRemotePort(v int) *ProxyUpdate {
|
||||||
|
_u.mutation.AddRemotePort(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetStatus sets the "status" field.
|
||||||
|
func (_u *ProxyUpdate) SetStatus(v string) *ProxyUpdate {
|
||||||
|
_u.mutation.SetStatus(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
||||||
|
func (_u *ProxyUpdate) SetNillableStatus(v *string) *ProxyUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetStatus(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCustomDomains sets the "custom_domains" field.
|
||||||
|
func (_u *ProxyUpdate) SetCustomDomains(v string) *ProxyUpdate {
|
||||||
|
_u.mutation.SetCustomDomains(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableCustomDomains sets the "custom_domains" field if the given value is not nil.
|
||||||
|
func (_u *ProxyUpdate) SetNillableCustomDomains(v *string) *ProxyUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetCustomDomains(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetMetadata sets the "metadata" field.
|
||||||
|
func (_u *ProxyUpdate) SetMetadata(v string) *ProxyUpdate {
|
||||||
|
_u.mutation.SetMetadata(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableMetadata sets the "metadata" field if the given value is not nil.
|
||||||
|
func (_u *ProxyUpdate) SetNillableMetadata(v *string) *ProxyUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetMetadata(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetClientID sets the "client_id" field.
|
||||||
|
func (_u *ProxyUpdate) SetClientID(v int) *ProxyUpdate {
|
||||||
|
_u.mutation.ResetClientID()
|
||||||
|
_u.mutation.SetClientID(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableClientID sets the "client_id" field if the given value is not nil.
|
||||||
|
func (_u *ProxyUpdate) SetNillableClientID(v *int) *ProxyUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetClientID(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddClientID adds value to the "client_id" field.
|
||||||
|
func (_u *ProxyUpdate) AddClientID(v int) *ProxyUpdate {
|
||||||
|
_u.mutation.AddClientID(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCreatedAt sets the "created_at" field.
|
||||||
|
func (_u *ProxyUpdate) SetCreatedAt(v time.Time) *ProxyUpdate {
|
||||||
|
_u.mutation.SetCreatedAt(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||||
|
func (_u *ProxyUpdate) SetNillableCreatedAt(v *time.Time) *ProxyUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetCreatedAt(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUpdatedAt sets the "updated_at" field.
|
||||||
|
func (_u *ProxyUpdate) SetUpdatedAt(v time.Time) *ProxyUpdate {
|
||||||
|
_u.mutation.SetUpdatedAt(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the ProxyMutation object of the builder.
|
||||||
|
func (_u *ProxyUpdate) Mutation() *ProxyMutation {
|
||||||
|
return _u.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||||
|
func (_u *ProxyUpdate) Save(ctx context.Context) (int, error) {
|
||||||
|
_u.defaults()
|
||||||
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (_u *ProxyUpdate) SaveX(ctx context.Context) int {
|
||||||
|
affected, err := _u.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return affected
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (_u *ProxyUpdate) Exec(ctx context.Context) error {
|
||||||
|
_, err := _u.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_u *ProxyUpdate) ExecX(ctx context.Context) {
|
||||||
|
if err := _u.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// defaults sets the default values of the builder before save.
|
||||||
|
func (_u *ProxyUpdate) defaults() {
|
||||||
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||||
|
v := proxy.UpdateDefaultUpdatedAt()
|
||||||
|
_u.mutation.SetUpdatedAt(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_u *ProxyUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||||
|
_spec := sqlgraph.NewUpdateSpec(proxy.Table, proxy.Columns, sqlgraph.NewFieldSpec(proxy.FieldID, field.TypeInt))
|
||||||
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Name(); ok {
|
||||||
|
_spec.SetField(proxy.FieldName, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.ProxyType(); ok {
|
||||||
|
_spec.SetField(proxy.FieldProxyType, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.LocalIP(); ok {
|
||||||
|
_spec.SetField(proxy.FieldLocalIP, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.LocalPort(); ok {
|
||||||
|
_spec.SetField(proxy.FieldLocalPort, field.TypeInt, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.AddedLocalPort(); ok {
|
||||||
|
_spec.AddField(proxy.FieldLocalPort, field.TypeInt, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.RemotePort(); ok {
|
||||||
|
_spec.SetField(proxy.FieldRemotePort, field.TypeInt, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.AddedRemotePort(); ok {
|
||||||
|
_spec.AddField(proxy.FieldRemotePort, field.TypeInt, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Status(); ok {
|
||||||
|
_spec.SetField(proxy.FieldStatus, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.CustomDomains(); ok {
|
||||||
|
_spec.SetField(proxy.FieldCustomDomains, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Metadata(); ok {
|
||||||
|
_spec.SetField(proxy.FieldMetadata, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.ClientID(); ok {
|
||||||
|
_spec.SetField(proxy.FieldClientID, field.TypeInt, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.AddedClientID(); ok {
|
||||||
|
_spec.AddField(proxy.FieldClientID, field.TypeInt, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
||||||
|
_spec.SetField(proxy.FieldCreatedAt, field.TypeTime, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||||
|
_spec.SetField(proxy.FieldUpdatedAt, field.TypeTime, value)
|
||||||
|
}
|
||||||
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||||
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
|
err = &NotFoundError{proxy.Label}
|
||||||
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
_u.mutation.done = true
|
||||||
|
return _node, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProxyUpdateOne is the builder for updating a single Proxy entity.
|
||||||
|
type ProxyUpdateOne struct {
|
||||||
|
config
|
||||||
|
fields []string
|
||||||
|
hooks []Hook
|
||||||
|
mutation *ProxyMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetName sets the "name" field.
|
||||||
|
func (_u *ProxyUpdateOne) SetName(v string) *ProxyUpdateOne {
|
||||||
|
_u.mutation.SetName(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableName sets the "name" field if the given value is not nil.
|
||||||
|
func (_u *ProxyUpdateOne) SetNillableName(v *string) *ProxyUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetName(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetProxyType sets the "proxy_type" field.
|
||||||
|
func (_u *ProxyUpdateOne) SetProxyType(v string) *ProxyUpdateOne {
|
||||||
|
_u.mutation.SetProxyType(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableProxyType sets the "proxy_type" field if the given value is not nil.
|
||||||
|
func (_u *ProxyUpdateOne) SetNillableProxyType(v *string) *ProxyUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetProxyType(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetLocalIP sets the "local_ip" field.
|
||||||
|
func (_u *ProxyUpdateOne) SetLocalIP(v string) *ProxyUpdateOne {
|
||||||
|
_u.mutation.SetLocalIP(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableLocalIP sets the "local_ip" field if the given value is not nil.
|
||||||
|
func (_u *ProxyUpdateOne) SetNillableLocalIP(v *string) *ProxyUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetLocalIP(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetLocalPort sets the "local_port" field.
|
||||||
|
func (_u *ProxyUpdateOne) SetLocalPort(v int) *ProxyUpdateOne {
|
||||||
|
_u.mutation.ResetLocalPort()
|
||||||
|
_u.mutation.SetLocalPort(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableLocalPort sets the "local_port" field if the given value is not nil.
|
||||||
|
func (_u *ProxyUpdateOne) SetNillableLocalPort(v *int) *ProxyUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetLocalPort(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddLocalPort adds value to the "local_port" field.
|
||||||
|
func (_u *ProxyUpdateOne) AddLocalPort(v int) *ProxyUpdateOne {
|
||||||
|
_u.mutation.AddLocalPort(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRemotePort sets the "remote_port" field.
|
||||||
|
func (_u *ProxyUpdateOne) SetRemotePort(v int) *ProxyUpdateOne {
|
||||||
|
_u.mutation.ResetRemotePort()
|
||||||
|
_u.mutation.SetRemotePort(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableRemotePort sets the "remote_port" field if the given value is not nil.
|
||||||
|
func (_u *ProxyUpdateOne) SetNillableRemotePort(v *int) *ProxyUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetRemotePort(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddRemotePort adds value to the "remote_port" field.
|
||||||
|
func (_u *ProxyUpdateOne) AddRemotePort(v int) *ProxyUpdateOne {
|
||||||
|
_u.mutation.AddRemotePort(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetStatus sets the "status" field.
|
||||||
|
func (_u *ProxyUpdateOne) SetStatus(v string) *ProxyUpdateOne {
|
||||||
|
_u.mutation.SetStatus(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
||||||
|
func (_u *ProxyUpdateOne) SetNillableStatus(v *string) *ProxyUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetStatus(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCustomDomains sets the "custom_domains" field.
|
||||||
|
func (_u *ProxyUpdateOne) SetCustomDomains(v string) *ProxyUpdateOne {
|
||||||
|
_u.mutation.SetCustomDomains(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableCustomDomains sets the "custom_domains" field if the given value is not nil.
|
||||||
|
func (_u *ProxyUpdateOne) SetNillableCustomDomains(v *string) *ProxyUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetCustomDomains(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetMetadata sets the "metadata" field.
|
||||||
|
func (_u *ProxyUpdateOne) SetMetadata(v string) *ProxyUpdateOne {
|
||||||
|
_u.mutation.SetMetadata(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableMetadata sets the "metadata" field if the given value is not nil.
|
||||||
|
func (_u *ProxyUpdateOne) SetNillableMetadata(v *string) *ProxyUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetMetadata(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetClientID sets the "client_id" field.
|
||||||
|
func (_u *ProxyUpdateOne) SetClientID(v int) *ProxyUpdateOne {
|
||||||
|
_u.mutation.ResetClientID()
|
||||||
|
_u.mutation.SetClientID(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableClientID sets the "client_id" field if the given value is not nil.
|
||||||
|
func (_u *ProxyUpdateOne) SetNillableClientID(v *int) *ProxyUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetClientID(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddClientID adds value to the "client_id" field.
|
||||||
|
func (_u *ProxyUpdateOne) AddClientID(v int) *ProxyUpdateOne {
|
||||||
|
_u.mutation.AddClientID(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCreatedAt sets the "created_at" field.
|
||||||
|
func (_u *ProxyUpdateOne) SetCreatedAt(v time.Time) *ProxyUpdateOne {
|
||||||
|
_u.mutation.SetCreatedAt(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||||
|
func (_u *ProxyUpdateOne) SetNillableCreatedAt(v *time.Time) *ProxyUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetCreatedAt(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUpdatedAt sets the "updated_at" field.
|
||||||
|
func (_u *ProxyUpdateOne) SetUpdatedAt(v time.Time) *ProxyUpdateOne {
|
||||||
|
_u.mutation.SetUpdatedAt(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the ProxyMutation object of the builder.
|
||||||
|
func (_u *ProxyUpdateOne) Mutation() *ProxyMutation {
|
||||||
|
return _u.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the ProxyUpdate builder.
|
||||||
|
func (_u *ProxyUpdateOne) Where(ps ...predicate.Proxy) *ProxyUpdateOne {
|
||||||
|
_u.mutation.Where(ps...)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||||
|
// The default is selecting all fields defined in the entity schema.
|
||||||
|
func (_u *ProxyUpdateOne) Select(field string, fields ...string) *ProxyUpdateOne {
|
||||||
|
_u.fields = append([]string{field}, fields...)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save executes the query and returns the updated Proxy entity.
|
||||||
|
func (_u *ProxyUpdateOne) Save(ctx context.Context) (*Proxy, error) {
|
||||||
|
_u.defaults()
|
||||||
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (_u *ProxyUpdateOne) SaveX(ctx context.Context) *Proxy {
|
||||||
|
node, err := _u.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query on the entity.
|
||||||
|
func (_u *ProxyUpdateOne) Exec(ctx context.Context) error {
|
||||||
|
_, err := _u.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_u *ProxyUpdateOne) ExecX(ctx context.Context) {
|
||||||
|
if err := _u.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// defaults sets the default values of the builder before save.
|
||||||
|
func (_u *ProxyUpdateOne) defaults() {
|
||||||
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||||
|
v := proxy.UpdateDefaultUpdatedAt()
|
||||||
|
_u.mutation.SetUpdatedAt(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_u *ProxyUpdateOne) sqlSave(ctx context.Context) (_node *Proxy, err error) {
|
||||||
|
_spec := sqlgraph.NewUpdateSpec(proxy.Table, proxy.Columns, sqlgraph.NewFieldSpec(proxy.FieldID, field.TypeInt))
|
||||||
|
id, ok := _u.mutation.ID()
|
||||||
|
if !ok {
|
||||||
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Proxy.id" for update`)}
|
||||||
|
}
|
||||||
|
_spec.Node.ID.Value = id
|
||||||
|
if fields := _u.fields; len(fields) > 0 {
|
||||||
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, proxy.FieldID)
|
||||||
|
for _, f := range fields {
|
||||||
|
if !proxy.ValidColumn(f) {
|
||||||
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||||
|
}
|
||||||
|
if f != proxy.FieldID {
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Name(); ok {
|
||||||
|
_spec.SetField(proxy.FieldName, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.ProxyType(); ok {
|
||||||
|
_spec.SetField(proxy.FieldProxyType, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.LocalIP(); ok {
|
||||||
|
_spec.SetField(proxy.FieldLocalIP, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.LocalPort(); ok {
|
||||||
|
_spec.SetField(proxy.FieldLocalPort, field.TypeInt, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.AddedLocalPort(); ok {
|
||||||
|
_spec.AddField(proxy.FieldLocalPort, field.TypeInt, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.RemotePort(); ok {
|
||||||
|
_spec.SetField(proxy.FieldRemotePort, field.TypeInt, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.AddedRemotePort(); ok {
|
||||||
|
_spec.AddField(proxy.FieldRemotePort, field.TypeInt, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Status(); ok {
|
||||||
|
_spec.SetField(proxy.FieldStatus, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.CustomDomains(); ok {
|
||||||
|
_spec.SetField(proxy.FieldCustomDomains, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Metadata(); ok {
|
||||||
|
_spec.SetField(proxy.FieldMetadata, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.ClientID(); ok {
|
||||||
|
_spec.SetField(proxy.FieldClientID, field.TypeInt, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.AddedClientID(); ok {
|
||||||
|
_spec.AddField(proxy.FieldClientID, field.TypeInt, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
||||||
|
_spec.SetField(proxy.FieldCreatedAt, field.TypeTime, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||||
|
_spec.SetField(proxy.FieldUpdatedAt, field.TypeTime, value)
|
||||||
|
}
|
||||||
|
_node = &Proxy{config: _u.config}
|
||||||
|
_spec.Assign = _node.assignValues
|
||||||
|
_spec.ScanValues = _node.scanValues
|
||||||
|
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
||||||
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
|
err = &NotFoundError{proxy.Label}
|
||||||
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_u.mutation.done = true
|
||||||
|
return _node, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/frpcclient"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/proxy"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/schema"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// The init function reads all schema descriptors with runtime code
|
||||||
|
// (default values, validators, hooks and policies) and stitches it
|
||||||
|
// to their package variables.
|
||||||
|
func init() {
|
||||||
|
frpcclientFields := schema.FrpcClient{}.Fields()
|
||||||
|
_ = frpcclientFields
|
||||||
|
// frpcclientDescKey is the schema descriptor for key field.
|
||||||
|
frpcclientDescKey := frpcclientFields[1].Descriptor()
|
||||||
|
// frpcclient.DefaultKey holds the default value on creation for the key field.
|
||||||
|
frpcclient.DefaultKey = frpcclientDescKey.Default.(string)
|
||||||
|
// frpcclientDescAddr is the schema descriptor for addr field.
|
||||||
|
frpcclientDescAddr := frpcclientFields[2].Descriptor()
|
||||||
|
// frpcclient.DefaultAddr holds the default value on creation for the addr field.
|
||||||
|
frpcclient.DefaultAddr = frpcclientDescAddr.Default.(string)
|
||||||
|
// frpcclientDescPort is the schema descriptor for port field.
|
||||||
|
frpcclientDescPort := frpcclientFields[3].Descriptor()
|
||||||
|
// frpcclient.DefaultPort holds the default value on creation for the port field.
|
||||||
|
frpcclient.DefaultPort = frpcclientDescPort.Default.(int)
|
||||||
|
// frpcclientDescStatus is the schema descriptor for status field.
|
||||||
|
frpcclientDescStatus := frpcclientFields[4].Descriptor()
|
||||||
|
// frpcclient.DefaultStatus holds the default value on creation for the status field.
|
||||||
|
frpcclient.DefaultStatus = frpcclientDescStatus.Default.(string)
|
||||||
|
// frpcclientDescMetadata is the schema descriptor for metadata field.
|
||||||
|
frpcclientDescMetadata := frpcclientFields[5].Descriptor()
|
||||||
|
// frpcclient.DefaultMetadata holds the default value on creation for the metadata field.
|
||||||
|
frpcclient.DefaultMetadata = frpcclientDescMetadata.Default.(string)
|
||||||
|
// frpcclientDescCreatedAt is the schema descriptor for created_at field.
|
||||||
|
frpcclientDescCreatedAt := frpcclientFields[6].Descriptor()
|
||||||
|
// frpcclient.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||||
|
frpcclient.DefaultCreatedAt = frpcclientDescCreatedAt.Default.(func() time.Time)
|
||||||
|
// frpcclientDescUpdatedAt is the schema descriptor for updated_at field.
|
||||||
|
frpcclientDescUpdatedAt := frpcclientFields[7].Descriptor()
|
||||||
|
// frpcclient.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||||
|
frpcclient.DefaultUpdatedAt = frpcclientDescUpdatedAt.Default.(func() time.Time)
|
||||||
|
// frpcclient.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||||
|
frpcclient.UpdateDefaultUpdatedAt = frpcclientDescUpdatedAt.UpdateDefault.(func() time.Time)
|
||||||
|
// frpcclientDescLastSeen is the schema descriptor for last_seen field.
|
||||||
|
frpcclientDescLastSeen := frpcclientFields[8].Descriptor()
|
||||||
|
// frpcclient.DefaultLastSeen holds the default value on creation for the last_seen field.
|
||||||
|
frpcclient.DefaultLastSeen = frpcclientDescLastSeen.Default.(func() time.Time)
|
||||||
|
proxyFields := schema.Proxy{}.Fields()
|
||||||
|
_ = proxyFields
|
||||||
|
// proxyDescProxyType is the schema descriptor for proxy_type field.
|
||||||
|
proxyDescProxyType := proxyFields[1].Descriptor()
|
||||||
|
// proxy.DefaultProxyType holds the default value on creation for the proxy_type field.
|
||||||
|
proxy.DefaultProxyType = proxyDescProxyType.Default.(string)
|
||||||
|
// proxyDescLocalIP is the schema descriptor for local_ip field.
|
||||||
|
proxyDescLocalIP := proxyFields[2].Descriptor()
|
||||||
|
// proxy.DefaultLocalIP holds the default value on creation for the local_ip field.
|
||||||
|
proxy.DefaultLocalIP = proxyDescLocalIP.Default.(string)
|
||||||
|
// proxyDescRemotePort is the schema descriptor for remote_port field.
|
||||||
|
proxyDescRemotePort := proxyFields[4].Descriptor()
|
||||||
|
// proxy.DefaultRemotePort holds the default value on creation for the remote_port field.
|
||||||
|
proxy.DefaultRemotePort = proxyDescRemotePort.Default.(int)
|
||||||
|
// proxyDescStatus is the schema descriptor for status field.
|
||||||
|
proxyDescStatus := proxyFields[5].Descriptor()
|
||||||
|
// proxy.DefaultStatus holds the default value on creation for the status field.
|
||||||
|
proxy.DefaultStatus = proxyDescStatus.Default.(string)
|
||||||
|
// proxyDescCustomDomains is the schema descriptor for custom_domains field.
|
||||||
|
proxyDescCustomDomains := proxyFields[6].Descriptor()
|
||||||
|
// proxy.DefaultCustomDomains holds the default value on creation for the custom_domains field.
|
||||||
|
proxy.DefaultCustomDomains = proxyDescCustomDomains.Default.(string)
|
||||||
|
// proxyDescMetadata is the schema descriptor for metadata field.
|
||||||
|
proxyDescMetadata := proxyFields[7].Descriptor()
|
||||||
|
// proxy.DefaultMetadata holds the default value on creation for the metadata field.
|
||||||
|
proxy.DefaultMetadata = proxyDescMetadata.Default.(string)
|
||||||
|
// proxyDescClientID is the schema descriptor for client_id field.
|
||||||
|
proxyDescClientID := proxyFields[8].Descriptor()
|
||||||
|
// proxy.DefaultClientID holds the default value on creation for the client_id field.
|
||||||
|
proxy.DefaultClientID = proxyDescClientID.Default.(int)
|
||||||
|
// proxyDescCreatedAt is the schema descriptor for created_at field.
|
||||||
|
proxyDescCreatedAt := proxyFields[9].Descriptor()
|
||||||
|
// proxy.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||||
|
proxy.DefaultCreatedAt = proxyDescCreatedAt.Default.(func() time.Time)
|
||||||
|
// proxyDescUpdatedAt is the schema descriptor for updated_at field.
|
||||||
|
proxyDescUpdatedAt := proxyFields[10].Descriptor()
|
||||||
|
// proxy.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||||
|
proxy.DefaultUpdatedAt = proxyDescUpdatedAt.Default.(func() time.Time)
|
||||||
|
// proxy.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||||
|
proxy.UpdateDefaultUpdatedAt = proxyDescUpdatedAt.UpdateDefault.(func() time.Time)
|
||||||
|
userFields := schema.User{}.Fields()
|
||||||
|
_ = userFields
|
||||||
|
// userDescName is the schema descriptor for name field.
|
||||||
|
userDescName := userFields[2].Descriptor()
|
||||||
|
// user.DefaultName holds the default value on creation for the name field.
|
||||||
|
user.DefaultName = userDescName.Default.(string)
|
||||||
|
// userDescRole is the schema descriptor for role field.
|
||||||
|
userDescRole := userFields[3].Descriptor()
|
||||||
|
// user.DefaultRole holds the default value on creation for the role field.
|
||||||
|
user.DefaultRole = userDescRole.Default.(string)
|
||||||
|
// userDescCreatedAt is the schema descriptor for created_at field.
|
||||||
|
userDescCreatedAt := userFields[4].Descriptor()
|
||||||
|
// user.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||||
|
user.DefaultCreatedAt = userDescCreatedAt.Default.(func() time.Time)
|
||||||
|
// userDescUpdatedAt is the schema descriptor for updated_at field.
|
||||||
|
userDescUpdatedAt := userFields[5].Descriptor()
|
||||||
|
// user.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||||
|
user.DefaultUpdatedAt = userDescUpdatedAt.Default.(func() time.Time)
|
||||||
|
// user.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||||
|
user.UpdateDefaultUpdatedAt = userDescUpdatedAt.UpdateDefault.(func() time.Time)
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package runtime
|
||||||
|
|
||||||
|
// The schema-stitching logic is generated in github.com/fatedier/frp/pkg/db/ent/runtime.go
|
||||||
|
|
||||||
|
const (
|
||||||
|
Version = "v0.14.6" // Version of ent codegen.
|
||||||
|
Sum = "h1:/f2696BpwuWAEEG6PVGWflg6+Inrpq4pRWuNlWz/Skk=" // Sum of ent codegen.
|
||||||
|
)
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package schema
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
)
|
||||||
|
|
||||||
|
type FrpcClient struct {
|
||||||
|
ent.Schema
|
||||||
|
}
|
||||||
|
|
||||||
|
func (FrpcClient) Fields() []ent.Field {
|
||||||
|
return []ent.Field{
|
||||||
|
field.String("name").Unique(),
|
||||||
|
field.String("key").Default(""),
|
||||||
|
field.String("addr").Default(""),
|
||||||
|
field.Int("port").Default(0),
|
||||||
|
field.String("status").Default("offline"),
|
||||||
|
field.String("metadata").Default("{}"),
|
||||||
|
field.Time("created_at").Default(time.Now),
|
||||||
|
field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now),
|
||||||
|
field.Time("last_seen").Optional().Default(time.Now),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package schema
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Proxy struct {
|
||||||
|
ent.Schema
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Proxy) Fields() []ent.Field {
|
||||||
|
return []ent.Field{
|
||||||
|
field.String("name"),
|
||||||
|
field.String("proxy_type").Default("tcp"),
|
||||||
|
field.String("local_ip").Default("127.0.0.1"),
|
||||||
|
field.Int("local_port"),
|
||||||
|
field.Int("remote_port").Default(0),
|
||||||
|
field.String("status").Default("inactive"),
|
||||||
|
field.String("custom_domains").Default(""),
|
||||||
|
field.String("metadata").Default("{}"),
|
||||||
|
field.Int("client_id").Default(0),
|
||||||
|
field.Time("created_at").Default(time.Now),
|
||||||
|
field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package schema
|
||||||
|
|
||||||
|
import (
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ServerConfig struct {
|
||||||
|
ent.Schema
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ServerConfig) Fields() []ent.Field {
|
||||||
|
return []ent.Field{
|
||||||
|
field.String("key").Unique(),
|
||||||
|
field.String("value"),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package schema
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
)
|
||||||
|
|
||||||
|
type User struct {
|
||||||
|
ent.Schema
|
||||||
|
}
|
||||||
|
|
||||||
|
func (User) Fields() []ent.Field {
|
||||||
|
return []ent.Field{
|
||||||
|
field.String("username").Unique(),
|
||||||
|
field.String("password"),
|
||||||
|
field.String("name").Default(""),
|
||||||
|
field.String("role").Default("admin"),
|
||||||
|
field.Time("created_at").Default(time.Now),
|
||||||
|
field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/serverconfig"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ServerConfig is the model entity for the ServerConfig schema.
|
||||||
|
type ServerConfig struct {
|
||||||
|
config `json:"-"`
|
||||||
|
// ID of the ent.
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
// Key holds the value of the "key" field.
|
||||||
|
Key string `json:"key,omitempty"`
|
||||||
|
// Value holds the value of the "value" field.
|
||||||
|
Value string `json:"value,omitempty"`
|
||||||
|
selectValues sql.SelectValues
|
||||||
|
}
|
||||||
|
|
||||||
|
// scanValues returns the types for scanning values from sql.Rows.
|
||||||
|
func (*ServerConfig) scanValues(columns []string) ([]any, error) {
|
||||||
|
values := make([]any, len(columns))
|
||||||
|
for i := range columns {
|
||||||
|
switch columns[i] {
|
||||||
|
case serverconfig.FieldID:
|
||||||
|
values[i] = new(sql.NullInt64)
|
||||||
|
case serverconfig.FieldKey, serverconfig.FieldValue:
|
||||||
|
values[i] = new(sql.NullString)
|
||||||
|
default:
|
||||||
|
values[i] = new(sql.UnknownType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return values, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||||
|
// to the ServerConfig fields.
|
||||||
|
func (_m *ServerConfig) assignValues(columns []string, values []any) error {
|
||||||
|
if m, n := len(values), len(columns); m < n {
|
||||||
|
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||||
|
}
|
||||||
|
for i := range columns {
|
||||||
|
switch columns[i] {
|
||||||
|
case serverconfig.FieldID:
|
||||||
|
value, ok := values[i].(*sql.NullInt64)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field id", value)
|
||||||
|
}
|
||||||
|
_m.ID = int(value.Int64)
|
||||||
|
case serverconfig.FieldKey:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field key", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.Key = value.String
|
||||||
|
}
|
||||||
|
case serverconfig.FieldValue:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field value", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.Value = value.String
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
_m.selectValues.Set(columns[i], values[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetValue returns the ent.Value that was dynamically selected and assigned to the ServerConfig.
|
||||||
|
// This includes values selected through modifiers, order, etc.
|
||||||
|
func (_m *ServerConfig) GetValue(name string) (ent.Value, error) {
|
||||||
|
return _m.selectValues.Get(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update returns a builder for updating this ServerConfig.
|
||||||
|
// Note that you need to call ServerConfig.Unwrap() before calling this method if this ServerConfig
|
||||||
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||||
|
func (_m *ServerConfig) Update() *ServerConfigUpdateOne {
|
||||||
|
return NewServerConfigClient(_m.config).UpdateOne(_m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unwrap unwraps the ServerConfig entity that was returned from a transaction after it was closed,
|
||||||
|
// so that all future queries will be executed through the driver which created the transaction.
|
||||||
|
func (_m *ServerConfig) Unwrap() *ServerConfig {
|
||||||
|
_tx, ok := _m.config.driver.(*txDriver)
|
||||||
|
if !ok {
|
||||||
|
panic("ent: ServerConfig is not a transactional entity")
|
||||||
|
}
|
||||||
|
_m.config.driver = _tx.drv
|
||||||
|
return _m
|
||||||
|
}
|
||||||
|
|
||||||
|
// String implements the fmt.Stringer.
|
||||||
|
func (_m *ServerConfig) String() string {
|
||||||
|
var builder strings.Builder
|
||||||
|
builder.WriteString("ServerConfig(")
|
||||||
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||||
|
builder.WriteString("key=")
|
||||||
|
builder.WriteString(_m.Key)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("value=")
|
||||||
|
builder.WriteString(_m.Value)
|
||||||
|
builder.WriteByte(')')
|
||||||
|
return builder.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServerConfigs is a parsable slice of ServerConfig.
|
||||||
|
type ServerConfigs []*ServerConfig
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package serverconfig
|
||||||
|
|
||||||
|
import (
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Label holds the string label denoting the serverconfig type in the database.
|
||||||
|
Label = "server_config"
|
||||||
|
// FieldID holds the string denoting the id field in the database.
|
||||||
|
FieldID = "id"
|
||||||
|
// FieldKey holds the string denoting the key field in the database.
|
||||||
|
FieldKey = "key"
|
||||||
|
// FieldValue holds the string denoting the value field in the database.
|
||||||
|
FieldValue = "value"
|
||||||
|
// Table holds the table name of the serverconfig in the database.
|
||||||
|
Table = "server_configs"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Columns holds all SQL columns for serverconfig fields.
|
||||||
|
var Columns = []string{
|
||||||
|
FieldID,
|
||||||
|
FieldKey,
|
||||||
|
FieldValue,
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||||
|
func ValidColumn(column string) bool {
|
||||||
|
for i := range Columns {
|
||||||
|
if column == Columns[i] {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// OrderOption defines the ordering options for the ServerConfig queries.
|
||||||
|
type OrderOption func(*sql.Selector)
|
||||||
|
|
||||||
|
// ByID orders the results by the id field.
|
||||||
|
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByKey orders the results by the key field.
|
||||||
|
func ByKey(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldKey, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByValue orders the results by the value field.
|
||||||
|
func ByValue(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldValue, opts...).ToFunc()
|
||||||
|
}
|
||||||
@@ -0,0 +1,208 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package serverconfig
|
||||||
|
|
||||||
|
import (
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/predicate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ID filters vertices based on their ID field.
|
||||||
|
func ID(id int) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDEQ applies the EQ predicate on the ID field.
|
||||||
|
func IDEQ(id int) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDNEQ applies the NEQ predicate on the ID field.
|
||||||
|
func IDNEQ(id int) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldNEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDIn applies the In predicate on the ID field.
|
||||||
|
func IDIn(ids ...int) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldIn(FieldID, ids...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDNotIn applies the NotIn predicate on the ID field.
|
||||||
|
func IDNotIn(ids ...int) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldNotIn(FieldID, ids...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDGT applies the GT predicate on the ID field.
|
||||||
|
func IDGT(id int) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldGT(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDGTE applies the GTE predicate on the ID field.
|
||||||
|
func IDGTE(id int) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldGTE(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDLT applies the LT predicate on the ID field.
|
||||||
|
func IDLT(id int) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldLT(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDLTE applies the LTE predicate on the ID field.
|
||||||
|
func IDLTE(id int) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldLTE(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Key applies equality check predicate on the "key" field. It's identical to KeyEQ.
|
||||||
|
func Key(v string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldEQ(FieldKey, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value applies equality check predicate on the "value" field. It's identical to ValueEQ.
|
||||||
|
func Value(v string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldEQ(FieldValue, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyEQ applies the EQ predicate on the "key" field.
|
||||||
|
func KeyEQ(v string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldEQ(FieldKey, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyNEQ applies the NEQ predicate on the "key" field.
|
||||||
|
func KeyNEQ(v string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldNEQ(FieldKey, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyIn applies the In predicate on the "key" field.
|
||||||
|
func KeyIn(vs ...string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldIn(FieldKey, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyNotIn applies the NotIn predicate on the "key" field.
|
||||||
|
func KeyNotIn(vs ...string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldNotIn(FieldKey, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyGT applies the GT predicate on the "key" field.
|
||||||
|
func KeyGT(v string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldGT(FieldKey, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyGTE applies the GTE predicate on the "key" field.
|
||||||
|
func KeyGTE(v string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldGTE(FieldKey, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyLT applies the LT predicate on the "key" field.
|
||||||
|
func KeyLT(v string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldLT(FieldKey, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyLTE applies the LTE predicate on the "key" field.
|
||||||
|
func KeyLTE(v string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldLTE(FieldKey, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyContains applies the Contains predicate on the "key" field.
|
||||||
|
func KeyContains(v string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldContains(FieldKey, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyHasPrefix applies the HasPrefix predicate on the "key" field.
|
||||||
|
func KeyHasPrefix(v string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldHasPrefix(FieldKey, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyHasSuffix applies the HasSuffix predicate on the "key" field.
|
||||||
|
func KeyHasSuffix(v string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldHasSuffix(FieldKey, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyEqualFold applies the EqualFold predicate on the "key" field.
|
||||||
|
func KeyEqualFold(v string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldEqualFold(FieldKey, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyContainsFold applies the ContainsFold predicate on the "key" field.
|
||||||
|
func KeyContainsFold(v string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldContainsFold(FieldKey, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValueEQ applies the EQ predicate on the "value" field.
|
||||||
|
func ValueEQ(v string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldEQ(FieldValue, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValueNEQ applies the NEQ predicate on the "value" field.
|
||||||
|
func ValueNEQ(v string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldNEQ(FieldValue, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValueIn applies the In predicate on the "value" field.
|
||||||
|
func ValueIn(vs ...string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldIn(FieldValue, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValueNotIn applies the NotIn predicate on the "value" field.
|
||||||
|
func ValueNotIn(vs ...string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldNotIn(FieldValue, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValueGT applies the GT predicate on the "value" field.
|
||||||
|
func ValueGT(v string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldGT(FieldValue, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValueGTE applies the GTE predicate on the "value" field.
|
||||||
|
func ValueGTE(v string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldGTE(FieldValue, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValueLT applies the LT predicate on the "value" field.
|
||||||
|
func ValueLT(v string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldLT(FieldValue, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValueLTE applies the LTE predicate on the "value" field.
|
||||||
|
func ValueLTE(v string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldLTE(FieldValue, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValueContains applies the Contains predicate on the "value" field.
|
||||||
|
func ValueContains(v string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldContains(FieldValue, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValueHasPrefix applies the HasPrefix predicate on the "value" field.
|
||||||
|
func ValueHasPrefix(v string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldHasPrefix(FieldValue, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValueHasSuffix applies the HasSuffix predicate on the "value" field.
|
||||||
|
func ValueHasSuffix(v string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldHasSuffix(FieldValue, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValueEqualFold applies the EqualFold predicate on the "value" field.
|
||||||
|
func ValueEqualFold(v string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldEqualFold(FieldValue, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValueContainsFold applies the ContainsFold predicate on the "value" field.
|
||||||
|
func ValueContainsFold(v string) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.FieldContainsFold(FieldValue, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// And groups predicates with the AND operator between them.
|
||||||
|
func And(predicates ...predicate.ServerConfig) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.AndPredicates(predicates...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Or groups predicates with the OR operator between them.
|
||||||
|
func Or(predicates ...predicate.ServerConfig) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.OrPredicates(predicates...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not applies the not operator on the given predicate.
|
||||||
|
func Not(p predicate.ServerConfig) predicate.ServerConfig {
|
||||||
|
return predicate.ServerConfig(sql.NotPredicates(p))
|
||||||
|
}
|
||||||
@@ -0,0 +1,196 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/serverconfig"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ServerConfigCreate is the builder for creating a ServerConfig entity.
|
||||||
|
type ServerConfigCreate struct {
|
||||||
|
config
|
||||||
|
mutation *ServerConfigMutation
|
||||||
|
hooks []Hook
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetKey sets the "key" field.
|
||||||
|
func (_c *ServerConfigCreate) SetKey(v string) *ServerConfigCreate {
|
||||||
|
_c.mutation.SetKey(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetValue sets the "value" field.
|
||||||
|
func (_c *ServerConfigCreate) SetValue(v string) *ServerConfigCreate {
|
||||||
|
_c.mutation.SetValue(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the ServerConfigMutation object of the builder.
|
||||||
|
func (_c *ServerConfigCreate) Mutation() *ServerConfigMutation {
|
||||||
|
return _c.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save creates the ServerConfig in the database.
|
||||||
|
func (_c *ServerConfigCreate) Save(ctx context.Context) (*ServerConfig, error) {
|
||||||
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX calls Save and panics if Save returns an error.
|
||||||
|
func (_c *ServerConfigCreate) SaveX(ctx context.Context) *ServerConfig {
|
||||||
|
v, err := _c.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (_c *ServerConfigCreate) Exec(ctx context.Context) error {
|
||||||
|
_, err := _c.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_c *ServerConfigCreate) ExecX(ctx context.Context) {
|
||||||
|
if err := _c.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check runs all checks and user-defined validators on the builder.
|
||||||
|
func (_c *ServerConfigCreate) check() error {
|
||||||
|
if _, ok := _c.mutation.Key(); !ok {
|
||||||
|
return &ValidationError{Name: "key", err: errors.New(`ent: missing required field "ServerConfig.key"`)}
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.Value(); !ok {
|
||||||
|
return &ValidationError{Name: "value", err: errors.New(`ent: missing required field "ServerConfig.value"`)}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_c *ServerConfigCreate) sqlSave(ctx context.Context) (*ServerConfig, error) {
|
||||||
|
if err := _c.check(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_node, _spec := _c.createSpec()
|
||||||
|
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||||
|
if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
id := _spec.ID.Value.(int64)
|
||||||
|
_node.ID = int(id)
|
||||||
|
_c.mutation.id = &_node.ID
|
||||||
|
_c.mutation.done = true
|
||||||
|
return _node, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_c *ServerConfigCreate) createSpec() (*ServerConfig, *sqlgraph.CreateSpec) {
|
||||||
|
var (
|
||||||
|
_node = &ServerConfig{config: _c.config}
|
||||||
|
_spec = sqlgraph.NewCreateSpec(serverconfig.Table, sqlgraph.NewFieldSpec(serverconfig.FieldID, field.TypeInt))
|
||||||
|
)
|
||||||
|
if value, ok := _c.mutation.Key(); ok {
|
||||||
|
_spec.SetField(serverconfig.FieldKey, field.TypeString, value)
|
||||||
|
_node.Key = value
|
||||||
|
}
|
||||||
|
if value, ok := _c.mutation.Value(); ok {
|
||||||
|
_spec.SetField(serverconfig.FieldValue, field.TypeString, value)
|
||||||
|
_node.Value = value
|
||||||
|
}
|
||||||
|
return _node, _spec
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServerConfigCreateBulk is the builder for creating many ServerConfig entities in bulk.
|
||||||
|
type ServerConfigCreateBulk struct {
|
||||||
|
config
|
||||||
|
err error
|
||||||
|
builders []*ServerConfigCreate
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save creates the ServerConfig entities in the database.
|
||||||
|
func (_c *ServerConfigCreateBulk) Save(ctx context.Context) ([]*ServerConfig, error) {
|
||||||
|
if _c.err != nil {
|
||||||
|
return nil, _c.err
|
||||||
|
}
|
||||||
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||||
|
nodes := make([]*ServerConfig, len(_c.builders))
|
||||||
|
mutators := make([]Mutator, len(_c.builders))
|
||||||
|
for i := range _c.builders {
|
||||||
|
func(i int, root context.Context) {
|
||||||
|
builder := _c.builders[i]
|
||||||
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||||
|
mutation, ok := m.(*ServerConfigMutation)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||||
|
}
|
||||||
|
if err := builder.check(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
builder.mutation = mutation
|
||||||
|
var err error
|
||||||
|
nodes[i], specs[i] = builder.createSpec()
|
||||||
|
if i < len(mutators)-1 {
|
||||||
|
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||||
|
} else {
|
||||||
|
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||||
|
// Invoke the actual operation on the latest mutation in the chain.
|
||||||
|
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||||
|
if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
mutation.id = &nodes[i].ID
|
||||||
|
if specs[i].ID.Value != nil {
|
||||||
|
id := specs[i].ID.Value.(int64)
|
||||||
|
nodes[i].ID = int(id)
|
||||||
|
}
|
||||||
|
mutation.done = true
|
||||||
|
return nodes[i], nil
|
||||||
|
})
|
||||||
|
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||||
|
mut = builder.hooks[i](mut)
|
||||||
|
}
|
||||||
|
mutators[i] = mut
|
||||||
|
}(i, ctx)
|
||||||
|
}
|
||||||
|
if len(mutators) > 0 {
|
||||||
|
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (_c *ServerConfigCreateBulk) SaveX(ctx context.Context) []*ServerConfig {
|
||||||
|
v, err := _c.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (_c *ServerConfigCreateBulk) Exec(ctx context.Context) error {
|
||||||
|
_, err := _c.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_c *ServerConfigCreateBulk) ExecX(ctx context.Context) {
|
||||||
|
if err := _c.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/predicate"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/serverconfig"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ServerConfigDelete is the builder for deleting a ServerConfig entity.
|
||||||
|
type ServerConfigDelete struct {
|
||||||
|
config
|
||||||
|
hooks []Hook
|
||||||
|
mutation *ServerConfigMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the ServerConfigDelete builder.
|
||||||
|
func (_d *ServerConfigDelete) Where(ps ...predicate.ServerConfig) *ServerConfigDelete {
|
||||||
|
_d.mutation.Where(ps...)
|
||||||
|
return _d
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||||
|
func (_d *ServerConfigDelete) Exec(ctx context.Context) (int, error) {
|
||||||
|
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_d *ServerConfigDelete) ExecX(ctx context.Context) int {
|
||||||
|
n, err := _d.Exec(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_d *ServerConfigDelete) sqlExec(ctx context.Context) (int, error) {
|
||||||
|
_spec := sqlgraph.NewDeleteSpec(serverconfig.Table, sqlgraph.NewFieldSpec(serverconfig.FieldID, field.TypeInt))
|
||||||
|
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||||
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
_d.mutation.done = true
|
||||||
|
return affected, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServerConfigDeleteOne is the builder for deleting a single ServerConfig entity.
|
||||||
|
type ServerConfigDeleteOne struct {
|
||||||
|
_d *ServerConfigDelete
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the ServerConfigDelete builder.
|
||||||
|
func (_d *ServerConfigDeleteOne) Where(ps ...predicate.ServerConfig) *ServerConfigDeleteOne {
|
||||||
|
_d._d.mutation.Where(ps...)
|
||||||
|
return _d
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query.
|
||||||
|
func (_d *ServerConfigDeleteOne) Exec(ctx context.Context) error {
|
||||||
|
n, err := _d._d.Exec(ctx)
|
||||||
|
switch {
|
||||||
|
case err != nil:
|
||||||
|
return err
|
||||||
|
case n == 0:
|
||||||
|
return &NotFoundError{serverconfig.Label}
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_d *ServerConfigDeleteOne) ExecX(ctx context.Context) {
|
||||||
|
if err := _d.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,527 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"math"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/predicate"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/serverconfig"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ServerConfigQuery is the builder for querying ServerConfig entities.
|
||||||
|
type ServerConfigQuery struct {
|
||||||
|
config
|
||||||
|
ctx *QueryContext
|
||||||
|
order []serverconfig.OrderOption
|
||||||
|
inters []Interceptor
|
||||||
|
predicates []predicate.ServerConfig
|
||||||
|
// intermediate query (i.e. traversal path).
|
||||||
|
sql *sql.Selector
|
||||||
|
path func(context.Context) (*sql.Selector, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where adds a new predicate for the ServerConfigQuery builder.
|
||||||
|
func (_q *ServerConfigQuery) Where(ps ...predicate.ServerConfig) *ServerConfigQuery {
|
||||||
|
_q.predicates = append(_q.predicates, ps...)
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// Limit the number of records to be returned by this query.
|
||||||
|
func (_q *ServerConfigQuery) Limit(limit int) *ServerConfigQuery {
|
||||||
|
_q.ctx.Limit = &limit
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// Offset to start from.
|
||||||
|
func (_q *ServerConfigQuery) Offset(offset int) *ServerConfigQuery {
|
||||||
|
_q.ctx.Offset = &offset
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unique configures the query builder to filter duplicate records on query.
|
||||||
|
// By default, unique is set to true, and can be disabled using this method.
|
||||||
|
func (_q *ServerConfigQuery) Unique(unique bool) *ServerConfigQuery {
|
||||||
|
_q.ctx.Unique = &unique
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// Order specifies how the records should be ordered.
|
||||||
|
func (_q *ServerConfigQuery) Order(o ...serverconfig.OrderOption) *ServerConfigQuery {
|
||||||
|
_q.order = append(_q.order, o...)
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// First returns the first ServerConfig entity from the query.
|
||||||
|
// Returns a *NotFoundError when no ServerConfig was found.
|
||||||
|
func (_q *ServerConfigQuery) First(ctx context.Context) (*ServerConfig, error) {
|
||||||
|
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return nil, &NotFoundError{serverconfig.Label}
|
||||||
|
}
|
||||||
|
return nodes[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstX is like First, but panics if an error occurs.
|
||||||
|
func (_q *ServerConfigQuery) FirstX(ctx context.Context) *ServerConfig {
|
||||||
|
node, err := _q.First(ctx)
|
||||||
|
if err != nil && !IsNotFound(err) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstID returns the first ServerConfig ID from the query.
|
||||||
|
// Returns a *NotFoundError when no ServerConfig ID was found.
|
||||||
|
func (_q *ServerConfigQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||||
|
var ids []int
|
||||||
|
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(ids) == 0 {
|
||||||
|
err = &NotFoundError{serverconfig.Label}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return ids[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||||
|
func (_q *ServerConfigQuery) FirstIDX(ctx context.Context) int {
|
||||||
|
id, err := _q.FirstID(ctx)
|
||||||
|
if err != nil && !IsNotFound(err) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only returns a single ServerConfig entity found by the query, ensuring it only returns one.
|
||||||
|
// Returns a *NotSingularError when more than one ServerConfig entity is found.
|
||||||
|
// Returns a *NotFoundError when no ServerConfig entities are found.
|
||||||
|
func (_q *ServerConfigQuery) Only(ctx context.Context) (*ServerConfig, error) {
|
||||||
|
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
switch len(nodes) {
|
||||||
|
case 1:
|
||||||
|
return nodes[0], nil
|
||||||
|
case 0:
|
||||||
|
return nil, &NotFoundError{serverconfig.Label}
|
||||||
|
default:
|
||||||
|
return nil, &NotSingularError{serverconfig.Label}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyX is like Only, but panics if an error occurs.
|
||||||
|
func (_q *ServerConfigQuery) OnlyX(ctx context.Context) *ServerConfig {
|
||||||
|
node, err := _q.Only(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyID is like Only, but returns the only ServerConfig ID in the query.
|
||||||
|
// Returns a *NotSingularError when more than one ServerConfig ID is found.
|
||||||
|
// Returns a *NotFoundError when no entities are found.
|
||||||
|
func (_q *ServerConfigQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||||
|
var ids []int
|
||||||
|
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch len(ids) {
|
||||||
|
case 1:
|
||||||
|
id = ids[0]
|
||||||
|
case 0:
|
||||||
|
err = &NotFoundError{serverconfig.Label}
|
||||||
|
default:
|
||||||
|
err = &NotSingularError{serverconfig.Label}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||||
|
func (_q *ServerConfigQuery) OnlyIDX(ctx context.Context) int {
|
||||||
|
id, err := _q.OnlyID(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// All executes the query and returns a list of ServerConfigs.
|
||||||
|
func (_q *ServerConfigQuery) All(ctx context.Context) ([]*ServerConfig, error) {
|
||||||
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||||
|
if err := _q.prepareQuery(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
qr := querierAll[[]*ServerConfig, *ServerConfigQuery]()
|
||||||
|
return withInterceptors[[]*ServerConfig](ctx, _q, qr, _q.inters)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AllX is like All, but panics if an error occurs.
|
||||||
|
func (_q *ServerConfigQuery) AllX(ctx context.Context) []*ServerConfig {
|
||||||
|
nodes, err := _q.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return nodes
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs executes the query and returns a list of ServerConfig IDs.
|
||||||
|
func (_q *ServerConfigQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||||
|
if _q.ctx.Unique == nil && _q.path != nil {
|
||||||
|
_q.Unique(true)
|
||||||
|
}
|
||||||
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||||
|
if err = _q.Select(serverconfig.FieldID).Scan(ctx, &ids); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ids, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDsX is like IDs, but panics if an error occurs.
|
||||||
|
func (_q *ServerConfigQuery) IDsX(ctx context.Context) []int {
|
||||||
|
ids, err := _q.IDs(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return ids
|
||||||
|
}
|
||||||
|
|
||||||
|
// Count returns the count of the given query.
|
||||||
|
func (_q *ServerConfigQuery) Count(ctx context.Context) (int, error) {
|
||||||
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||||
|
if err := _q.prepareQuery(ctx); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return withInterceptors[int](ctx, _q, querierCount[*ServerConfigQuery](), _q.inters)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountX is like Count, but panics if an error occurs.
|
||||||
|
func (_q *ServerConfigQuery) CountX(ctx context.Context) int {
|
||||||
|
count, err := _q.Count(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exist returns true if the query has elements in the graph.
|
||||||
|
func (_q *ServerConfigQuery) Exist(ctx context.Context) (bool, error) {
|
||||||
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||||
|
switch _, err := _q.FirstID(ctx); {
|
||||||
|
case IsNotFound(err):
|
||||||
|
return false, nil
|
||||||
|
case err != nil:
|
||||||
|
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||||
|
default:
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExistX is like Exist, but panics if an error occurs.
|
||||||
|
func (_q *ServerConfigQuery) ExistX(ctx context.Context) bool {
|
||||||
|
exist, err := _q.Exist(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return exist
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clone returns a duplicate of the ServerConfigQuery builder, including all associated steps. It can be
|
||||||
|
// used to prepare common query builders and use them differently after the clone is made.
|
||||||
|
func (_q *ServerConfigQuery) Clone() *ServerConfigQuery {
|
||||||
|
if _q == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &ServerConfigQuery{
|
||||||
|
config: _q.config,
|
||||||
|
ctx: _q.ctx.Clone(),
|
||||||
|
order: append([]serverconfig.OrderOption{}, _q.order...),
|
||||||
|
inters: append([]Interceptor{}, _q.inters...),
|
||||||
|
predicates: append([]predicate.ServerConfig{}, _q.predicates...),
|
||||||
|
// clone intermediate query.
|
||||||
|
sql: _q.sql.Clone(),
|
||||||
|
path: _q.path,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GroupBy is used to group vertices by one or more fields/columns.
|
||||||
|
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
//
|
||||||
|
// var v []struct {
|
||||||
|
// Key string `json:"key,omitempty"`
|
||||||
|
// Count int `json:"count,omitempty"`
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// client.ServerConfig.Query().
|
||||||
|
// GroupBy(serverconfig.FieldKey).
|
||||||
|
// Aggregate(ent.Count()).
|
||||||
|
// Scan(ctx, &v)
|
||||||
|
func (_q *ServerConfigQuery) GroupBy(field string, fields ...string) *ServerConfigGroupBy {
|
||||||
|
_q.ctx.Fields = append([]string{field}, fields...)
|
||||||
|
grbuild := &ServerConfigGroupBy{build: _q}
|
||||||
|
grbuild.flds = &_q.ctx.Fields
|
||||||
|
grbuild.label = serverconfig.Label
|
||||||
|
grbuild.scan = grbuild.Scan
|
||||||
|
return grbuild
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select allows the selection one or more fields/columns for the given query,
|
||||||
|
// instead of selecting all fields in the entity.
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
//
|
||||||
|
// var v []struct {
|
||||||
|
// Key string `json:"key,omitempty"`
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// client.ServerConfig.Query().
|
||||||
|
// Select(serverconfig.FieldKey).
|
||||||
|
// Scan(ctx, &v)
|
||||||
|
func (_q *ServerConfigQuery) Select(fields ...string) *ServerConfigSelect {
|
||||||
|
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||||
|
sbuild := &ServerConfigSelect{ServerConfigQuery: _q}
|
||||||
|
sbuild.label = serverconfig.Label
|
||||||
|
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||||
|
return sbuild
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate returns a ServerConfigSelect configured with the given aggregations.
|
||||||
|
func (_q *ServerConfigQuery) Aggregate(fns ...AggregateFunc) *ServerConfigSelect {
|
||||||
|
return _q.Select().Aggregate(fns...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *ServerConfigQuery) prepareQuery(ctx context.Context) error {
|
||||||
|
for _, inter := range _q.inters {
|
||||||
|
if inter == nil {
|
||||||
|
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||||
|
}
|
||||||
|
if trv, ok := inter.(Traverser); ok {
|
||||||
|
if err := trv.Traverse(ctx, _q); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, f := range _q.ctx.Fields {
|
||||||
|
if !serverconfig.ValidColumn(f) {
|
||||||
|
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _q.path != nil {
|
||||||
|
prev, err := _q.path(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_q.sql = prev
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *ServerConfigQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ServerConfig, error) {
|
||||||
|
var (
|
||||||
|
nodes = []*ServerConfig{}
|
||||||
|
_spec = _q.querySpec()
|
||||||
|
)
|
||||||
|
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||||
|
return (*ServerConfig).scanValues(nil, columns)
|
||||||
|
}
|
||||||
|
_spec.Assign = func(columns []string, values []any) error {
|
||||||
|
node := &ServerConfig{config: _q.config}
|
||||||
|
nodes = append(nodes, node)
|
||||||
|
return node.assignValues(columns, values)
|
||||||
|
}
|
||||||
|
for i := range hooks {
|
||||||
|
hooks[i](ctx, _spec)
|
||||||
|
}
|
||||||
|
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *ServerConfigQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
|
_spec := _q.querySpec()
|
||||||
|
_spec.Node.Columns = _q.ctx.Fields
|
||||||
|
if len(_q.ctx.Fields) > 0 {
|
||||||
|
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||||
|
}
|
||||||
|
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *ServerConfigQuery) querySpec() *sqlgraph.QuerySpec {
|
||||||
|
_spec := sqlgraph.NewQuerySpec(serverconfig.Table, serverconfig.Columns, sqlgraph.NewFieldSpec(serverconfig.FieldID, field.TypeInt))
|
||||||
|
_spec.From = _q.sql
|
||||||
|
if unique := _q.ctx.Unique; unique != nil {
|
||||||
|
_spec.Unique = *unique
|
||||||
|
} else if _q.path != nil {
|
||||||
|
_spec.Unique = true
|
||||||
|
}
|
||||||
|
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||||
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, serverconfig.FieldID)
|
||||||
|
for i := range fields {
|
||||||
|
if fields[i] != serverconfig.FieldID {
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ps := _q.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if limit := _q.ctx.Limit; limit != nil {
|
||||||
|
_spec.Limit = *limit
|
||||||
|
}
|
||||||
|
if offset := _q.ctx.Offset; offset != nil {
|
||||||
|
_spec.Offset = *offset
|
||||||
|
}
|
||||||
|
if ps := _q.order; len(ps) > 0 {
|
||||||
|
_spec.Order = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _spec
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *ServerConfigQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||||
|
builder := sql.Dialect(_q.driver.Dialect())
|
||||||
|
t1 := builder.Table(serverconfig.Table)
|
||||||
|
columns := _q.ctx.Fields
|
||||||
|
if len(columns) == 0 {
|
||||||
|
columns = serverconfig.Columns
|
||||||
|
}
|
||||||
|
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||||
|
if _q.sql != nil {
|
||||||
|
selector = _q.sql
|
||||||
|
selector.Select(selector.Columns(columns...)...)
|
||||||
|
}
|
||||||
|
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||||
|
selector.Distinct()
|
||||||
|
}
|
||||||
|
for _, p := range _q.predicates {
|
||||||
|
p(selector)
|
||||||
|
}
|
||||||
|
for _, p := range _q.order {
|
||||||
|
p(selector)
|
||||||
|
}
|
||||||
|
if offset := _q.ctx.Offset; offset != nil {
|
||||||
|
// limit is mandatory for offset clause. We start
|
||||||
|
// with default value, and override it below if needed.
|
||||||
|
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||||
|
}
|
||||||
|
if limit := _q.ctx.Limit; limit != nil {
|
||||||
|
selector.Limit(*limit)
|
||||||
|
}
|
||||||
|
return selector
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServerConfigGroupBy is the group-by builder for ServerConfig entities.
|
||||||
|
type ServerConfigGroupBy struct {
|
||||||
|
selector
|
||||||
|
build *ServerConfigQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the group-by query.
|
||||||
|
func (_g *ServerConfigGroupBy) Aggregate(fns ...AggregateFunc) *ServerConfigGroupBy {
|
||||||
|
_g.fns = append(_g.fns, fns...)
|
||||||
|
return _g
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (_g *ServerConfigGroupBy) Scan(ctx context.Context, v any) error {
|
||||||
|
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||||
|
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return scanWithInterceptors[*ServerConfigQuery, *ServerConfigGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_g *ServerConfigGroupBy) sqlScan(ctx context.Context, root *ServerConfigQuery, v any) error {
|
||||||
|
selector := root.sqlQuery(ctx).Select()
|
||||||
|
aggregation := make([]string, 0, len(_g.fns))
|
||||||
|
for _, fn := range _g.fns {
|
||||||
|
aggregation = append(aggregation, fn(selector))
|
||||||
|
}
|
||||||
|
if len(selector.SelectedColumns()) == 0 {
|
||||||
|
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||||
|
for _, f := range *_g.flds {
|
||||||
|
columns = append(columns, selector.C(f))
|
||||||
|
}
|
||||||
|
columns = append(columns, aggregation...)
|
||||||
|
selector.Select(columns...)
|
||||||
|
}
|
||||||
|
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||||
|
if err := selector.Err(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
rows := &sql.Rows{}
|
||||||
|
query, args := selector.Query()
|
||||||
|
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
return sql.ScanSlice(rows, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServerConfigSelect is the builder for selecting fields of ServerConfig entities.
|
||||||
|
type ServerConfigSelect struct {
|
||||||
|
*ServerConfigQuery
|
||||||
|
selector
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the selector query.
|
||||||
|
func (_s *ServerConfigSelect) Aggregate(fns ...AggregateFunc) *ServerConfigSelect {
|
||||||
|
_s.fns = append(_s.fns, fns...)
|
||||||
|
return _s
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (_s *ServerConfigSelect) Scan(ctx context.Context, v any) error {
|
||||||
|
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||||
|
if err := _s.prepareQuery(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return scanWithInterceptors[*ServerConfigQuery, *ServerConfigSelect](ctx, _s.ServerConfigQuery, _s, _s.inters, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_s *ServerConfigSelect) sqlScan(ctx context.Context, root *ServerConfigQuery, v any) error {
|
||||||
|
selector := root.sqlQuery(ctx)
|
||||||
|
aggregation := make([]string, 0, len(_s.fns))
|
||||||
|
for _, fn := range _s.fns {
|
||||||
|
aggregation = append(aggregation, fn(selector))
|
||||||
|
}
|
||||||
|
switch n := len(*_s.selector.flds); {
|
||||||
|
case n == 0 && len(aggregation) > 0:
|
||||||
|
selector.Select(aggregation...)
|
||||||
|
case n != 0 && len(aggregation) > 0:
|
||||||
|
selector.AppendSelect(aggregation...)
|
||||||
|
}
|
||||||
|
rows := &sql.Rows{}
|
||||||
|
query, args := selector.Query()
|
||||||
|
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
return sql.ScanSlice(rows, v)
|
||||||
|
}
|
||||||
@@ -0,0 +1,243 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/predicate"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/serverconfig"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ServerConfigUpdate is the builder for updating ServerConfig entities.
|
||||||
|
type ServerConfigUpdate struct {
|
||||||
|
config
|
||||||
|
hooks []Hook
|
||||||
|
mutation *ServerConfigMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the ServerConfigUpdate builder.
|
||||||
|
func (_u *ServerConfigUpdate) Where(ps ...predicate.ServerConfig) *ServerConfigUpdate {
|
||||||
|
_u.mutation.Where(ps...)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetKey sets the "key" field.
|
||||||
|
func (_u *ServerConfigUpdate) SetKey(v string) *ServerConfigUpdate {
|
||||||
|
_u.mutation.SetKey(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableKey sets the "key" field if the given value is not nil.
|
||||||
|
func (_u *ServerConfigUpdate) SetNillableKey(v *string) *ServerConfigUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetKey(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetValue sets the "value" field.
|
||||||
|
func (_u *ServerConfigUpdate) SetValue(v string) *ServerConfigUpdate {
|
||||||
|
_u.mutation.SetValue(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableValue sets the "value" field if the given value is not nil.
|
||||||
|
func (_u *ServerConfigUpdate) SetNillableValue(v *string) *ServerConfigUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetValue(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the ServerConfigMutation object of the builder.
|
||||||
|
func (_u *ServerConfigUpdate) Mutation() *ServerConfigMutation {
|
||||||
|
return _u.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||||
|
func (_u *ServerConfigUpdate) Save(ctx context.Context) (int, error) {
|
||||||
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (_u *ServerConfigUpdate) SaveX(ctx context.Context) int {
|
||||||
|
affected, err := _u.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return affected
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (_u *ServerConfigUpdate) Exec(ctx context.Context) error {
|
||||||
|
_, err := _u.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_u *ServerConfigUpdate) ExecX(ctx context.Context) {
|
||||||
|
if err := _u.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_u *ServerConfigUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||||
|
_spec := sqlgraph.NewUpdateSpec(serverconfig.Table, serverconfig.Columns, sqlgraph.NewFieldSpec(serverconfig.FieldID, field.TypeInt))
|
||||||
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Key(); ok {
|
||||||
|
_spec.SetField(serverconfig.FieldKey, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Value(); ok {
|
||||||
|
_spec.SetField(serverconfig.FieldValue, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||||
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
|
err = &NotFoundError{serverconfig.Label}
|
||||||
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
_u.mutation.done = true
|
||||||
|
return _node, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServerConfigUpdateOne is the builder for updating a single ServerConfig entity.
|
||||||
|
type ServerConfigUpdateOne struct {
|
||||||
|
config
|
||||||
|
fields []string
|
||||||
|
hooks []Hook
|
||||||
|
mutation *ServerConfigMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetKey sets the "key" field.
|
||||||
|
func (_u *ServerConfigUpdateOne) SetKey(v string) *ServerConfigUpdateOne {
|
||||||
|
_u.mutation.SetKey(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableKey sets the "key" field if the given value is not nil.
|
||||||
|
func (_u *ServerConfigUpdateOne) SetNillableKey(v *string) *ServerConfigUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetKey(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetValue sets the "value" field.
|
||||||
|
func (_u *ServerConfigUpdateOne) SetValue(v string) *ServerConfigUpdateOne {
|
||||||
|
_u.mutation.SetValue(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableValue sets the "value" field if the given value is not nil.
|
||||||
|
func (_u *ServerConfigUpdateOne) SetNillableValue(v *string) *ServerConfigUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetValue(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the ServerConfigMutation object of the builder.
|
||||||
|
func (_u *ServerConfigUpdateOne) Mutation() *ServerConfigMutation {
|
||||||
|
return _u.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the ServerConfigUpdate builder.
|
||||||
|
func (_u *ServerConfigUpdateOne) Where(ps ...predicate.ServerConfig) *ServerConfigUpdateOne {
|
||||||
|
_u.mutation.Where(ps...)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||||
|
// The default is selecting all fields defined in the entity schema.
|
||||||
|
func (_u *ServerConfigUpdateOne) Select(field string, fields ...string) *ServerConfigUpdateOne {
|
||||||
|
_u.fields = append([]string{field}, fields...)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save executes the query and returns the updated ServerConfig entity.
|
||||||
|
func (_u *ServerConfigUpdateOne) Save(ctx context.Context) (*ServerConfig, error) {
|
||||||
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (_u *ServerConfigUpdateOne) SaveX(ctx context.Context) *ServerConfig {
|
||||||
|
node, err := _u.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query on the entity.
|
||||||
|
func (_u *ServerConfigUpdateOne) Exec(ctx context.Context) error {
|
||||||
|
_, err := _u.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_u *ServerConfigUpdateOne) ExecX(ctx context.Context) {
|
||||||
|
if err := _u.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_u *ServerConfigUpdateOne) sqlSave(ctx context.Context) (_node *ServerConfig, err error) {
|
||||||
|
_spec := sqlgraph.NewUpdateSpec(serverconfig.Table, serverconfig.Columns, sqlgraph.NewFieldSpec(serverconfig.FieldID, field.TypeInt))
|
||||||
|
id, ok := _u.mutation.ID()
|
||||||
|
if !ok {
|
||||||
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ServerConfig.id" for update`)}
|
||||||
|
}
|
||||||
|
_spec.Node.ID.Value = id
|
||||||
|
if fields := _u.fields; len(fields) > 0 {
|
||||||
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, serverconfig.FieldID)
|
||||||
|
for _, f := range fields {
|
||||||
|
if !serverconfig.ValidColumn(f) {
|
||||||
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||||
|
}
|
||||||
|
if f != serverconfig.FieldID {
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Key(); ok {
|
||||||
|
_spec.SetField(serverconfig.FieldKey, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Value(); ok {
|
||||||
|
_spec.SetField(serverconfig.FieldValue, field.TypeString, value)
|
||||||
|
}
|
||||||
|
_node = &ServerConfig{config: _u.config}
|
||||||
|
_spec.Assign = _node.assignValues
|
||||||
|
_spec.ScanValues = _node.scanValues
|
||||||
|
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
||||||
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
|
err = &NotFoundError{serverconfig.Label}
|
||||||
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_u.mutation.done = true
|
||||||
|
return _node, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,219 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Tx is a transactional client that is created by calling Client.Tx().
|
||||||
|
type Tx struct {
|
||||||
|
config
|
||||||
|
// FrpcClient is the client for interacting with the FrpcClient builders.
|
||||||
|
FrpcClient *FrpcClientClient
|
||||||
|
// Proxy is the client for interacting with the Proxy builders.
|
||||||
|
Proxy *ProxyClient
|
||||||
|
// ServerConfig is the client for interacting with the ServerConfig builders.
|
||||||
|
ServerConfig *ServerConfigClient
|
||||||
|
// User is the client for interacting with the User builders.
|
||||||
|
User *UserClient
|
||||||
|
|
||||||
|
// lazily loaded.
|
||||||
|
client *Client
|
||||||
|
clientOnce sync.Once
|
||||||
|
// ctx lives for the life of the transaction. It is
|
||||||
|
// the same context used by the underlying connection.
|
||||||
|
ctx context.Context
|
||||||
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
// Committer is the interface that wraps the Commit method.
|
||||||
|
Committer interface {
|
||||||
|
Commit(context.Context, *Tx) error
|
||||||
|
}
|
||||||
|
|
||||||
|
// The CommitFunc type is an adapter to allow the use of ordinary
|
||||||
|
// function as a Committer. If f is a function with the appropriate
|
||||||
|
// signature, CommitFunc(f) is a Committer that calls f.
|
||||||
|
CommitFunc func(context.Context, *Tx) error
|
||||||
|
|
||||||
|
// CommitHook defines the "commit middleware". A function that gets a Committer
|
||||||
|
// and returns a Committer. For example:
|
||||||
|
//
|
||||||
|
// hook := func(next ent.Committer) ent.Committer {
|
||||||
|
// return ent.CommitFunc(func(ctx context.Context, tx *ent.Tx) error {
|
||||||
|
// // Do some stuff before.
|
||||||
|
// if err := next.Commit(ctx, tx); err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// // Do some stuff after.
|
||||||
|
// return nil
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
CommitHook func(Committer) Committer
|
||||||
|
)
|
||||||
|
|
||||||
|
// Commit calls f(ctx, m).
|
||||||
|
func (f CommitFunc) Commit(ctx context.Context, tx *Tx) error {
|
||||||
|
return f(ctx, tx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Commit commits the transaction.
|
||||||
|
func (tx *Tx) Commit() error {
|
||||||
|
txDriver := tx.config.driver.(*txDriver)
|
||||||
|
var fn Committer = CommitFunc(func(context.Context, *Tx) error {
|
||||||
|
return txDriver.tx.Commit()
|
||||||
|
})
|
||||||
|
txDriver.mu.Lock()
|
||||||
|
hooks := append([]CommitHook(nil), txDriver.onCommit...)
|
||||||
|
txDriver.mu.Unlock()
|
||||||
|
for i := len(hooks) - 1; i >= 0; i-- {
|
||||||
|
fn = hooks[i](fn)
|
||||||
|
}
|
||||||
|
return fn.Commit(tx.ctx, tx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnCommit adds a hook to call on commit.
|
||||||
|
func (tx *Tx) OnCommit(f CommitHook) {
|
||||||
|
txDriver := tx.config.driver.(*txDriver)
|
||||||
|
txDriver.mu.Lock()
|
||||||
|
txDriver.onCommit = append(txDriver.onCommit, f)
|
||||||
|
txDriver.mu.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
// Rollbacker is the interface that wraps the Rollback method.
|
||||||
|
Rollbacker interface {
|
||||||
|
Rollback(context.Context, *Tx) error
|
||||||
|
}
|
||||||
|
|
||||||
|
// The RollbackFunc type is an adapter to allow the use of ordinary
|
||||||
|
// function as a Rollbacker. If f is a function with the appropriate
|
||||||
|
// signature, RollbackFunc(f) is a Rollbacker that calls f.
|
||||||
|
RollbackFunc func(context.Context, *Tx) error
|
||||||
|
|
||||||
|
// RollbackHook defines the "rollback middleware". A function that gets a Rollbacker
|
||||||
|
// and returns a Rollbacker. For example:
|
||||||
|
//
|
||||||
|
// hook := func(next ent.Rollbacker) ent.Rollbacker {
|
||||||
|
// return ent.RollbackFunc(func(ctx context.Context, tx *ent.Tx) error {
|
||||||
|
// // Do some stuff before.
|
||||||
|
// if err := next.Rollback(ctx, tx); err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// // Do some stuff after.
|
||||||
|
// return nil
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
RollbackHook func(Rollbacker) Rollbacker
|
||||||
|
)
|
||||||
|
|
||||||
|
// Rollback calls f(ctx, m).
|
||||||
|
func (f RollbackFunc) Rollback(ctx context.Context, tx *Tx) error {
|
||||||
|
return f(ctx, tx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rollback rollbacks the transaction.
|
||||||
|
func (tx *Tx) Rollback() error {
|
||||||
|
txDriver := tx.config.driver.(*txDriver)
|
||||||
|
var fn Rollbacker = RollbackFunc(func(context.Context, *Tx) error {
|
||||||
|
return txDriver.tx.Rollback()
|
||||||
|
})
|
||||||
|
txDriver.mu.Lock()
|
||||||
|
hooks := append([]RollbackHook(nil), txDriver.onRollback...)
|
||||||
|
txDriver.mu.Unlock()
|
||||||
|
for i := len(hooks) - 1; i >= 0; i-- {
|
||||||
|
fn = hooks[i](fn)
|
||||||
|
}
|
||||||
|
return fn.Rollback(tx.ctx, tx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnRollback adds a hook to call on rollback.
|
||||||
|
func (tx *Tx) OnRollback(f RollbackHook) {
|
||||||
|
txDriver := tx.config.driver.(*txDriver)
|
||||||
|
txDriver.mu.Lock()
|
||||||
|
txDriver.onRollback = append(txDriver.onRollback, f)
|
||||||
|
txDriver.mu.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Client returns a Client that binds to current transaction.
|
||||||
|
func (tx *Tx) Client() *Client {
|
||||||
|
tx.clientOnce.Do(func() {
|
||||||
|
tx.client = &Client{config: tx.config}
|
||||||
|
tx.client.init()
|
||||||
|
})
|
||||||
|
return tx.client
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tx *Tx) init() {
|
||||||
|
tx.FrpcClient = NewFrpcClientClient(tx.config)
|
||||||
|
tx.Proxy = NewProxyClient(tx.config)
|
||||||
|
tx.ServerConfig = NewServerConfigClient(tx.config)
|
||||||
|
tx.User = NewUserClient(tx.config)
|
||||||
|
}
|
||||||
|
|
||||||
|
// txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation.
|
||||||
|
// The idea is to support transactions without adding any extra code to the builders.
|
||||||
|
// When a builder calls to driver.Tx(), it gets the same dialect.Tx instance.
|
||||||
|
// Commit and Rollback are nop for the internal builders and the user must call one
|
||||||
|
// of them in order to commit or rollback the transaction.
|
||||||
|
//
|
||||||
|
// If a closed transaction is embedded in one of the generated entities, and the entity
|
||||||
|
// applies a query, for example: FrpcClient.QueryXXX(), the query will be executed
|
||||||
|
// through the driver which created this transaction.
|
||||||
|
//
|
||||||
|
// Note that txDriver is not goroutine safe.
|
||||||
|
type txDriver struct {
|
||||||
|
// the driver we started the transaction from.
|
||||||
|
drv dialect.Driver
|
||||||
|
// tx is the underlying transaction.
|
||||||
|
tx dialect.Tx
|
||||||
|
// completion hooks.
|
||||||
|
mu sync.Mutex
|
||||||
|
onCommit []CommitHook
|
||||||
|
onRollback []RollbackHook
|
||||||
|
}
|
||||||
|
|
||||||
|
// newTx creates a new transactional driver.
|
||||||
|
func newTx(ctx context.Context, drv dialect.Driver) (*txDriver, error) {
|
||||||
|
tx, err := drv.Tx(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &txDriver{tx: tx, drv: drv}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tx returns the transaction wrapper (txDriver) to avoid Commit or Rollback calls
|
||||||
|
// from the internal builders. Should be called only by the internal builders.
|
||||||
|
func (tx *txDriver) Tx(context.Context) (dialect.Tx, error) { return tx, nil }
|
||||||
|
|
||||||
|
// Dialect returns the dialect of the driver we started the transaction from.
|
||||||
|
func (tx *txDriver) Dialect() string { return tx.drv.Dialect() }
|
||||||
|
|
||||||
|
// Close is a nop close.
|
||||||
|
func (*txDriver) Close() error { return nil }
|
||||||
|
|
||||||
|
// Commit is a nop commit for the internal builders.
|
||||||
|
// User must call `Tx.Commit` in order to commit the transaction.
|
||||||
|
func (*txDriver) Commit() error { return nil }
|
||||||
|
|
||||||
|
// Rollback is a nop rollback for the internal builders.
|
||||||
|
// User must call `Tx.Rollback` in order to rollback the transaction.
|
||||||
|
func (*txDriver) Rollback() error { return nil }
|
||||||
|
|
||||||
|
// Exec calls tx.Exec.
|
||||||
|
func (tx *txDriver) Exec(ctx context.Context, query string, args, v any) error {
|
||||||
|
return tx.tx.Exec(ctx, query, args, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Query calls tx.Query.
|
||||||
|
func (tx *txDriver) Query(ctx context.Context, query string, args, v any) error {
|
||||||
|
return tx.tx.Query(ctx, query, args, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ dialect.Driver = (*txDriver)(nil)
|
||||||
@@ -0,0 +1,161 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// User is the model entity for the User schema.
|
||||||
|
type User struct {
|
||||||
|
config `json:"-"`
|
||||||
|
// ID of the ent.
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
// Username holds the value of the "username" field.
|
||||||
|
Username string `json:"username,omitempty"`
|
||||||
|
// Password holds the value of the "password" field.
|
||||||
|
Password string `json:"password,omitempty"`
|
||||||
|
// Name holds the value of the "name" field.
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
// Role holds the value of the "role" field.
|
||||||
|
Role string `json:"role,omitempty"`
|
||||||
|
// CreatedAt holds the value of the "created_at" field.
|
||||||
|
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||||
|
// UpdatedAt holds the value of the "updated_at" field.
|
||||||
|
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||||
|
selectValues sql.SelectValues
|
||||||
|
}
|
||||||
|
|
||||||
|
// scanValues returns the types for scanning values from sql.Rows.
|
||||||
|
func (*User) scanValues(columns []string) ([]any, error) {
|
||||||
|
values := make([]any, len(columns))
|
||||||
|
for i := range columns {
|
||||||
|
switch columns[i] {
|
||||||
|
case user.FieldID:
|
||||||
|
values[i] = new(sql.NullInt64)
|
||||||
|
case user.FieldUsername, user.FieldPassword, user.FieldName, user.FieldRole:
|
||||||
|
values[i] = new(sql.NullString)
|
||||||
|
case user.FieldCreatedAt, user.FieldUpdatedAt:
|
||||||
|
values[i] = new(sql.NullTime)
|
||||||
|
default:
|
||||||
|
values[i] = new(sql.UnknownType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return values, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||||
|
// to the User fields.
|
||||||
|
func (_m *User) assignValues(columns []string, values []any) error {
|
||||||
|
if m, n := len(values), len(columns); m < n {
|
||||||
|
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||||
|
}
|
||||||
|
for i := range columns {
|
||||||
|
switch columns[i] {
|
||||||
|
case user.FieldID:
|
||||||
|
value, ok := values[i].(*sql.NullInt64)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field id", value)
|
||||||
|
}
|
||||||
|
_m.ID = int(value.Int64)
|
||||||
|
case user.FieldUsername:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field username", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.Username = value.String
|
||||||
|
}
|
||||||
|
case user.FieldPassword:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field password", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.Password = value.String
|
||||||
|
}
|
||||||
|
case user.FieldName:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.Name = value.String
|
||||||
|
}
|
||||||
|
case user.FieldRole:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field role", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.Role = value.String
|
||||||
|
}
|
||||||
|
case user.FieldCreatedAt:
|
||||||
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.CreatedAt = value.Time
|
||||||
|
}
|
||||||
|
case user.FieldUpdatedAt:
|
||||||
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
_m.UpdatedAt = value.Time
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
_m.selectValues.Set(columns[i], values[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value returns the ent.Value that was dynamically selected and assigned to the User.
|
||||||
|
// This includes values selected through modifiers, order, etc.
|
||||||
|
func (_m *User) Value(name string) (ent.Value, error) {
|
||||||
|
return _m.selectValues.Get(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update returns a builder for updating this User.
|
||||||
|
// Note that you need to call User.Unwrap() before calling this method if this User
|
||||||
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||||
|
func (_m *User) Update() *UserUpdateOne {
|
||||||
|
return NewUserClient(_m.config).UpdateOne(_m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unwrap unwraps the User entity that was returned from a transaction after it was closed,
|
||||||
|
// so that all future queries will be executed through the driver which created the transaction.
|
||||||
|
func (_m *User) Unwrap() *User {
|
||||||
|
_tx, ok := _m.config.driver.(*txDriver)
|
||||||
|
if !ok {
|
||||||
|
panic("ent: User is not a transactional entity")
|
||||||
|
}
|
||||||
|
_m.config.driver = _tx.drv
|
||||||
|
return _m
|
||||||
|
}
|
||||||
|
|
||||||
|
// String implements the fmt.Stringer.
|
||||||
|
func (_m *User) String() string {
|
||||||
|
var builder strings.Builder
|
||||||
|
builder.WriteString("User(")
|
||||||
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||||
|
builder.WriteString("username=")
|
||||||
|
builder.WriteString(_m.Username)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("password=")
|
||||||
|
builder.WriteString(_m.Password)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("name=")
|
||||||
|
builder.WriteString(_m.Name)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("role=")
|
||||||
|
builder.WriteString(_m.Role)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("created_at=")
|
||||||
|
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("updated_at=")
|
||||||
|
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
||||||
|
builder.WriteByte(')')
|
||||||
|
return builder.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Users is a parsable slice of User.
|
||||||
|
type Users []*User
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package user
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Label holds the string label denoting the user type in the database.
|
||||||
|
Label = "user"
|
||||||
|
// FieldID holds the string denoting the id field in the database.
|
||||||
|
FieldID = "id"
|
||||||
|
// FieldUsername holds the string denoting the username field in the database.
|
||||||
|
FieldUsername = "username"
|
||||||
|
// FieldPassword holds the string denoting the password field in the database.
|
||||||
|
FieldPassword = "password"
|
||||||
|
// FieldName holds the string denoting the name field in the database.
|
||||||
|
FieldName = "name"
|
||||||
|
// FieldRole holds the string denoting the role field in the database.
|
||||||
|
FieldRole = "role"
|
||||||
|
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||||
|
FieldCreatedAt = "created_at"
|
||||||
|
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||||
|
FieldUpdatedAt = "updated_at"
|
||||||
|
// Table holds the table name of the user in the database.
|
||||||
|
Table = "users"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Columns holds all SQL columns for user fields.
|
||||||
|
var Columns = []string{
|
||||||
|
FieldID,
|
||||||
|
FieldUsername,
|
||||||
|
FieldPassword,
|
||||||
|
FieldName,
|
||||||
|
FieldRole,
|
||||||
|
FieldCreatedAt,
|
||||||
|
FieldUpdatedAt,
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||||
|
func ValidColumn(column string) bool {
|
||||||
|
for i := range Columns {
|
||||||
|
if column == Columns[i] {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// DefaultName holds the default value on creation for the "name" field.
|
||||||
|
DefaultName string
|
||||||
|
// DefaultRole holds the default value on creation for the "role" field.
|
||||||
|
DefaultRole string
|
||||||
|
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||||
|
DefaultCreatedAt func() time.Time
|
||||||
|
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
||||||
|
DefaultUpdatedAt func() time.Time
|
||||||
|
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
|
||||||
|
UpdateDefaultUpdatedAt func() time.Time
|
||||||
|
)
|
||||||
|
|
||||||
|
// OrderOption defines the ordering options for the User queries.
|
||||||
|
type OrderOption func(*sql.Selector)
|
||||||
|
|
||||||
|
// ByID orders the results by the id field.
|
||||||
|
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByUsername orders the results by the username field.
|
||||||
|
func ByUsername(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldUsername, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByPassword orders the results by the password field.
|
||||||
|
func ByPassword(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldPassword, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByName orders the results by the name field.
|
||||||
|
func ByName(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldName, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByRole orders the results by the role field.
|
||||||
|
func ByRole(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldRole, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByCreatedAt orders the results by the created_at field.
|
||||||
|
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByUpdatedAt orders the results by the updated_at field.
|
||||||
|
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
|
||||||
|
}
|
||||||
@@ -0,0 +1,440 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package user
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/predicate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ID filters vertices based on their ID field.
|
||||||
|
func ID(id int) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDEQ applies the EQ predicate on the ID field.
|
||||||
|
func IDEQ(id int) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDNEQ applies the NEQ predicate on the ID field.
|
||||||
|
func IDNEQ(id int) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDIn applies the In predicate on the ID field.
|
||||||
|
func IDIn(ids ...int) predicate.User {
|
||||||
|
return predicate.User(sql.FieldIn(FieldID, ids...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDNotIn applies the NotIn predicate on the ID field.
|
||||||
|
func IDNotIn(ids ...int) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNotIn(FieldID, ids...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDGT applies the GT predicate on the ID field.
|
||||||
|
func IDGT(id int) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGT(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDGTE applies the GTE predicate on the ID field.
|
||||||
|
func IDGTE(id int) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGTE(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDLT applies the LT predicate on the ID field.
|
||||||
|
func IDLT(id int) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLT(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDLTE applies the LTE predicate on the ID field.
|
||||||
|
func IDLTE(id int) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLTE(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Username applies equality check predicate on the "username" field. It's identical to UsernameEQ.
|
||||||
|
func Username(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldUsername, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Password applies equality check predicate on the "password" field. It's identical to PasswordEQ.
|
||||||
|
func Password(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldPassword, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
|
||||||
|
func Name(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Role applies equality check predicate on the "role" field. It's identical to RoleEQ.
|
||||||
|
func Role(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldRole, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||||
|
func CreatedAt(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
|
||||||
|
func UpdatedAt(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UsernameEQ applies the EQ predicate on the "username" field.
|
||||||
|
func UsernameEQ(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldUsername, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UsernameNEQ applies the NEQ predicate on the "username" field.
|
||||||
|
func UsernameNEQ(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNEQ(FieldUsername, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UsernameIn applies the In predicate on the "username" field.
|
||||||
|
func UsernameIn(vs ...string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldIn(FieldUsername, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UsernameNotIn applies the NotIn predicate on the "username" field.
|
||||||
|
func UsernameNotIn(vs ...string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNotIn(FieldUsername, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UsernameGT applies the GT predicate on the "username" field.
|
||||||
|
func UsernameGT(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGT(FieldUsername, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UsernameGTE applies the GTE predicate on the "username" field.
|
||||||
|
func UsernameGTE(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGTE(FieldUsername, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UsernameLT applies the LT predicate on the "username" field.
|
||||||
|
func UsernameLT(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLT(FieldUsername, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UsernameLTE applies the LTE predicate on the "username" field.
|
||||||
|
func UsernameLTE(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLTE(FieldUsername, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UsernameContains applies the Contains predicate on the "username" field.
|
||||||
|
func UsernameContains(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldContains(FieldUsername, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UsernameHasPrefix applies the HasPrefix predicate on the "username" field.
|
||||||
|
func UsernameHasPrefix(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldHasPrefix(FieldUsername, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UsernameHasSuffix applies the HasSuffix predicate on the "username" field.
|
||||||
|
func UsernameHasSuffix(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldHasSuffix(FieldUsername, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UsernameEqualFold applies the EqualFold predicate on the "username" field.
|
||||||
|
func UsernameEqualFold(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEqualFold(FieldUsername, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UsernameContainsFold applies the ContainsFold predicate on the "username" field.
|
||||||
|
func UsernameContainsFold(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldContainsFold(FieldUsername, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PasswordEQ applies the EQ predicate on the "password" field.
|
||||||
|
func PasswordEQ(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldPassword, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PasswordNEQ applies the NEQ predicate on the "password" field.
|
||||||
|
func PasswordNEQ(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNEQ(FieldPassword, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PasswordIn applies the In predicate on the "password" field.
|
||||||
|
func PasswordIn(vs ...string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldIn(FieldPassword, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PasswordNotIn applies the NotIn predicate on the "password" field.
|
||||||
|
func PasswordNotIn(vs ...string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNotIn(FieldPassword, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PasswordGT applies the GT predicate on the "password" field.
|
||||||
|
func PasswordGT(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGT(FieldPassword, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PasswordGTE applies the GTE predicate on the "password" field.
|
||||||
|
func PasswordGTE(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGTE(FieldPassword, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PasswordLT applies the LT predicate on the "password" field.
|
||||||
|
func PasswordLT(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLT(FieldPassword, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PasswordLTE applies the LTE predicate on the "password" field.
|
||||||
|
func PasswordLTE(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLTE(FieldPassword, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PasswordContains applies the Contains predicate on the "password" field.
|
||||||
|
func PasswordContains(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldContains(FieldPassword, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PasswordHasPrefix applies the HasPrefix predicate on the "password" field.
|
||||||
|
func PasswordHasPrefix(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldHasPrefix(FieldPassword, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PasswordHasSuffix applies the HasSuffix predicate on the "password" field.
|
||||||
|
func PasswordHasSuffix(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldHasSuffix(FieldPassword, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PasswordEqualFold applies the EqualFold predicate on the "password" field.
|
||||||
|
func PasswordEqualFold(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEqualFold(FieldPassword, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PasswordContainsFold applies the ContainsFold predicate on the "password" field.
|
||||||
|
func PasswordContainsFold(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldContainsFold(FieldPassword, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameEQ applies the EQ predicate on the "name" field.
|
||||||
|
func NameEQ(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameNEQ applies the NEQ predicate on the "name" field.
|
||||||
|
func NameNEQ(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNEQ(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameIn applies the In predicate on the "name" field.
|
||||||
|
func NameIn(vs ...string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldIn(FieldName, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameNotIn applies the NotIn predicate on the "name" field.
|
||||||
|
func NameNotIn(vs ...string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNotIn(FieldName, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameGT applies the GT predicate on the "name" field.
|
||||||
|
func NameGT(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGT(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameGTE applies the GTE predicate on the "name" field.
|
||||||
|
func NameGTE(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGTE(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameLT applies the LT predicate on the "name" field.
|
||||||
|
func NameLT(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLT(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameLTE applies the LTE predicate on the "name" field.
|
||||||
|
func NameLTE(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLTE(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameContains applies the Contains predicate on the "name" field.
|
||||||
|
func NameContains(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldContains(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
|
||||||
|
func NameHasPrefix(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldHasPrefix(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
|
||||||
|
func NameHasSuffix(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldHasSuffix(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameEqualFold applies the EqualFold predicate on the "name" field.
|
||||||
|
func NameEqualFold(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEqualFold(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameContainsFold applies the ContainsFold predicate on the "name" field.
|
||||||
|
func NameContainsFold(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldContainsFold(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoleEQ applies the EQ predicate on the "role" field.
|
||||||
|
func RoleEQ(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldRole, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoleNEQ applies the NEQ predicate on the "role" field.
|
||||||
|
func RoleNEQ(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNEQ(FieldRole, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoleIn applies the In predicate on the "role" field.
|
||||||
|
func RoleIn(vs ...string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldIn(FieldRole, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoleNotIn applies the NotIn predicate on the "role" field.
|
||||||
|
func RoleNotIn(vs ...string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNotIn(FieldRole, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoleGT applies the GT predicate on the "role" field.
|
||||||
|
func RoleGT(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGT(FieldRole, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoleGTE applies the GTE predicate on the "role" field.
|
||||||
|
func RoleGTE(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGTE(FieldRole, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoleLT applies the LT predicate on the "role" field.
|
||||||
|
func RoleLT(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLT(FieldRole, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoleLTE applies the LTE predicate on the "role" field.
|
||||||
|
func RoleLTE(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLTE(FieldRole, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoleContains applies the Contains predicate on the "role" field.
|
||||||
|
func RoleContains(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldContains(FieldRole, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoleHasPrefix applies the HasPrefix predicate on the "role" field.
|
||||||
|
func RoleHasPrefix(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldHasPrefix(FieldRole, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoleHasSuffix applies the HasSuffix predicate on the "role" field.
|
||||||
|
func RoleHasSuffix(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldHasSuffix(FieldRole, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoleEqualFold applies the EqualFold predicate on the "role" field.
|
||||||
|
func RoleEqualFold(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEqualFold(FieldRole, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoleContainsFold applies the ContainsFold predicate on the "role" field.
|
||||||
|
func RoleContainsFold(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldContainsFold(FieldRole, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||||
|
func CreatedAtEQ(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
|
||||||
|
func CreatedAtNEQ(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNEQ(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||||
|
func CreatedAtIn(vs ...time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldIn(FieldCreatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||||
|
func CreatedAtNotIn(vs ...time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNotIn(FieldCreatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtGT applies the GT predicate on the "created_at" field.
|
||||||
|
func CreatedAtGT(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGT(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
|
||||||
|
func CreatedAtGTE(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGTE(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtLT applies the LT predicate on the "created_at" field.
|
||||||
|
func CreatedAtLT(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLT(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
|
||||||
|
func CreatedAtLTE(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLTE(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtEQ(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtNEQ(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNEQ(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtIn(vs ...time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldIn(FieldUpdatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtNotIn(vs ...time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNotIn(FieldUpdatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtGT(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGT(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtGTE(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGTE(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtLT(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLT(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtLTE(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLTE(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// And groups predicates with the AND operator between them.
|
||||||
|
func And(predicates ...predicate.User) predicate.User {
|
||||||
|
return predicate.User(sql.AndPredicates(predicates...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Or groups predicates with the OR operator between them.
|
||||||
|
func Or(predicates ...predicate.User) predicate.User {
|
||||||
|
return predicate.User(sql.OrPredicates(predicates...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not applies the not operator on the given predicate.
|
||||||
|
func Not(p predicate.User) predicate.User {
|
||||||
|
return predicate.User(sql.NotPredicates(p))
|
||||||
|
}
|
||||||
@@ -0,0 +1,303 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserCreate is the builder for creating a User entity.
|
||||||
|
type UserCreate struct {
|
||||||
|
config
|
||||||
|
mutation *UserMutation
|
||||||
|
hooks []Hook
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUsername sets the "username" field.
|
||||||
|
func (_c *UserCreate) SetUsername(v string) *UserCreate {
|
||||||
|
_c.mutation.SetUsername(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPassword sets the "password" field.
|
||||||
|
func (_c *UserCreate) SetPassword(v string) *UserCreate {
|
||||||
|
_c.mutation.SetPassword(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetName sets the "name" field.
|
||||||
|
func (_c *UserCreate) SetName(v string) *UserCreate {
|
||||||
|
_c.mutation.SetName(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableName sets the "name" field if the given value is not nil.
|
||||||
|
func (_c *UserCreate) SetNillableName(v *string) *UserCreate {
|
||||||
|
if v != nil {
|
||||||
|
_c.SetName(*v)
|
||||||
|
}
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRole sets the "role" field.
|
||||||
|
func (_c *UserCreate) SetRole(v string) *UserCreate {
|
||||||
|
_c.mutation.SetRole(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableRole sets the "role" field if the given value is not nil.
|
||||||
|
func (_c *UserCreate) SetNillableRole(v *string) *UserCreate {
|
||||||
|
if v != nil {
|
||||||
|
_c.SetRole(*v)
|
||||||
|
}
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCreatedAt sets the "created_at" field.
|
||||||
|
func (_c *UserCreate) SetCreatedAt(v time.Time) *UserCreate {
|
||||||
|
_c.mutation.SetCreatedAt(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||||
|
func (_c *UserCreate) SetNillableCreatedAt(v *time.Time) *UserCreate {
|
||||||
|
if v != nil {
|
||||||
|
_c.SetCreatedAt(*v)
|
||||||
|
}
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUpdatedAt sets the "updated_at" field.
|
||||||
|
func (_c *UserCreate) SetUpdatedAt(v time.Time) *UserCreate {
|
||||||
|
_c.mutation.SetUpdatedAt(v)
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||||
|
func (_c *UserCreate) SetNillableUpdatedAt(v *time.Time) *UserCreate {
|
||||||
|
if v != nil {
|
||||||
|
_c.SetUpdatedAt(*v)
|
||||||
|
}
|
||||||
|
return _c
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the UserMutation object of the builder.
|
||||||
|
func (_c *UserCreate) Mutation() *UserMutation {
|
||||||
|
return _c.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save creates the User in the database.
|
||||||
|
func (_c *UserCreate) Save(ctx context.Context) (*User, error) {
|
||||||
|
_c.defaults()
|
||||||
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX calls Save and panics if Save returns an error.
|
||||||
|
func (_c *UserCreate) SaveX(ctx context.Context) *User {
|
||||||
|
v, err := _c.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (_c *UserCreate) Exec(ctx context.Context) error {
|
||||||
|
_, err := _c.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_c *UserCreate) ExecX(ctx context.Context) {
|
||||||
|
if err := _c.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// defaults sets the default values of the builder before save.
|
||||||
|
func (_c *UserCreate) defaults() {
|
||||||
|
if _, ok := _c.mutation.Name(); !ok {
|
||||||
|
v := user.DefaultName
|
||||||
|
_c.mutation.SetName(v)
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.Role(); !ok {
|
||||||
|
v := user.DefaultRole
|
||||||
|
_c.mutation.SetRole(v)
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||||
|
v := user.DefaultCreatedAt()
|
||||||
|
_c.mutation.SetCreatedAt(v)
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||||
|
v := user.DefaultUpdatedAt()
|
||||||
|
_c.mutation.SetUpdatedAt(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check runs all checks and user-defined validators on the builder.
|
||||||
|
func (_c *UserCreate) check() error {
|
||||||
|
if _, ok := _c.mutation.Username(); !ok {
|
||||||
|
return &ValidationError{Name: "username", err: errors.New(`ent: missing required field "User.username"`)}
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.Password(); !ok {
|
||||||
|
return &ValidationError{Name: "password", err: errors.New(`ent: missing required field "User.password"`)}
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.Name(); !ok {
|
||||||
|
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "User.name"`)}
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.Role(); !ok {
|
||||||
|
return &ValidationError{Name: "role", err: errors.New(`ent: missing required field "User.role"`)}
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||||
|
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "User.created_at"`)}
|
||||||
|
}
|
||||||
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||||
|
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "User.updated_at"`)}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_c *UserCreate) sqlSave(ctx context.Context) (*User, error) {
|
||||||
|
if err := _c.check(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_node, _spec := _c.createSpec()
|
||||||
|
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||||
|
if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
id := _spec.ID.Value.(int64)
|
||||||
|
_node.ID = int(id)
|
||||||
|
_c.mutation.id = &_node.ID
|
||||||
|
_c.mutation.done = true
|
||||||
|
return _node, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_c *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
|
||||||
|
var (
|
||||||
|
_node = &User{config: _c.config}
|
||||||
|
_spec = sqlgraph.NewCreateSpec(user.Table, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt))
|
||||||
|
)
|
||||||
|
if value, ok := _c.mutation.Username(); ok {
|
||||||
|
_spec.SetField(user.FieldUsername, field.TypeString, value)
|
||||||
|
_node.Username = value
|
||||||
|
}
|
||||||
|
if value, ok := _c.mutation.Password(); ok {
|
||||||
|
_spec.SetField(user.FieldPassword, field.TypeString, value)
|
||||||
|
_node.Password = value
|
||||||
|
}
|
||||||
|
if value, ok := _c.mutation.Name(); ok {
|
||||||
|
_spec.SetField(user.FieldName, field.TypeString, value)
|
||||||
|
_node.Name = value
|
||||||
|
}
|
||||||
|
if value, ok := _c.mutation.Role(); ok {
|
||||||
|
_spec.SetField(user.FieldRole, field.TypeString, value)
|
||||||
|
_node.Role = value
|
||||||
|
}
|
||||||
|
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||||
|
_spec.SetField(user.FieldCreatedAt, field.TypeTime, value)
|
||||||
|
_node.CreatedAt = value
|
||||||
|
}
|
||||||
|
if value, ok := _c.mutation.UpdatedAt(); ok {
|
||||||
|
_spec.SetField(user.FieldUpdatedAt, field.TypeTime, value)
|
||||||
|
_node.UpdatedAt = value
|
||||||
|
}
|
||||||
|
return _node, _spec
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserCreateBulk is the builder for creating many User entities in bulk.
|
||||||
|
type UserCreateBulk struct {
|
||||||
|
config
|
||||||
|
err error
|
||||||
|
builders []*UserCreate
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save creates the User entities in the database.
|
||||||
|
func (_c *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
|
||||||
|
if _c.err != nil {
|
||||||
|
return nil, _c.err
|
||||||
|
}
|
||||||
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||||
|
nodes := make([]*User, len(_c.builders))
|
||||||
|
mutators := make([]Mutator, len(_c.builders))
|
||||||
|
for i := range _c.builders {
|
||||||
|
func(i int, root context.Context) {
|
||||||
|
builder := _c.builders[i]
|
||||||
|
builder.defaults()
|
||||||
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||||
|
mutation, ok := m.(*UserMutation)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||||
|
}
|
||||||
|
if err := builder.check(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
builder.mutation = mutation
|
||||||
|
var err error
|
||||||
|
nodes[i], specs[i] = builder.createSpec()
|
||||||
|
if i < len(mutators)-1 {
|
||||||
|
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||||
|
} else {
|
||||||
|
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||||
|
// Invoke the actual operation on the latest mutation in the chain.
|
||||||
|
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||||
|
if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
mutation.id = &nodes[i].ID
|
||||||
|
if specs[i].ID.Value != nil {
|
||||||
|
id := specs[i].ID.Value.(int64)
|
||||||
|
nodes[i].ID = int(id)
|
||||||
|
}
|
||||||
|
mutation.done = true
|
||||||
|
return nodes[i], nil
|
||||||
|
})
|
||||||
|
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||||
|
mut = builder.hooks[i](mut)
|
||||||
|
}
|
||||||
|
mutators[i] = mut
|
||||||
|
}(i, ctx)
|
||||||
|
}
|
||||||
|
if len(mutators) > 0 {
|
||||||
|
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (_c *UserCreateBulk) SaveX(ctx context.Context) []*User {
|
||||||
|
v, err := _c.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (_c *UserCreateBulk) Exec(ctx context.Context) error {
|
||||||
|
_, err := _c.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_c *UserCreateBulk) ExecX(ctx context.Context) {
|
||||||
|
if err := _c.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/predicate"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserDelete is the builder for deleting a User entity.
|
||||||
|
type UserDelete struct {
|
||||||
|
config
|
||||||
|
hooks []Hook
|
||||||
|
mutation *UserMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the UserDelete builder.
|
||||||
|
func (_d *UserDelete) Where(ps ...predicate.User) *UserDelete {
|
||||||
|
_d.mutation.Where(ps...)
|
||||||
|
return _d
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||||
|
func (_d *UserDelete) Exec(ctx context.Context) (int, error) {
|
||||||
|
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_d *UserDelete) ExecX(ctx context.Context) int {
|
||||||
|
n, err := _d.Exec(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_d *UserDelete) sqlExec(ctx context.Context) (int, error) {
|
||||||
|
_spec := sqlgraph.NewDeleteSpec(user.Table, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt))
|
||||||
|
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||||
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
_d.mutation.done = true
|
||||||
|
return affected, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserDeleteOne is the builder for deleting a single User entity.
|
||||||
|
type UserDeleteOne struct {
|
||||||
|
_d *UserDelete
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the UserDelete builder.
|
||||||
|
func (_d *UserDeleteOne) Where(ps ...predicate.User) *UserDeleteOne {
|
||||||
|
_d._d.mutation.Where(ps...)
|
||||||
|
return _d
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query.
|
||||||
|
func (_d *UserDeleteOne) Exec(ctx context.Context) error {
|
||||||
|
n, err := _d._d.Exec(ctx)
|
||||||
|
switch {
|
||||||
|
case err != nil:
|
||||||
|
return err
|
||||||
|
case n == 0:
|
||||||
|
return &NotFoundError{user.Label}
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_d *UserDeleteOne) ExecX(ctx context.Context) {
|
||||||
|
if err := _d.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,527 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"math"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/predicate"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserQuery is the builder for querying User entities.
|
||||||
|
type UserQuery struct {
|
||||||
|
config
|
||||||
|
ctx *QueryContext
|
||||||
|
order []user.OrderOption
|
||||||
|
inters []Interceptor
|
||||||
|
predicates []predicate.User
|
||||||
|
// intermediate query (i.e. traversal path).
|
||||||
|
sql *sql.Selector
|
||||||
|
path func(context.Context) (*sql.Selector, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where adds a new predicate for the UserQuery builder.
|
||||||
|
func (_q *UserQuery) Where(ps ...predicate.User) *UserQuery {
|
||||||
|
_q.predicates = append(_q.predicates, ps...)
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// Limit the number of records to be returned by this query.
|
||||||
|
func (_q *UserQuery) Limit(limit int) *UserQuery {
|
||||||
|
_q.ctx.Limit = &limit
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// Offset to start from.
|
||||||
|
func (_q *UserQuery) Offset(offset int) *UserQuery {
|
||||||
|
_q.ctx.Offset = &offset
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unique configures the query builder to filter duplicate records on query.
|
||||||
|
// By default, unique is set to true, and can be disabled using this method.
|
||||||
|
func (_q *UserQuery) Unique(unique bool) *UserQuery {
|
||||||
|
_q.ctx.Unique = &unique
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// Order specifies how the records should be ordered.
|
||||||
|
func (_q *UserQuery) Order(o ...user.OrderOption) *UserQuery {
|
||||||
|
_q.order = append(_q.order, o...)
|
||||||
|
return _q
|
||||||
|
}
|
||||||
|
|
||||||
|
// First returns the first User entity from the query.
|
||||||
|
// Returns a *NotFoundError when no User was found.
|
||||||
|
func (_q *UserQuery) First(ctx context.Context) (*User, error) {
|
||||||
|
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return nil, &NotFoundError{user.Label}
|
||||||
|
}
|
||||||
|
return nodes[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstX is like First, but panics if an error occurs.
|
||||||
|
func (_q *UserQuery) FirstX(ctx context.Context) *User {
|
||||||
|
node, err := _q.First(ctx)
|
||||||
|
if err != nil && !IsNotFound(err) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstID returns the first User ID from the query.
|
||||||
|
// Returns a *NotFoundError when no User ID was found.
|
||||||
|
func (_q *UserQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||||
|
var ids []int
|
||||||
|
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(ids) == 0 {
|
||||||
|
err = &NotFoundError{user.Label}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return ids[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||||
|
func (_q *UserQuery) FirstIDX(ctx context.Context) int {
|
||||||
|
id, err := _q.FirstID(ctx)
|
||||||
|
if err != nil && !IsNotFound(err) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only returns a single User entity found by the query, ensuring it only returns one.
|
||||||
|
// Returns a *NotSingularError when more than one User entity is found.
|
||||||
|
// Returns a *NotFoundError when no User entities are found.
|
||||||
|
func (_q *UserQuery) Only(ctx context.Context) (*User, error) {
|
||||||
|
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
switch len(nodes) {
|
||||||
|
case 1:
|
||||||
|
return nodes[0], nil
|
||||||
|
case 0:
|
||||||
|
return nil, &NotFoundError{user.Label}
|
||||||
|
default:
|
||||||
|
return nil, &NotSingularError{user.Label}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyX is like Only, but panics if an error occurs.
|
||||||
|
func (_q *UserQuery) OnlyX(ctx context.Context) *User {
|
||||||
|
node, err := _q.Only(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyID is like Only, but returns the only User ID in the query.
|
||||||
|
// Returns a *NotSingularError when more than one User ID is found.
|
||||||
|
// Returns a *NotFoundError when no entities are found.
|
||||||
|
func (_q *UserQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||||
|
var ids []int
|
||||||
|
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch len(ids) {
|
||||||
|
case 1:
|
||||||
|
id = ids[0]
|
||||||
|
case 0:
|
||||||
|
err = &NotFoundError{user.Label}
|
||||||
|
default:
|
||||||
|
err = &NotSingularError{user.Label}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||||
|
func (_q *UserQuery) OnlyIDX(ctx context.Context) int {
|
||||||
|
id, err := _q.OnlyID(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// All executes the query and returns a list of Users.
|
||||||
|
func (_q *UserQuery) All(ctx context.Context) ([]*User, error) {
|
||||||
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||||
|
if err := _q.prepareQuery(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
qr := querierAll[[]*User, *UserQuery]()
|
||||||
|
return withInterceptors[[]*User](ctx, _q, qr, _q.inters)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AllX is like All, but panics if an error occurs.
|
||||||
|
func (_q *UserQuery) AllX(ctx context.Context) []*User {
|
||||||
|
nodes, err := _q.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return nodes
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs executes the query and returns a list of User IDs.
|
||||||
|
func (_q *UserQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||||
|
if _q.ctx.Unique == nil && _q.path != nil {
|
||||||
|
_q.Unique(true)
|
||||||
|
}
|
||||||
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||||
|
if err = _q.Select(user.FieldID).Scan(ctx, &ids); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ids, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDsX is like IDs, but panics if an error occurs.
|
||||||
|
func (_q *UserQuery) IDsX(ctx context.Context) []int {
|
||||||
|
ids, err := _q.IDs(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return ids
|
||||||
|
}
|
||||||
|
|
||||||
|
// Count returns the count of the given query.
|
||||||
|
func (_q *UserQuery) Count(ctx context.Context) (int, error) {
|
||||||
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||||
|
if err := _q.prepareQuery(ctx); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return withInterceptors[int](ctx, _q, querierCount[*UserQuery](), _q.inters)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountX is like Count, but panics if an error occurs.
|
||||||
|
func (_q *UserQuery) CountX(ctx context.Context) int {
|
||||||
|
count, err := _q.Count(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exist returns true if the query has elements in the graph.
|
||||||
|
func (_q *UserQuery) Exist(ctx context.Context) (bool, error) {
|
||||||
|
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||||
|
switch _, err := _q.FirstID(ctx); {
|
||||||
|
case IsNotFound(err):
|
||||||
|
return false, nil
|
||||||
|
case err != nil:
|
||||||
|
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||||
|
default:
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExistX is like Exist, but panics if an error occurs.
|
||||||
|
func (_q *UserQuery) ExistX(ctx context.Context) bool {
|
||||||
|
exist, err := _q.Exist(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return exist
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clone returns a duplicate of the UserQuery builder, including all associated steps. It can be
|
||||||
|
// used to prepare common query builders and use them differently after the clone is made.
|
||||||
|
func (_q *UserQuery) Clone() *UserQuery {
|
||||||
|
if _q == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &UserQuery{
|
||||||
|
config: _q.config,
|
||||||
|
ctx: _q.ctx.Clone(),
|
||||||
|
order: append([]user.OrderOption{}, _q.order...),
|
||||||
|
inters: append([]Interceptor{}, _q.inters...),
|
||||||
|
predicates: append([]predicate.User{}, _q.predicates...),
|
||||||
|
// clone intermediate query.
|
||||||
|
sql: _q.sql.Clone(),
|
||||||
|
path: _q.path,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GroupBy is used to group vertices by one or more fields/columns.
|
||||||
|
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
//
|
||||||
|
// var v []struct {
|
||||||
|
// Username string `json:"username,omitempty"`
|
||||||
|
// Count int `json:"count,omitempty"`
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// client.User.Query().
|
||||||
|
// GroupBy(user.FieldUsername).
|
||||||
|
// Aggregate(ent.Count()).
|
||||||
|
// Scan(ctx, &v)
|
||||||
|
func (_q *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy {
|
||||||
|
_q.ctx.Fields = append([]string{field}, fields...)
|
||||||
|
grbuild := &UserGroupBy{build: _q}
|
||||||
|
grbuild.flds = &_q.ctx.Fields
|
||||||
|
grbuild.label = user.Label
|
||||||
|
grbuild.scan = grbuild.Scan
|
||||||
|
return grbuild
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select allows the selection one or more fields/columns for the given query,
|
||||||
|
// instead of selecting all fields in the entity.
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
//
|
||||||
|
// var v []struct {
|
||||||
|
// Username string `json:"username,omitempty"`
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// client.User.Query().
|
||||||
|
// Select(user.FieldUsername).
|
||||||
|
// Scan(ctx, &v)
|
||||||
|
func (_q *UserQuery) Select(fields ...string) *UserSelect {
|
||||||
|
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||||
|
sbuild := &UserSelect{UserQuery: _q}
|
||||||
|
sbuild.label = user.Label
|
||||||
|
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||||
|
return sbuild
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate returns a UserSelect configured with the given aggregations.
|
||||||
|
func (_q *UserQuery) Aggregate(fns ...AggregateFunc) *UserSelect {
|
||||||
|
return _q.Select().Aggregate(fns...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *UserQuery) prepareQuery(ctx context.Context) error {
|
||||||
|
for _, inter := range _q.inters {
|
||||||
|
if inter == nil {
|
||||||
|
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||||
|
}
|
||||||
|
if trv, ok := inter.(Traverser); ok {
|
||||||
|
if err := trv.Traverse(ctx, _q); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, f := range _q.ctx.Fields {
|
||||||
|
if !user.ValidColumn(f) {
|
||||||
|
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _q.path != nil {
|
||||||
|
prev, err := _q.path(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_q.sql = prev
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, error) {
|
||||||
|
var (
|
||||||
|
nodes = []*User{}
|
||||||
|
_spec = _q.querySpec()
|
||||||
|
)
|
||||||
|
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||||
|
return (*User).scanValues(nil, columns)
|
||||||
|
}
|
||||||
|
_spec.Assign = func(columns []string, values []any) error {
|
||||||
|
node := &User{config: _q.config}
|
||||||
|
nodes = append(nodes, node)
|
||||||
|
return node.assignValues(columns, values)
|
||||||
|
}
|
||||||
|
for i := range hooks {
|
||||||
|
hooks[i](ctx, _spec)
|
||||||
|
}
|
||||||
|
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *UserQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
|
_spec := _q.querySpec()
|
||||||
|
_spec.Node.Columns = _q.ctx.Fields
|
||||||
|
if len(_q.ctx.Fields) > 0 {
|
||||||
|
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||||
|
}
|
||||||
|
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *UserQuery) querySpec() *sqlgraph.QuerySpec {
|
||||||
|
_spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt))
|
||||||
|
_spec.From = _q.sql
|
||||||
|
if unique := _q.ctx.Unique; unique != nil {
|
||||||
|
_spec.Unique = *unique
|
||||||
|
} else if _q.path != nil {
|
||||||
|
_spec.Unique = true
|
||||||
|
}
|
||||||
|
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||||
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, user.FieldID)
|
||||||
|
for i := range fields {
|
||||||
|
if fields[i] != user.FieldID {
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ps := _q.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if limit := _q.ctx.Limit; limit != nil {
|
||||||
|
_spec.Limit = *limit
|
||||||
|
}
|
||||||
|
if offset := _q.ctx.Offset; offset != nil {
|
||||||
|
_spec.Offset = *offset
|
||||||
|
}
|
||||||
|
if ps := _q.order; len(ps) > 0 {
|
||||||
|
_spec.Order = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _spec
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_q *UserQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||||
|
builder := sql.Dialect(_q.driver.Dialect())
|
||||||
|
t1 := builder.Table(user.Table)
|
||||||
|
columns := _q.ctx.Fields
|
||||||
|
if len(columns) == 0 {
|
||||||
|
columns = user.Columns
|
||||||
|
}
|
||||||
|
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||||
|
if _q.sql != nil {
|
||||||
|
selector = _q.sql
|
||||||
|
selector.Select(selector.Columns(columns...)...)
|
||||||
|
}
|
||||||
|
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||||
|
selector.Distinct()
|
||||||
|
}
|
||||||
|
for _, p := range _q.predicates {
|
||||||
|
p(selector)
|
||||||
|
}
|
||||||
|
for _, p := range _q.order {
|
||||||
|
p(selector)
|
||||||
|
}
|
||||||
|
if offset := _q.ctx.Offset; offset != nil {
|
||||||
|
// limit is mandatory for offset clause. We start
|
||||||
|
// with default value, and override it below if needed.
|
||||||
|
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||||
|
}
|
||||||
|
if limit := _q.ctx.Limit; limit != nil {
|
||||||
|
selector.Limit(*limit)
|
||||||
|
}
|
||||||
|
return selector
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserGroupBy is the group-by builder for User entities.
|
||||||
|
type UserGroupBy struct {
|
||||||
|
selector
|
||||||
|
build *UserQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the group-by query.
|
||||||
|
func (_g *UserGroupBy) Aggregate(fns ...AggregateFunc) *UserGroupBy {
|
||||||
|
_g.fns = append(_g.fns, fns...)
|
||||||
|
return _g
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (_g *UserGroupBy) Scan(ctx context.Context, v any) error {
|
||||||
|
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||||
|
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return scanWithInterceptors[*UserQuery, *UserGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_g *UserGroupBy) sqlScan(ctx context.Context, root *UserQuery, v any) error {
|
||||||
|
selector := root.sqlQuery(ctx).Select()
|
||||||
|
aggregation := make([]string, 0, len(_g.fns))
|
||||||
|
for _, fn := range _g.fns {
|
||||||
|
aggregation = append(aggregation, fn(selector))
|
||||||
|
}
|
||||||
|
if len(selector.SelectedColumns()) == 0 {
|
||||||
|
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||||
|
for _, f := range *_g.flds {
|
||||||
|
columns = append(columns, selector.C(f))
|
||||||
|
}
|
||||||
|
columns = append(columns, aggregation...)
|
||||||
|
selector.Select(columns...)
|
||||||
|
}
|
||||||
|
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||||
|
if err := selector.Err(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
rows := &sql.Rows{}
|
||||||
|
query, args := selector.Query()
|
||||||
|
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
return sql.ScanSlice(rows, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserSelect is the builder for selecting fields of User entities.
|
||||||
|
type UserSelect struct {
|
||||||
|
*UserQuery
|
||||||
|
selector
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the selector query.
|
||||||
|
func (_s *UserSelect) Aggregate(fns ...AggregateFunc) *UserSelect {
|
||||||
|
_s.fns = append(_s.fns, fns...)
|
||||||
|
return _s
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (_s *UserSelect) Scan(ctx context.Context, v any) error {
|
||||||
|
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||||
|
if err := _s.prepareQuery(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return scanWithInterceptors[*UserQuery, *UserSelect](ctx, _s.UserQuery, _s, _s.inters, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_s *UserSelect) sqlScan(ctx context.Context, root *UserQuery, v any) error {
|
||||||
|
selector := root.sqlQuery(ctx)
|
||||||
|
aggregation := make([]string, 0, len(_s.fns))
|
||||||
|
for _, fn := range _s.fns {
|
||||||
|
aggregation = append(aggregation, fn(selector))
|
||||||
|
}
|
||||||
|
switch n := len(*_s.selector.flds); {
|
||||||
|
case n == 0 && len(aggregation) > 0:
|
||||||
|
selector.Select(aggregation...)
|
||||||
|
case n != 0 && len(aggregation) > 0:
|
||||||
|
selector.AppendSelect(aggregation...)
|
||||||
|
}
|
||||||
|
rows := &sql.Rows{}
|
||||||
|
query, args := selector.Query()
|
||||||
|
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
return sql.ScanSlice(rows, v)
|
||||||
|
}
|
||||||
@@ -0,0 +1,382 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/predicate"
|
||||||
|
"github.com/fatedier/frp/pkg/db/ent/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserUpdate is the builder for updating User entities.
|
||||||
|
type UserUpdate struct {
|
||||||
|
config
|
||||||
|
hooks []Hook
|
||||||
|
mutation *UserMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the UserUpdate builder.
|
||||||
|
func (_u *UserUpdate) Where(ps ...predicate.User) *UserUpdate {
|
||||||
|
_u.mutation.Where(ps...)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUsername sets the "username" field.
|
||||||
|
func (_u *UserUpdate) SetUsername(v string) *UserUpdate {
|
||||||
|
_u.mutation.SetUsername(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableUsername sets the "username" field if the given value is not nil.
|
||||||
|
func (_u *UserUpdate) SetNillableUsername(v *string) *UserUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetUsername(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPassword sets the "password" field.
|
||||||
|
func (_u *UserUpdate) SetPassword(v string) *UserUpdate {
|
||||||
|
_u.mutation.SetPassword(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillablePassword sets the "password" field if the given value is not nil.
|
||||||
|
func (_u *UserUpdate) SetNillablePassword(v *string) *UserUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetPassword(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetName sets the "name" field.
|
||||||
|
func (_u *UserUpdate) SetName(v string) *UserUpdate {
|
||||||
|
_u.mutation.SetName(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableName sets the "name" field if the given value is not nil.
|
||||||
|
func (_u *UserUpdate) SetNillableName(v *string) *UserUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetName(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRole sets the "role" field.
|
||||||
|
func (_u *UserUpdate) SetRole(v string) *UserUpdate {
|
||||||
|
_u.mutation.SetRole(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableRole sets the "role" field if the given value is not nil.
|
||||||
|
func (_u *UserUpdate) SetNillableRole(v *string) *UserUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetRole(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCreatedAt sets the "created_at" field.
|
||||||
|
func (_u *UserUpdate) SetCreatedAt(v time.Time) *UserUpdate {
|
||||||
|
_u.mutation.SetCreatedAt(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||||
|
func (_u *UserUpdate) SetNillableCreatedAt(v *time.Time) *UserUpdate {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetCreatedAt(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUpdatedAt sets the "updated_at" field.
|
||||||
|
func (_u *UserUpdate) SetUpdatedAt(v time.Time) *UserUpdate {
|
||||||
|
_u.mutation.SetUpdatedAt(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the UserMutation object of the builder.
|
||||||
|
func (_u *UserUpdate) Mutation() *UserMutation {
|
||||||
|
return _u.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||||
|
func (_u *UserUpdate) Save(ctx context.Context) (int, error) {
|
||||||
|
_u.defaults()
|
||||||
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (_u *UserUpdate) SaveX(ctx context.Context) int {
|
||||||
|
affected, err := _u.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return affected
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (_u *UserUpdate) Exec(ctx context.Context) error {
|
||||||
|
_, err := _u.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_u *UserUpdate) ExecX(ctx context.Context) {
|
||||||
|
if err := _u.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// defaults sets the default values of the builder before save.
|
||||||
|
func (_u *UserUpdate) defaults() {
|
||||||
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||||
|
v := user.UpdateDefaultUpdatedAt()
|
||||||
|
_u.mutation.SetUpdatedAt(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_u *UserUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||||
|
_spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt))
|
||||||
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Username(); ok {
|
||||||
|
_spec.SetField(user.FieldUsername, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Password(); ok {
|
||||||
|
_spec.SetField(user.FieldPassword, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Name(); ok {
|
||||||
|
_spec.SetField(user.FieldName, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Role(); ok {
|
||||||
|
_spec.SetField(user.FieldRole, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
||||||
|
_spec.SetField(user.FieldCreatedAt, field.TypeTime, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||||
|
_spec.SetField(user.FieldUpdatedAt, field.TypeTime, value)
|
||||||
|
}
|
||||||
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||||
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
|
err = &NotFoundError{user.Label}
|
||||||
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
_u.mutation.done = true
|
||||||
|
return _node, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserUpdateOne is the builder for updating a single User entity.
|
||||||
|
type UserUpdateOne struct {
|
||||||
|
config
|
||||||
|
fields []string
|
||||||
|
hooks []Hook
|
||||||
|
mutation *UserMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUsername sets the "username" field.
|
||||||
|
func (_u *UserUpdateOne) SetUsername(v string) *UserUpdateOne {
|
||||||
|
_u.mutation.SetUsername(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableUsername sets the "username" field if the given value is not nil.
|
||||||
|
func (_u *UserUpdateOne) SetNillableUsername(v *string) *UserUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetUsername(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPassword sets the "password" field.
|
||||||
|
func (_u *UserUpdateOne) SetPassword(v string) *UserUpdateOne {
|
||||||
|
_u.mutation.SetPassword(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillablePassword sets the "password" field if the given value is not nil.
|
||||||
|
func (_u *UserUpdateOne) SetNillablePassword(v *string) *UserUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetPassword(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetName sets the "name" field.
|
||||||
|
func (_u *UserUpdateOne) SetName(v string) *UserUpdateOne {
|
||||||
|
_u.mutation.SetName(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableName sets the "name" field if the given value is not nil.
|
||||||
|
func (_u *UserUpdateOne) SetNillableName(v *string) *UserUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetName(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRole sets the "role" field.
|
||||||
|
func (_u *UserUpdateOne) SetRole(v string) *UserUpdateOne {
|
||||||
|
_u.mutation.SetRole(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableRole sets the "role" field if the given value is not nil.
|
||||||
|
func (_u *UserUpdateOne) SetNillableRole(v *string) *UserUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetRole(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCreatedAt sets the "created_at" field.
|
||||||
|
func (_u *UserUpdateOne) SetCreatedAt(v time.Time) *UserUpdateOne {
|
||||||
|
_u.mutation.SetCreatedAt(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||||
|
func (_u *UserUpdateOne) SetNillableCreatedAt(v *time.Time) *UserUpdateOne {
|
||||||
|
if v != nil {
|
||||||
|
_u.SetCreatedAt(*v)
|
||||||
|
}
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUpdatedAt sets the "updated_at" field.
|
||||||
|
func (_u *UserUpdateOne) SetUpdatedAt(v time.Time) *UserUpdateOne {
|
||||||
|
_u.mutation.SetUpdatedAt(v)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the UserMutation object of the builder.
|
||||||
|
func (_u *UserUpdateOne) Mutation() *UserMutation {
|
||||||
|
return _u.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the UserUpdate builder.
|
||||||
|
func (_u *UserUpdateOne) Where(ps ...predicate.User) *UserUpdateOne {
|
||||||
|
_u.mutation.Where(ps...)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||||
|
// The default is selecting all fields defined in the entity schema.
|
||||||
|
func (_u *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne {
|
||||||
|
_u.fields = append([]string{field}, fields...)
|
||||||
|
return _u
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save executes the query and returns the updated User entity.
|
||||||
|
func (_u *UserUpdateOne) Save(ctx context.Context) (*User, error) {
|
||||||
|
_u.defaults()
|
||||||
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (_u *UserUpdateOne) SaveX(ctx context.Context) *User {
|
||||||
|
node, err := _u.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query on the entity.
|
||||||
|
func (_u *UserUpdateOne) Exec(ctx context.Context) error {
|
||||||
|
_, err := _u.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (_u *UserUpdateOne) ExecX(ctx context.Context) {
|
||||||
|
if err := _u.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// defaults sets the default values of the builder before save.
|
||||||
|
func (_u *UserUpdateOne) defaults() {
|
||||||
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||||
|
v := user.UpdateDefaultUpdatedAt()
|
||||||
|
_u.mutation.SetUpdatedAt(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_u *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) {
|
||||||
|
_spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt))
|
||||||
|
id, ok := _u.mutation.ID()
|
||||||
|
if !ok {
|
||||||
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "User.id" for update`)}
|
||||||
|
}
|
||||||
|
_spec.Node.ID.Value = id
|
||||||
|
if fields := _u.fields; len(fields) > 0 {
|
||||||
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, user.FieldID)
|
||||||
|
for _, f := range fields {
|
||||||
|
if !user.ValidColumn(f) {
|
||||||
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||||
|
}
|
||||||
|
if f != user.FieldID {
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Username(); ok {
|
||||||
|
_spec.SetField(user.FieldUsername, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Password(); ok {
|
||||||
|
_spec.SetField(user.FieldPassword, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Name(); ok {
|
||||||
|
_spec.SetField(user.FieldName, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.Role(); ok {
|
||||||
|
_spec.SetField(user.FieldRole, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
||||||
|
_spec.SetField(user.FieldCreatedAt, field.TypeTime, value)
|
||||||
|
}
|
||||||
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||||
|
_spec.SetField(user.FieldUpdatedAt, field.TypeTime, value)
|
||||||
|
}
|
||||||
|
_node = &User{config: _u.config}
|
||||||
|
_spec.Assign = _node.assignValues
|
||||||
|
_spec.ScanValues = _node.scanValues
|
||||||
|
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
||||||
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
|
err = &NotFoundError{user.Label}
|
||||||
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_u.mutation.done = true
|
||||||
|
return _node, nil
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,40 @@
|
|||||||
|
package admin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"embed"
|
||||||
|
"html/template"
|
||||||
|
"io"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:embed templates/*.html
|
||||||
|
var templateFS embed.FS
|
||||||
|
|
||||||
|
var tmpl *template.Template
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
funcMap := template.FuncMap{
|
||||||
|
"lower": strings.ToLower,
|
||||||
|
}
|
||||||
|
tmpl = template.Must(template.New("").Funcs(funcMap).ParseFS(templateFS, "templates/*.html"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func renderTemplate(w io.Writer, name string, data map[string]any) error {
|
||||||
|
return tmpl.ExecuteTemplate(w, name, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
func renderToString(name string, data map[string]any) string {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
if err := tmpl.ExecuteTemplate(&buf, name, data); err != nil {
|
||||||
|
return "<p>Error rendering template</p>"
|
||||||
|
}
|
||||||
|
return buf.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
func renderLayout(w io.Writer, title string, content template.HTML) error {
|
||||||
|
return tmpl.ExecuteTemplate(w, "layout.html", map[string]any{
|
||||||
|
"Title": title,
|
||||||
|
"Content": content,
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<div class="toolbar">
|
||||||
|
<h1>Client: {{.Client.Name}}</h1>
|
||||||
|
<div class="spacer"></div>
|
||||||
|
<a href="/admin/clients/{{.Client.ID}}/provision" class="btn btn-sm" hx-get="/admin/clients/{{.Client.ID}}/provision" hx-target="#main-content" hx-push-url="true">Provision</a>
|
||||||
|
<a href="/admin/clients" class="btn btn-sm btn-outline" hx-get="/admin/clients" hx-target="#main-content" hx-push-url="true">Back</a>
|
||||||
|
</div>
|
||||||
|
<div class="grid-2 mb-16">
|
||||||
|
<div class="card">
|
||||||
|
<h3>Details</h3>
|
||||||
|
<table style="margin-top:8px">
|
||||||
|
<tbody>
|
||||||
|
<tr><td style="width:120px;color:var(--fg2);font-size:12px">Status</td><td>{{if eq .Client.Status "online"}}<span style="font-weight:600">Online</span>{{else}}<span style="color:var(--fg2)">Offline</span>{{end}}</td></tr>
|
||||||
|
<tr><td style="color:var(--fg2);font-size:12px">Address</td><td class="text-mono">{{if .Client.Addr}}{{.Client.Addr}}:{{.Client.Port}}{{else}}—{{end}}</td></tr>
|
||||||
|
<tr><td style="color:var(--fg2);font-size:12px">Auth Key</td><td class="text-mono">{{.Client.Key}}</td></tr>
|
||||||
|
<tr><td style="color:var(--fg2);font-size:12px">Created</td><td>{{.Client.CreatedAt}}</td></tr>
|
||||||
|
<tr><td style="color:var(--fg2);font-size:12px">Last Seen</td><td>{{if .Client.LastSeen}}{{.Client.LastSeen}}{{else}}—{{end}}</td></tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h3>One-Time Token</h3>
|
||||||
|
<p style="font-size:12px;color:var(--fg2);margin-bottom:8px">Generate a one-time token for client auth:</p>
|
||||||
|
<button class="btn btn-sm" hx-post="/admin/clients/{{.Client.ID}}/generate-token" hx-target="#token-result" hx-swap="innerHTML">Generate Token</button>
|
||||||
|
<div id="token-result" style="margin-top:8px"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<h2 style="font-size:16px;font-weight:600;margin-bottom:12px">Proxies</h2>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr><th>Name</th><th>Type</th><th>Local</th><th>Remote</th><th>Status</th><th></th></tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{{range .Proxies}}
|
||||||
|
<tr>
|
||||||
|
<td><a href="/admin/proxies/{{.ID}}" hx-get="/admin/proxies/{{.ID}}" hx-target="#main-content" hx-push-url="true">{{.Name}}</a></td>
|
||||||
|
<td style="color:var(--fg2)">{{.ProxyType}}</td>
|
||||||
|
<td class="text-mono">{{.LocalIP}}:{{.LocalPort}}</td>
|
||||||
|
<td class="text-mono">{{if .RemotePort}}{{.RemotePort}}{{else}}—{{end}}</td>
|
||||||
|
<td>{{if eq .Status "active"}}<span style="font-weight:600">active</span>{{else}}<span style="color:var(--fg2)">{{.Status}}</span>{{end}}</td>
|
||||||
|
<td><a href="/admin/proxies/{{.ID}}" class="btn btn-sm btn-outline" hx-get="/admin/proxies/{{.ID}}" hx-target="#main-content" hx-push-url="true">View</a></td>
|
||||||
|
</tr>
|
||||||
|
{{else}}
|
||||||
|
<tr><td colspan="6"><div class="empty">No proxies for this client. <a href="/admin/proxies/new?client_id={{$.Client.ID}}" hx-get="/admin/proxies/new?client_id={{$.Client.ID}}" hx-target="#main-content" hx-push-url="true">Create one</a>.</div></td></tr>
|
||||||
|
{{end}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<div class="toolbar">
|
||||||
|
<h1>New Client</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{if .Error}}
|
||||||
|
<div style="margin-bottom:16px;padding:12px;border:1px solid var(--border);font-size:13px">{{.Error}}</div>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
<form hx-post="/admin/clients/new" hx-target="body" hx-push-url="true" style="max-width:400px">
|
||||||
|
<div style="margin-bottom:16px">
|
||||||
|
<label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">Client Name</label>
|
||||||
|
<input type="text" name="name" required autofocus placeholder="my-server">
|
||||||
|
</div>
|
||||||
|
<div class="toolbar">
|
||||||
|
<button type="submit">Create Client</button>
|
||||||
|
<a href="/admin/clients" class="btn btn-outline" hx-get="/admin/clients" hx-target="#main-content" hx-push-url="true">Cancel</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<div class="toolbar">
|
||||||
|
<h1>Provision: {{.Client.Name}}</h1>
|
||||||
|
<div class="spacer"></div>
|
||||||
|
<a href="/admin/clients/{{.Client.ID}}" class="btn btn-sm btn-outline" hx-get="/admin/clients/{{.Client.ID}}" hx-target="#main-content" hx-push-url="true">Back</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="border:1px solid var(--border);padding:20px;margin-bottom:16px">
|
||||||
|
<h2 style="font-size:12px;font-weight:600;letter-spacing:.3px;color:var(--fg2);margin-bottom:12px;text-transform:uppercase">Client Details</h2>
|
||||||
|
<table>
|
||||||
|
<tr><td style="width:120px;color:var(--fg2);font-size:12px">Name</td><td>{{.Client.Name}}</td></tr>
|
||||||
|
<tr><td style="color:var(--fg2);font-size:12px">Key</td><td class="text-mono">{{.Client.Key}}</td></tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="border:1px solid var(--border);padding:20px;margin-bottom:16px">
|
||||||
|
<h2 style="font-size:12px;font-weight:600;letter-spacing:.3px;color:var(--fg2);margin-bottom:12px;text-transform:uppercase">One-Liner Setup</h2>
|
||||||
|
<p style="font-size:12px;color:var(--fg2);margin-bottom:8px">Run this on your client machine. It downloads frpc and auto-updates from this server:</p>
|
||||||
|
<pre class="text-mono" style="padding:12px;background:var(--bg2);border:1px solid var(--border);overflow-x:auto;white-space:pre-wrap;word-break:break-all;font-size:12px">curl -sL https://github.com/fatedier/frp/releases/latest/download/frp_linux_amd64.tar.gz | tar xz \
|
||||||
|
&& ./frp_*/frpc --server-config http://{{.ServerAddr}}:{{.ServerPort}}/admin/api/frpc/proxy-config/{{.Client.Key}}</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="border:1px solid var(--border);padding:20px;margin-bottom:16px">
|
||||||
|
<h2 style="font-size:12px;font-weight:600;letter-spacing:.3px;color:var(--fg2);margin-bottom:12px;text-transform:uppercase">Download Install Script</h2>
|
||||||
|
<p style="font-size:12px;color:var(--fg2);margin-bottom:8px">Download a standalone provisioning script:</p>
|
||||||
|
<a href="/admin/clients/{{.Client.ID}}/provision.sh" class="btn btn-sm" download>Download provision-{{.Client.Name}}.sh</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="border:1px solid var(--border);padding:20px;margin-bottom:16px">
|
||||||
|
<h2 style="font-size:12px;font-weight:600;letter-spacing:.3px;color:var(--fg2);margin-bottom:12px;text-transform:uppercase">Current Config</h2>
|
||||||
|
<pre class="text-mono" style="padding:12px;background:var(--bg2);border:1px solid var(--border);overflow-x:auto;white-space:pre-wrap;font-size:12px">{{.FrpcConfig}}</pre>
|
||||||
|
<div class="toolbar" style="margin-top:12px">
|
||||||
|
<a href="/admin/clients/{{.Client.ID}}/config" class="btn btn-sm" download>Download frpc.toml</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="border:1px solid var(--border);padding:20px;margin-bottom:16px">
|
||||||
|
<h2 style="font-size:12px;font-weight:600;letter-spacing:.3px;color:var(--fg2);margin-bottom:12px;text-transform:uppercase">Add Proxies</h2>
|
||||||
|
<p style="font-size:13px;color:var(--fg2);margin-bottom:4px">Create proxies from the <a href="/admin/proxies/new?client_id={{.Client.ID}}" hx-get="/admin/proxies/new?client_id={{.Client.ID}}" hx-target="#main-content" hx-push-url="true">new proxy page</a>. The client will auto-reload within 30 seconds.</p>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<div class="toolbar">
|
||||||
|
<h1>Clients</h1>
|
||||||
|
<div class="spacer"></div>
|
||||||
|
<a href="/admin/clients/new" class="btn btn-sm" hx-get="/admin/clients/new" hx-target="#main-content" hx-push-url="true">New Client</a>
|
||||||
|
</div>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr><th>Name</th><th>Address</th><th>Status</th><th>Key</th><th>Last Seen</th><th></th></tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{{range .Clients}}
|
||||||
|
<tr>
|
||||||
|
<td><a href="/admin/clients/{{.ID}}" hx-get="/admin/clients/{{.ID}}" hx-target="#main-content" hx-push-url="true">{{.Name}}</a></td>
|
||||||
|
<td class="text-mono">{{if .Addr}}{{.Addr}}:{{.Port}}{{else}}—{{end}}</td>
|
||||||
|
<td>{{if eq .Status "online"}}<span style="font-weight:600">online</span>{{else}}<span style="color:var(--fg2)">offline</span>{{end}}</td>
|
||||||
|
<td class="text-mono" style="max-width:120px;overflow:hidden;text-overflow:ellipsis">{{.Key}}</td>
|
||||||
|
<td>{{if .LastSeen}}{{.LastSeen}}{{else}}—{{end}}</td>
|
||||||
|
<td><a href="/admin/clients/{{.ID}}/provision" class="btn btn-sm btn-outline" hx-get="/admin/clients/{{.ID}}/provision" hx-target="#main-content" hx-push-url="true">Provision</a></td>
|
||||||
|
</tr>
|
||||||
|
{{else}}
|
||||||
|
<tr><td colspan="6"><div class="empty">No clients registered. <a href="/admin/clients/new" hx-get="/admin/clients/new" hx-target="#main-content" hx-push-url="true">Create one</a>.</div></td></tr>
|
||||||
|
{{end}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<h1>Dashboard</h1>
|
||||||
|
<div class="grid-4">
|
||||||
|
<div class="card">
|
||||||
|
<h3>Active Proxies</h3>
|
||||||
|
<div class="value">{{.ActiveProxies}}</div>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h3>Clients</h3>
|
||||||
|
<div class="value">{{.TotalClients}}</div>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h3>Users</h3>
|
||||||
|
<div class="value">{{.TotalUsers}}</div>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h3>Uptime</h3>
|
||||||
|
<div class="value" style="font-size:20px">{{.Uptime}}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="grid-2">
|
||||||
|
<div class="card">
|
||||||
|
<h3>Clients by Status</h3>
|
||||||
|
<table style="margin-top:8px">
|
||||||
|
<tr><td style="width:100px">Online</td><td>{{.OnlineClients}}</td></tr>
|
||||||
|
<tr><td>Offline</td><td>{{.OfflineClients}}</td></tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h3>Proxies by Type</h3>
|
||||||
|
<table style="margin-top:8px">
|
||||||
|
{{range .ProxyBreakdown}}
|
||||||
|
<tr><td style="width:100px;text-transform:capitalize">{{.Type}}</td><td>{{.Count}}</td></tr>
|
||||||
|
{{end}}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
<title>{{if .Title}}{{.Title}} — {{end}}frp Admin</title>
|
||||||
|
<script src="https://unpkg.com/htmx.org@2.0.4"></script>
|
||||||
|
<style>
|
||||||
|
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
|
||||||
|
:root{--bg:#fff;--bg2:#f5f5f5;--fg:#000;--fg2:#888;--border:#ddd;--accent:#000;--font:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;--radius:0}
|
||||||
|
@media(prefers-color-scheme:dark){
|
||||||
|
:root{--bg:#000;--bg2:#111;--fg:#fff;--fg2:#666;--border:#333;--accent:#fff}
|
||||||
|
}
|
||||||
|
html,body{height:100%}
|
||||||
|
body{font-family:var(--font);background:var(--bg);color:var(--fg);font-size:14px;line-height:1.5}
|
||||||
|
a{color:var(--fg);text-decoration:underline}
|
||||||
|
a:hover{text-decoration:none}
|
||||||
|
table{width:100%;border-collapse:collapse}
|
||||||
|
th,td{padding:10px 12px;text-align:left;border-bottom:1px solid var(--border);font-size:13px}
|
||||||
|
th{font-weight:600;font-size:11px;letter-spacing:.3px;color:var(--fg2)}
|
||||||
|
tr:hover td{background:var(--bg2)}
|
||||||
|
input,select,textarea{padding:8px 12px;border:1px solid var(--border);background:var(--bg);color:var(--fg);font-size:13px;border-radius:var(--radius);width:100%;-webkit-appearance:none;appearance:none}
|
||||||
|
input:focus,select:focus,textarea:focus{outline:1px solid var(--fg)}
|
||||||
|
button,.btn{padding:8px 16px;border:1px solid var(--fg);background:var(--fg);color:var(--bg);font-size:13px;cursor:pointer;border-radius:var(--radius);font-family:var(--font)}
|
||||||
|
button:hover,.btn:hover{opacity:.8}
|
||||||
|
.btn-outline{background:transparent;color:var(--fg)}
|
||||||
|
.btn-outline:hover{background:var(--fg);color:var(--bg)}
|
||||||
|
.btn-sm{padding:4px 10px;font-size:12px}
|
||||||
|
.card{background:var(--bg2);border:1px solid var(--border);padding:20px}
|
||||||
|
.card h3{margin-bottom:8px;font-size:12px;font-weight:600;letter-spacing:.3px;color:var(--fg2)}
|
||||||
|
.card .value{font-size:28px;font-weight:700;color:var(--fg)}
|
||||||
|
.layout{display:flex;min-height:100vh}
|
||||||
|
.sidebar{width:220px;background:var(--bg2);border-right:1px solid var(--border);padding:24px 0;flex-shrink:0}
|
||||||
|
.sidebar .brand{padding:0 20px 24px;font-size:16px;font-weight:700;letter-spacing:-.5px;border-bottom:1px solid var(--border);margin-bottom:8px}
|
||||||
|
.sidebar nav a{display:block;padding:8px 20px;color:var(--fg2);font-size:13px;text-decoration:none}
|
||||||
|
.sidebar nav a:hover{color:var(--fg);background:var(--border)}
|
||||||
|
.main{flex:1;padding:24px 32px;max-width:1200px}
|
||||||
|
.main>h1{font-size:22px;font-weight:700;margin-bottom:24px}
|
||||||
|
.login-page{display:flex;align-items:center;justify-content:center;min-height:100vh;background:var(--bg2)}
|
||||||
|
.login-card{width:360px;padding:32px;background:var(--bg);border:1px solid var(--border)}
|
||||||
|
.login-card h1{font-size:20px;margin-bottom:24px;text-align:center;letter-spacing:-.5px}
|
||||||
|
.login-card .field{margin-bottom:16px}
|
||||||
|
.login-card .field label{display:block;font-size:12px;color:var(--fg2);margin-bottom:4px}
|
||||||
|
.login-card .error{color:var(--fg);font-size:13px;margin-bottom:12px;text-align:center}
|
||||||
|
.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin-bottom:24px}
|
||||||
|
.grid-3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:16px;margin-bottom:24px}
|
||||||
|
.grid-4{display:grid;grid-template-columns:repeat(4,1fr);gap:16px;margin-bottom:24px}
|
||||||
|
.toolbar{display:flex;gap:8px;margin-bottom:16px;align-items:center}
|
||||||
|
.toolbar .spacer{flex:1}
|
||||||
|
.flex{display:flex;gap:8px;align-items:center}
|
||||||
|
.text-right{text-align:right}
|
||||||
|
.text-mono{font-family:"SFMono-Regular",Consolas,"Liberation Mono",monospace;font-size:12px}
|
||||||
|
.mb-8{margin-bottom:8px;margin-top:0!important}
|
||||||
|
.mt-8{margin-top:8px}
|
||||||
|
.mb-16{margin-bottom:16px}
|
||||||
|
.empty{padding:40px;text-align:center;color:var(--fg2);font-size:14px}
|
||||||
|
@media(max-width:768px){
|
||||||
|
.sidebar{width:56px;overflow:hidden}
|
||||||
|
.sidebar .brand{font-size:0;padding:12px 16px}
|
||||||
|
.sidebar .brand::after{content:"F";font-size:20px}
|
||||||
|
.sidebar nav a{font-size:0;padding:12px 16px;text-align:center}
|
||||||
|
.sidebar nav a::after{content:attr(data-label);font-size:13px;display:block;text-align:center}
|
||||||
|
.sidebar nav a[data-label]::first-letter{font-size:14px}
|
||||||
|
.main{padding:16px}
|
||||||
|
.grid-2,.grid-3,.grid-4{grid-template-columns:1fr}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="layout">
|
||||||
|
<aside class="sidebar">
|
||||||
|
<div class="brand">frp Admin</div>
|
||||||
|
<nav>
|
||||||
|
<a href="/admin/dashboard" data-label="Dashboard" hx-get="/admin/dashboard" hx-target="#main-content" hx-push-url="true">Dashboard</a>
|
||||||
|
<a href="/admin/clients" data-label="Clients" hx-get="/admin/clients" hx-target="#main-content" hx-push-url="true">Clients</a>
|
||||||
|
<a href="/admin/proxies" data-label="Proxies" hx-get="/admin/proxies" hx-target="#main-content" hx-push-url="true">Proxies</a>
|
||||||
|
<a href="/admin/settings" data-label="Settings" hx-get="/admin/settings" hx-target="#main-content" hx-push-url="true">Settings</a>
|
||||||
|
<hr style="border:none;border-top:1px solid var(--border);margin:8px 20px">
|
||||||
|
<a href="/admin/logout" data-label="Logout" hx-post="/admin/logout" hx-trigger="click" hx-target="body" hx-push-url="true">Logout</a>
|
||||||
|
</nav>
|
||||||
|
</aside>
|
||||||
|
<main class="main" id="main-content">
|
||||||
|
{{.Content}}
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
<title>Login — frp Admin</title>
|
||||||
|
<style>
|
||||||
|
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
|
||||||
|
:root{--bg:#fff;--bg2:#f5f5f5;--fg:#000;--fg2:#888;--border:#ddd;--accent:#000;--font:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;--radius:0}
|
||||||
|
@media(prefers-color-scheme:dark){
|
||||||
|
:root{--bg:#000;--bg2:#111;--fg:#fff;--fg2:#666;--border:#333;--accent:#fff}
|
||||||
|
}
|
||||||
|
html,body{height:100%}
|
||||||
|
body{font-family:var(--font);background:var(--bg2);color:var(--fg);font-size:14px;display:flex;align-items:center;justify-content:center;min-height:100vh}
|
||||||
|
.login-card{width:360px;padding:32px;background:var(--bg);border:1px solid var(--border)}
|
||||||
|
.login-card h1{font-size:20px;margin-bottom:24px;text-align:center;letter-spacing:-.5px}
|
||||||
|
.login-card .field{margin-bottom:16px}
|
||||||
|
.login-card .field label{display:block;font-size:12px;color:var(--fg2);margin-bottom:4px}
|
||||||
|
.login-card .error{font-size:13px;margin-bottom:12px;text-align:center}
|
||||||
|
input{padding:8px 12px;border:1px solid var(--border);background:var(--bg);color:var(--fg);font-size:13px;width:100%;-webkit-appearance:none;appearance:none}
|
||||||
|
input:focus{outline:1px solid var(--fg)}
|
||||||
|
button{padding:8px 16px;border:1px solid var(--fg);background:var(--fg);color:var(--bg);font-size:13px;cursor:pointer;font-family:var(--font);width:100%}
|
||||||
|
button:hover{opacity:.8}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="login-card">
|
||||||
|
<h1>frp Admin</h1>
|
||||||
|
{{if .Error}}
|
||||||
|
<div class="error">{{.Error}}</div>
|
||||||
|
{{end}}
|
||||||
|
<form method="post" action="/admin/login">
|
||||||
|
<div class="field">
|
||||||
|
<label for="username">Username</label>
|
||||||
|
<input type="text" id="username" name="username" required autofocus>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label for="password">Password</label>
|
||||||
|
<input type="password" id="password" name="password" required>
|
||||||
|
</div>
|
||||||
|
<button type="submit">Sign In</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<div class="toolbar">
|
||||||
|
<h1>Proxies</h1>
|
||||||
|
<div class="spacer"></div>
|
||||||
|
<a href="/admin/proxies/new" class="btn btn-sm" hx-get="/admin/proxies/new" hx-target="#main-content" hx-push-url="true">New Proxy</a>
|
||||||
|
</div>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr><th>Name</th><th>Type</th><th>Client</th><th>Local</th><th>Remote</th><th>Status</th><th></th></tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{{range .Proxies}}
|
||||||
|
<tr>
|
||||||
|
<td><a href="/admin/proxies/{{.ID}}" hx-get="/admin/proxies/{{.ID}}" hx-target="#main-content" hx-push-url="true">{{.Name}}</a></td>
|
||||||
|
<td style="color:var(--fg2)">{{.ProxyType}}</td>
|
||||||
|
<td>{{.ClientName}}</td>
|
||||||
|
<td class="text-mono">{{.LocalIP}}:{{.LocalPort}}</td>
|
||||||
|
<td class="text-mono">{{if .RemotePort}}{{.RemotePort}}{{else}}—{{end}}</td>
|
||||||
|
<td>{{if eq .Status "active"}}<span style="font-weight:600">active</span>{{else if eq .Status "inactive"}}<span style="color:var(--fg2)">inactive</span>{{else}}<span style="color:var(--fg2)">{{.Status}}</span>{{end}}</td>
|
||||||
|
<td><a href="/admin/proxies/{{.ID}}" class="btn btn-sm btn-outline" hx-get="/admin/proxies/{{.ID}}" hx-target="#main-content" hx-push-url="true">View</a></td>
|
||||||
|
</tr>
|
||||||
|
{{else}}
|
||||||
|
<tr><td colspan="7"><div class="empty">No proxies found. <a href="/admin/proxies/new" hx-get="/admin/proxies/new" hx-target="#main-content" hx-push-url="true">Create one</a>.</div></td></tr>
|
||||||
|
{{end}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<div class="toolbar">
|
||||||
|
<h1>Proxy: {{.Proxy.Name}}</h1>
|
||||||
|
<div class="spacer"></div>
|
||||||
|
<a href="/admin/proxies" class="btn btn-sm btn-outline" hx-get="/admin/proxies" hx-target="#main-content" hx-push-url="true">Back</a>
|
||||||
|
</div>
|
||||||
|
<div class="grid-2">
|
||||||
|
<div class="card">
|
||||||
|
<h3>Configuration</h3>
|
||||||
|
<table style="margin-top:8px">
|
||||||
|
<tbody>
|
||||||
|
<tr><td style="width:120px;color:var(--fg2);font-size:12px">Type</td><td style="color:var(--fg2)">{{.Proxy.ProxyType}}</td></tr>
|
||||||
|
<tr><td style="color:var(--fg2);font-size:12px">Status</td><td>{{if eq .Proxy.Status "active"}}<span style="font-weight:600">Active</span>{{else}}<span style="color:var(--fg2)">{{.Proxy.Status}}</span>{{end}}</td></tr>
|
||||||
|
<tr><td style="color:var(--fg2);font-size:12px">Local</td><td class="text-mono">{{.Proxy.LocalIP}}:{{.Proxy.LocalPort}}</td></tr>
|
||||||
|
<tr><td style="color:var(--fg2);font-size:12px">Remote Port</td><td class="text-mono">{{if .Proxy.RemotePort}}{{.Proxy.RemotePort}}{{else}}—{{end}}</td></tr>
|
||||||
|
<tr><td style="color:var(--fg2);font-size:12px">Custom Domains</td><td>{{if .Proxy.CustomDomains}}{{.Proxy.CustomDomains}}{{else}}—{{end}}</td></tr>
|
||||||
|
<tr><td style="color:var(--fg2);font-size:12px">Created</td><td>{{.Proxy.CreatedAt}}</td></tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<h3>Client</h3>
|
||||||
|
<table style="margin-top:8px">
|
||||||
|
<tbody>
|
||||||
|
<tr><td style="width:120px;color:var(--fg2);font-size:12px">Client ID</td><td class="text-mono">{{.Proxy.ClientID}}</td></tr>
|
||||||
|
{{if .ClientName}}
|
||||||
|
<tr><td style="color:var(--fg2);font-size:12px">Name</td><td><a href="/admin/clients/{{.Proxy.ClientID}}" hx-get="/admin/clients/{{.Proxy.ClientID}}" hx-target="#main-content" hx-push-url="true">{{.ClientName}}</a></td></tr>
|
||||||
|
{{end}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card mt-8">
|
||||||
|
<h3>Metadata</h3>
|
||||||
|
<pre class="text-mono" style="margin-top:8px;white-space:pre-wrap;font-size:12px">{{if .Proxy.Metadata}}{{.Proxy.Metadata}}{{else}}None{{end}}</pre>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
<div class="toolbar">
|
||||||
|
<h1>New Proxy</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{if .Error}}
|
||||||
|
<div style="margin-bottom:16px;padding:12px;border:1px solid var(--border);font-size:13px">{{.Error}}</div>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
<form hx-post="/admin/proxies/new" hx-target="body" hx-push-url="true" style="max-width:500px">
|
||||||
|
<div style="margin-bottom:16px">
|
||||||
|
<label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">Client</label>
|
||||||
|
<select name="client_id" required>
|
||||||
|
<option value="">— Select Client —</option>
|
||||||
|
{{range .Clients}}
|
||||||
|
<option value="{{.ID}}"{{if eq .ID $.SelectedClient}} selected{{end}}>{{.Name}}</option>
|
||||||
|
{{end}}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="margin-bottom:16px">
|
||||||
|
<label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">Proxy Type</label>
|
||||||
|
<select name="proxy_type">
|
||||||
|
<option value="tcp">TCP</option>
|
||||||
|
<option value="udp">UDP</option>
|
||||||
|
<option value="http">HTTP</option>
|
||||||
|
<option value="https">HTTPS</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="margin-bottom:16px">
|
||||||
|
<label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">Name</label>
|
||||||
|
<input type="text" name="name" required autofocus placeholder="ssh-proxy">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-bottom:16px">
|
||||||
|
<div>
|
||||||
|
<label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">Local IP</label>
|
||||||
|
<input type="text" name="local_ip" value="127.0.0.1" required>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">Local Port</label>
|
||||||
|
<input type="number" name="local_port" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-bottom:16px">
|
||||||
|
<div>
|
||||||
|
<label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">Remote Port</label>
|
||||||
|
<input type="number" name="remote_port" placeholder="0 = auto">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">Custom Domains</label>
|
||||||
|
<input type="text" name="custom_domains" placeholder="example.com">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="toolbar" style="margin-top:24px">
|
||||||
|
<button type="submit">Create Proxy</button>
|
||||||
|
<a href="/admin/proxies" class="btn btn-outline" hx-get="/admin/proxies" hx-target="#main-content" hx-push-url="true">Cancel</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
<div class="toolbar">
|
||||||
|
<h1>Settings</h1>
|
||||||
|
<div class="spacer"></div>
|
||||||
|
{{if .Saved}}
|
||||||
|
<span style="font-size:12px;color:var(--fg2)">Saved. Restart to apply.</span>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form hx-post="/admin/settings" hx-target="body" hx-push-url="true">
|
||||||
|
<div style="border:1px solid var(--border);padding:20px;margin-bottom:16px">
|
||||||
|
<h2 style="font-size:12px;font-weight:600;letter-spacing:.3px;color:var(--fg2);margin-bottom:16px;text-transform:uppercase">Server</h2>
|
||||||
|
<div class="grid-2" style="margin-bottom:0">
|
||||||
|
<div><label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">Bind Address</label><input type="text" name="bind_addr" value="{{.Config.BindAddr}}"></div>
|
||||||
|
<div><label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">Bind Port</label><input type="number" name="bind_port" value="{{.Config.BindPort}}"></div>
|
||||||
|
<div><label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">Proxy Bind Address</label><input type="text" name="proxy_bind_addr" value="{{.Config.ProxyBindAddr}}"></div>
|
||||||
|
<div></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="border:1px solid var(--border);padding:20px;margin-bottom:16px">
|
||||||
|
<h2 style="font-size:12px;font-weight:600;letter-spacing:.3px;color:var(--fg2);margin-bottom:16px;text-transform:uppercase">Dashboard</h2>
|
||||||
|
<div class="grid-2" style="margin-bottom:0">
|
||||||
|
<div><label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">Address</label><input type="text" name="dashboard_addr" value="{{.Config.WebServer.Addr}}"></div>
|
||||||
|
<div><label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">Port</label><input type="number" name="dashboard_port" value="{{.Config.WebServer.Port}}"></div>
|
||||||
|
<div><label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">Username</label><input type="text" name="dashboard_user" value="{{.Config.WebServer.User}}" autocomplete="off"></div>
|
||||||
|
<div><label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">Password</label><input type="text" name="dashboard_password" value="{{.Config.WebServer.Password}}" autocomplete="off"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="border:1px solid var(--border);padding:20px;margin-bottom:16px">
|
||||||
|
<h2 style="font-size:12px;font-weight:600;letter-spacing:.3px;color:var(--fg2);margin-bottom:16px;text-transform:uppercase">Authentication</h2>
|
||||||
|
<div class="grid-2" style="margin-bottom:0">
|
||||||
|
<div><label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">Auth Method</label>
|
||||||
|
<select name="auth_method">
|
||||||
|
<option value="token"{{if eq .Config.Auth.Method "token"}} selected{{end}}>Token</option>
|
||||||
|
<option value="oidc"{{if eq .Config.Auth.Method "oidc"}} selected{{end}}>OIDC</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div><label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">Token</label><input type="text" name="auth_token" value="{{.Config.Auth.Token}}" autocomplete="off"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="border:1px solid var(--border);padding:20px;margin-bottom:16px">
|
||||||
|
<h2 style="font-size:12px;font-weight:600;letter-spacing:.3px;color:var(--fg2);margin-bottom:16px;text-transform:uppercase">HTTP / VHost</h2>
|
||||||
|
<div class="grid-2" style="margin-bottom:0">
|
||||||
|
<div><label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">VHost HTTP Port</label><input type="number" name="vhost_http_port" value="{{.Config.VhostHTTPPort}}" placeholder="0 = disabled"></div>
|
||||||
|
<div><label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">VHost HTTPS Port</label><input type="number" name="vhost_https_port" value="{{.Config.VhostHTTPSPort}}" placeholder="0 = disabled"></div>
|
||||||
|
<div><label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">Subdomain Host</label><input type="text" name="subdomain_host" value="{{.Config.SubDomainHost}}"></div>
|
||||||
|
<div></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="border:1px solid var(--border);padding:20px;margin-bottom:16px">
|
||||||
|
<h2 style="font-size:12px;font-weight:600;letter-spacing:.3px;color:var(--fg2);margin-bottom:16px;text-transform:uppercase">Transport</h2>
|
||||||
|
<div class="grid-2" style="margin-bottom:0">
|
||||||
|
<div style="display:flex;align-items:center;gap:8px;padding-top:20px">
|
||||||
|
<input type="checkbox" name="tcp_mux" value="true" style="width:auto"{{if .Config.Transport.TCPMux}} checked{{end}}>
|
||||||
|
<label style="font-size:13px">TCP Multiplexing</label>
|
||||||
|
</div>
|
||||||
|
<div><label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">Max Pool Count</label><input type="number" name="max_pool_count" value="{{.Config.Transport.MaxPoolCount}}" placeholder="0 = unlimited"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="border:1px solid var(--border);padding:20px;margin-bottom:16px">
|
||||||
|
<h2 style="font-size:12px;font-weight:600;letter-spacing:.3px;color:var(--fg2);margin-bottom:16px;text-transform:uppercase">Logging</h2>
|
||||||
|
<div class="grid-2" style="margin-bottom:0">
|
||||||
|
<div><label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">Output</label>
|
||||||
|
<select name="log_to">
|
||||||
|
<option value="console"{{if eq .Config.Log.To "console"}} selected{{end}}>Console</option>
|
||||||
|
<option value="file"{{if eq .Config.Log.To "file"}} selected{{end}}>File</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div><label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">Level</label>
|
||||||
|
<select name="log_level">
|
||||||
|
<option value="trace"{{if eq .Config.Log.Level "trace"}} selected{{end}}>Trace</option>
|
||||||
|
<option value="debug"{{if eq .Config.Log.Level "debug"}} selected{{end}}>Debug</option>
|
||||||
|
<option value="info"{{if eq .Config.Log.Level "info"}} selected{{end}}>Info</option>
|
||||||
|
<option value="warn"{{if eq .Config.Log.Level "warn"}} selected{{end}}>Warn</option>
|
||||||
|
<option value="error"{{if eq .Config.Log.Level "error"}} selected{{end}}>Error</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div><label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">Max Days</label><input type="number" name="log_max_days" value="{{.Config.Log.MaxDays}}"></div>
|
||||||
|
<div></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="border:1px solid var(--border);padding:20px;margin-bottom:16px">
|
||||||
|
<h2 style="font-size:12px;font-weight:600;letter-spacing:.3px;color:var(--fg2);margin-bottom:16px;text-transform:uppercase">Extra Ports</h2>
|
||||||
|
<div class="grid-2" style="margin-bottom:0">
|
||||||
|
<div><label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">KCP Bind Port</label><input type="number" name="kcp_bind_port" value="{{.Config.KCPBindPort}}" placeholder="0 = disabled"></div>
|
||||||
|
<div><label style="display:block;font-size:12px;color:var(--fg2);margin-bottom:4px">QUIC Bind Port</label><input type="number" name="quic_bind_port" value="{{.Config.QUICBindPort}}" placeholder="0 = disabled"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="border:1px solid var(--border);padding:20px;margin-bottom:16px">
|
||||||
|
<h2 style="font-size:12px;font-weight:600;letter-spacing:.3px;color:var(--fg2);margin-bottom:16px;text-transform:uppercase">Misc</h2>
|
||||||
|
<div style="display:flex;align-items:center;gap:8px;margin-bottom:16px">
|
||||||
|
<input type="checkbox" name="enable_prometheus" value="true" style="width:auto"{{if .Config.EnablePrometheus}} checked{{end}}>
|
||||||
|
<label style="font-size:13px">Enable Prometheus Metrics</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="toolbar" style="margin-top:24px">
|
||||||
|
<button type="submit">Save Configuration</button>
|
||||||
|
<a href="/admin/dashboard" class="btn btn-outline" hx-get="/admin/dashboard" hx-target="#main-content" hx-push-url="true">Cancel</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
<title>Setup — frp Admin</title>
|
||||||
|
<style>
|
||||||
|
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
|
||||||
|
:root{--bg:#fff;--bg2:#f5f5f5;--fg:#000;--fg2:#888;--border:#ddd;--accent:#000;--font:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;--radius:0}
|
||||||
|
@media(prefers-color-scheme:dark){
|
||||||
|
:root{--bg:#000;--bg2:#111;--fg:#fff;--fg2:#666;--border:#333;--accent:#fff}
|
||||||
|
}
|
||||||
|
html,body{height:100%}
|
||||||
|
body{font-family:var(--font);background:var(--bg2);color:var(--fg);font-size:14px;display:flex;align-items:center;justify-content:center;min-height:100vh;padding:20px}
|
||||||
|
.setup-card{width:520px;padding:32px;background:var(--bg);border:1px solid var(--border)}
|
||||||
|
.setup-card h1{font-size:20px;margin-bottom:4px;text-align:center;letter-spacing:-.5px}
|
||||||
|
.setup-card p{font-size:13px;color:var(--fg2);text-align:center;margin-bottom:24px}
|
||||||
|
.setup-card .error{font-size:13px;margin-bottom:12px;text-align:center}
|
||||||
|
.setup-card .section-title{font-size:12px;font-weight:600;letter-spacing:.3px;color:var(--fg2);text-transform:uppercase;margin-bottom:12px;padding-top:8px;border-top:1px solid var(--border)}
|
||||||
|
.setup-card .field{margin-bottom:16px}
|
||||||
|
.setup-card .field label{display:block;font-size:12px;color:var(--fg2);margin-bottom:4px}
|
||||||
|
input{padding:8px 12px;border:1px solid var(--border);background:var(--bg);color:var(--fg);font-size:13px;width:100%;-webkit-appearance:none;appearance:none}
|
||||||
|
input:focus{outline:1px solid var(--fg)}
|
||||||
|
button{padding:8px 16px;border:1px solid var(--fg);background:var(--fg);color:var(--bg);font-size:13px;cursor:pointer;font-family:var(--font);width:100%;margin-top:8px}
|
||||||
|
button:hover{opacity:.8}
|
||||||
|
.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:12px}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="setup-card">
|
||||||
|
<h1>frp Admin Setup</h1>
|
||||||
|
<p>Create an admin account and configure your server.</p>
|
||||||
|
{{if .Error}}
|
||||||
|
<div class="error">{{.Error}}</div>
|
||||||
|
{{end}}
|
||||||
|
<form method="post" action="/admin/setup">
|
||||||
|
<div class="section-title">Admin Account</div>
|
||||||
|
<div class="grid-2">
|
||||||
|
<div class="field">
|
||||||
|
<label for="username">Username</label>
|
||||||
|
<input type="text" id="username" name="username" required autofocus>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label for="name">Display Name</label>
|
||||||
|
<input type="text" id="name" name="name" placeholder="optional">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="grid-2">
|
||||||
|
<div class="field">
|
||||||
|
<label for="password">Password</label>
|
||||||
|
<input type="password" id="password" name="password" required>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label for="confirm_password">Confirm Password</label>
|
||||||
|
<input type="password" id="confirm_password" name="confirm_password" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="section-title">Server Configuration</div>
|
||||||
|
<div class="grid-2">
|
||||||
|
<div class="field">
|
||||||
|
<label for="bind_addr">Bind Address</label>
|
||||||
|
<input type="text" id="bind_addr" name="bind_addr" value="0.0.0.0">
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label for="bind_port">Bind Port</label>
|
||||||
|
<input type="number" id="bind_port" name="bind_port" value="7000">
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label for="dashboard_addr">Dashboard Address</label>
|
||||||
|
<input type="text" id="dashboard_addr" name="dashboard_addr" value="0.0.0.0">
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label for="dashboard_port">Dashboard Port</label>
|
||||||
|
<input type="number" id="dashboard_port" name="dashboard_port" value="7500">
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label for="auth_token">Auth Token</label>
|
||||||
|
<input type="text" id="auth_token" name="auth_token" placeholder="optional">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit">Complete Setup</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
+10
-17
@@ -1,17 +1,3 @@
|
|||||||
// Copyright 2017 fatedier, fatedier@gmail.com
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -26,6 +12,12 @@ import (
|
|||||||
|
|
||||||
func (svr *Service) registerRouteHandlers(helper *httppkg.RouterRegisterHelper) {
|
func (svr *Service) registerRouteHandlers(helper *httppkg.RouterRegisterHelper) {
|
||||||
helper.Router.HandleFunc("/healthz", healthz)
|
helper.Router.HandleFunc("/healthz", healthz)
|
||||||
|
|
||||||
|
// root redirects to admin setup
|
||||||
|
helper.Router.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
http.Redirect(w, r, "/admin/setup", http.StatusFound)
|
||||||
|
})
|
||||||
|
|
||||||
subRouter := helper.Router.NewRoute().Subrouter()
|
subRouter := helper.Router.NewRoute().Subrouter()
|
||||||
|
|
||||||
subRouter.Use(helper.AuthMiddleware)
|
subRouter.Use(helper.AuthMiddleware)
|
||||||
@@ -54,9 +46,10 @@ func (svr *Service) registerRouteHandlers(helper *httppkg.RouterRegisterHelper)
|
|||||||
netpkg.MakeHTTPGzipHandler(http.StripPrefix("/static/", http.FileServer(helper.AssetsFS))),
|
netpkg.MakeHTTPGzipHandler(http.StripPrefix("/static/", http.FileServer(helper.AssetsFS))),
|
||||||
).Methods("GET")
|
).Methods("GET")
|
||||||
|
|
||||||
subRouter.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
// admin routes (htmx-based dashboard)
|
||||||
http.Redirect(w, r, "/static/", http.StatusMovedPermanently)
|
if svr.adminHandler != nil {
|
||||||
})
|
svr.adminHandler.RegisterRoutes(helper.Router)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func healthz(w http.ResponseWriter, _ *http.Request) {
|
func healthz(w http.ResponseWriter, _ *http.Request) {
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ import (
|
|||||||
"github.com/fatedier/frp/pkg/util/version"
|
"github.com/fatedier/frp/pkg/util/version"
|
||||||
"github.com/fatedier/frp/pkg/util/vhost"
|
"github.com/fatedier/frp/pkg/util/vhost"
|
||||||
"github.com/fatedier/frp/pkg/util/xlog"
|
"github.com/fatedier/frp/pkg/util/xlog"
|
||||||
|
"github.com/fatedier/frp/server/admin"
|
||||||
"github.com/fatedier/frp/server/controller"
|
"github.com/fatedier/frp/server/controller"
|
||||||
"github.com/fatedier/frp/server/group"
|
"github.com/fatedier/frp/server/group"
|
||||||
"github.com/fatedier/frp/server/metrics"
|
"github.com/fatedier/frp/server/metrics"
|
||||||
@@ -127,6 +128,9 @@ type Service struct {
|
|||||||
|
|
||||||
cfg *v1.ServerConfig
|
cfg *v1.ServerConfig
|
||||||
|
|
||||||
|
// admin web handler
|
||||||
|
adminHandler *admin.Handler
|
||||||
|
|
||||||
// service context
|
// service context
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
// call cancel to stop service
|
// call cancel to stop service
|
||||||
@@ -180,6 +184,7 @@ func NewService(cfg *v1.ServerConfig) (*Service, error) {
|
|||||||
ctx: context.Background(),
|
ctx: context.Background(),
|
||||||
}
|
}
|
||||||
if webServer != nil {
|
if webServer != nil {
|
||||||
|
svr.adminHandler = admin.NewHandler()
|
||||||
webServer.RouteRegister(svr.registerRouteHandlers)
|
webServer.RouteRegister(svr.registerRouteHandlers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user