优化通道处理

This commit is contained in:
2026-06-09 16:30:19 +08:00
parent c5453557ae
commit dd482dd6b0
10 changed files with 454 additions and 614 deletions

View File

@@ -64,6 +64,7 @@ type CreateProxy struct {
Mac string `json:"mac" validate:"required"`
IP string `json:"ip" validate:"required"`
Host *string `json:"host"`
Port *int `json:"port"`
Secret *string `json:"secret"`
Type *m.ProxyType `json:"type"`
Status *m.ProxyStatus `json:"status"`
@@ -80,6 +81,7 @@ func (s *proxyService) Create(create *CreateProxy) error {
Mac: create.Mac,
IP: orm.Inet{Addr: addr},
Host: create.Host,
Port: create.Port,
Secret: create.Secret,
Type: u.Else(create.Type, m.ProxyTypeSelfHosted),
Status: u.Else(create.Status, m.ProxyStatusOffline),
@@ -99,6 +101,7 @@ type UpdateProxy struct {
Mac *string `json:"mac"`
IP *string `json:"ip"`
Host *string `json:"host"`
Port *int `json:"port"`
Secret *string `json:"secret"`
}
@@ -121,6 +124,9 @@ func (s *proxyService) Update(update *UpdateProxy) error {
if update.Host != nil {
simples = append(simples, q.Proxy.Host.Value(*update.Host))
}
if update.Port != nil {
simples = append(simples, q.Proxy.Port.Value(*update.Port))
}
if update.Secret != nil {
hasSideEffect = true
simples = append(simples, q.Proxy.Secret.Value(*update.Secret))