123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- package web
- import (
- "context"
- "fmt"
- v1 "github.com/go-nunu/nunu-layout-advanced/api/v1"
- )
- // ConfigureWebsocket 配置WebSocket
- func (s *AidedWebService) ConfigureWebsocket(ctx context.Context, webId int64) error {
- websocketId, err := s.websocket.AddWebsocket(ctx)
- if err != nil {
- return fmt.Errorf("添加WebSocket失败: %w", err)
- }
- if err := s.websocket.EnableOrDisable(ctx, webId, websocketId, true, false); err != nil {
- return fmt.Errorf("启用WebSocket失败: %w", err)
- }
- return nil
- }
- // ConfigureProxyProtocol 配置代理协议
- func (s *AidedWebService) ConfigureProxyProtocol(ctx context.Context, proxy bool, cdnWebId int64) error {
- if err := s.proxy.EditProxy(ctx, cdnWebId, v1.ProxyProtocolJSON{
- IsOn: proxy,
- Version: proxyProtocolVersion,
- }); err != nil {
- return fmt.Errorf("启用代理协议失败: %w", err)
- }
- return nil
- }
- // ConfigureCCProtection 配置CC防护
- func (s *AidedWebService) ConfigureCCProtection(ctx context.Context, ccConfig v1.CcConfigRequest, webId int64) error {
- if err := s.cc.EditCcConfig(ctx, webId, ccConfig); err != nil {
- return fmt.Errorf("配置CC防护失败: %w", err)
- }
- return nil
- }
- // ConfigureWafFirewall 配置WAF防火墙
- func (s *AidedWebService) ConfigureWafFirewall(ctx context.Context, webId int64, groupId int) error {
- if err := s.ccIpList.AddCcIpListPolicy(ctx, webId, int64(groupId)); err != nil {
- return fmt.Errorf("配置WAF防火墙失败: %w", err)
- }
- return nil
- }
|