mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-09 16:50:26 +08:00
创建网站服务后自动开启Websocket
This commit is contained in:
@@ -5,11 +5,14 @@ import (
|
|||||||
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
|
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
|
"github.com/iwind/TeaGo/logs"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
|
"github.com/iwind/TeaGo/types"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -415,6 +418,41 @@ func (this *CreateAction) RunPost(params struct {
|
|||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
var serverId = createResp.ServerId
|
||||||
|
|
||||||
|
// 开启访问日志和Websocket
|
||||||
|
if params.ServerType == serverconfigs.ServerTypeHTTPProxy {
|
||||||
|
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithServerId(this.AdminContext(), serverId)
|
||||||
|
if err == nil {
|
||||||
|
// websocket
|
||||||
|
createWebSocketResp, err := this.RPC().HTTPWebsocketRPC().CreateHTTPWebsocket(this.AdminContext(), &pb.CreateHTTPWebsocketRequest{
|
||||||
|
HandshakeTimeoutJSON: []byte(`{
|
||||||
|
"count": 30,
|
||||||
|
"unit": "second"
|
||||||
|
}`),
|
||||||
|
AllowAllOrigins: true,
|
||||||
|
AllowedOrigins: nil,
|
||||||
|
RequestSameOrigin: true,
|
||||||
|
RequestOrigin: "",
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
logs.Error(err)
|
||||||
|
} else {
|
||||||
|
websocketId := createWebSocketResp.WebsocketId
|
||||||
|
_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebWebsocket(this.AdminContext(), &pb.UpdateHTTPWebWebsocketRequest{
|
||||||
|
WebId: webConfig.Id,
|
||||||
|
WebsocketJSON: []byte(` {
|
||||||
|
"isPrior": false,
|
||||||
|
"isOn": true,
|
||||||
|
"websocketId": ` + types.String(websocketId) + `
|
||||||
|
}`),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
logs.Error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 创建日志
|
// 创建日志
|
||||||
defer this.CreateLog(oplogs.LevelInfo, "创建代理服务 %d", createResp.ServerId)
|
defer this.CreateLog(oplogs.LevelInfo, "创建代理服务 %d", createResp.ServerId)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tr v-for="(cert, index) in certs">
|
<tr v-for="(cert, index) in certs">
|
||||||
<td>{{cert.name}}
|
<td><keyword :v-word="keyword">{{cert.name}}</keyword>
|
||||||
<div v-if="cert.isCA" style="margin-top:0.5em">
|
<div v-if="cert.isCA" style="margin-top:0.5em">
|
||||||
<span class="ui label olive tiny">CA</span>
|
<span class="ui label olive tiny">CA</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div v-for="dnsName in cert.dnsNames" style="margin-bottom:0.4em">
|
<div v-for="dnsName in cert.dnsNames" style="margin-bottom:0.4em">
|
||||||
<span class="ui label tiny">{{dnsName}}</span>
|
<span class="ui label tiny"><keyword :v-word="keyword">{{dnsName}}</keyword></span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>{{certInfos[index].endDay}}</td>
|
<td>{{certInfos[index].endDay}}</td>
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>{{tlsProtocolName.toUpperCase()}}证书</td>
|
<td>{{tlsProtocolName.toUpperCase()}}证书</td>
|
||||||
<td>
|
<td>
|
||||||
<ssl-certs-box></ssl-certs-box>
|
<ssl-certs-box :v-protocol="tlsProtocolName.toLowerCase()"></ssl-certs-box>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Reference in New Issue
Block a user