Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion agent/app/dto/request/website.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type WebsiteCreate struct {
}

type StreamConfig struct {
StreamPorts string `json:"streamPorts" validate:"required"`
StreamPorts string `json:"streamPorts"`
Name string `json:"name"`
Algorithm string `json:"algorithm"`

Expand Down
6 changes: 6 additions & 0 deletions agent/app/service/website.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
primaryDomain string
)
if website.Type == constant.Stream {
if create.StreamConfig.StreamPorts == "" {
return buserr.New("ErrTypePortRange")
}
website.PrimaryDomain = create.Name
website.Protocol = constant.ProtocolStream
website.StreamPorts = create.StreamConfig.StreamPorts
Expand Down Expand Up @@ -2400,6 +2403,9 @@ func (w WebsiteService) ExecComposer(req request.ExecComposerReq) error {
}

func (w WebsiteService) UpdateStream(req request.StreamUpdate) error {
if req.StreamConfig.StreamPorts == ""{
return buserr.New("ErrTypePortRange")
}
website, err := websiteRepo.GetFirst(repo.WithByID(req.WebsiteID))
if err != nil {
return err
Expand Down
6 changes: 5 additions & 1 deletion agent/app/service/website_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/1Panel-dev/1Panel/agent/utils/xpack"
"log"
"net"
"os"
Expand All @@ -15,6 +14,8 @@ import (
"syscall"
"time"

"github.com/1Panel-dev/1Panel/agent/utils/xpack"

"github.com/1Panel-dev/1Panel/agent/app/repo"

"github.com/1Panel-dev/1Panel/agent/app/dto/request"
Expand Down Expand Up @@ -189,6 +190,9 @@ func configDefaultNginx(website *model.Website, domains []model.WebsiteDomain, a
config *components.Config
)
if website.Type == constant.Stream {
if streamConfig.StreamPorts == "" {
return buserr.New("ErrTypePortRange")
}
nginxContent := nginx_conf.GetWebsiteFile("stream_default.conf")
config, err = parser.NewStringParser(string(nginxContent)).Parse()
if err != nil {
Expand Down
Loading