From 9d4430c1991d0252362984ee675c2a81a1744a69 Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 15 Oct 2020 19:40:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core.go | 3 +-- core/link.go | 7 +++---- web/api/model.go | 12 ++++++------ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/core/core.go b/core/core.go index 51c7531..e238bb6 100644 --- a/core/core.go +++ b/core/core.go @@ -20,8 +20,7 @@ func Tunnels() []Tunnel { } func Recovery() error { - //TODO 改为 加载模型,创建通道 - var cs []models.ModelAdapter + var cs []models.Tunnel err := db.Engine.Find(&cs) if err != nil { return err diff --git a/core/link.go b/core/link.go index a551a99..66b3906 100644 --- a/core/link.go +++ b/core/link.go @@ -151,10 +151,9 @@ func newLink(ch Tunnel, conn net.Conn) *Link { c := ch.GetTunnel() return &Link{ Link: models.Link{ - Id: 0, TunnelId: c.Id, - //ModelTunnelId: c.ModelId, - Active: true, + ModelId: c.ModelId, + Active: true, }, tunnel: ch, conn: conn, @@ -166,8 +165,8 @@ func newPacketLink(ch Tunnel, conn net.PacketConn, addr net.Addr) *Link { c := ch.GetTunnel() return &Link{ Link: models.Link{ - Id: 0, TunnelId: c.Id, + ModelId: c.ModelId, Active: true, }, tunnel: ch, diff --git a/web/api/model.go b/web/api/model.go index 7722906..15e76e6 100644 --- a/web/api/model.go +++ b/web/api/model.go @@ -42,7 +42,7 @@ type ModelTunnel struct { HeartBeatContent string `json:"heart_beat_content"` HeartBeatIsHex bool `json:"heart_beat_is_hex"` - Protocol string `json:"protocol"` + ProtocolName string `json:"protocol"` ProtocolOpts string `json:"protocol_opts"` PollingEnable bool `json:"polling_enable"` //轮询 @@ -52,7 +52,7 @@ type ModelTunnel struct { type ModelVariable struct { ModelBase - + Tunnel string `json:"tunnel"` models.Address @@ -71,7 +71,7 @@ type ModelVariable struct { type ModelBatch struct { ModelBase - + Tunnel string `json:"tunnel"` models.Address `xorm:"extends"` @@ -86,7 +86,7 @@ type ModelBatch struct { type ModelJob struct { ModelBase - + Cron string `json:"cron"` Script string `json:"script"` //javascript } @@ -129,7 +129,7 @@ func modelImport(ctx *gin.Context) { Name: t.Name, Description: t.Description, }, - Protocol: t.Protocol, + ProtocolName: t.ProtocolName, ProtocolOpts: t.ProtocolOpts, PollingEnable: t.PollingEnable, PollingInterval: t.PollingInterval, @@ -270,7 +270,7 @@ func modelExport(ctx *gin.Context) { Name: v.Name, Description: v.Description, }, - Protocol: v.Protocol, + ProtocolName: v.ProtocolName, ProtocolOpts: v.ProtocolOpts, PollingEnable: v.PollingEnable, PollingInterval: v.PollingInterval, -- GitLab