Skip to content

Commit ab13dde

Browse files
feat: The website supports TCP/UDP proxying. (#11302)
Refs #5135 Refs #6976
1 parent 2d1792c commit ab13dde

File tree

43 files changed

+2498
-1826
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2498
-1826
lines changed

agent/app/api/v2/website.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,3 +1223,23 @@ func (b *BaseApi) UpdateCORSConfig(c *gin.Context) {
12231223
}
12241224
helper.Success(c)
12251225
}
1226+
1227+
// @Tags Website
1228+
// @Summary Update Stream Config
1229+
// @Accept json
1230+
// @Param request body request.StreamUpdate true "request"
1231+
// @Success 200
1232+
// @Security ApiKeyAuth
1233+
// @Security Timestamp
1234+
// @Router /websites/stream/update [post]
1235+
func (b *BaseApi) UpdateStreamConfig(c *gin.Context) {
1236+
var req request.StreamUpdate
1237+
if err := helper.CheckBindAndValidate(&req, c); err != nil {
1238+
return
1239+
}
1240+
if err := websiteService.UpdateStream(req); err != nil {
1241+
helper.InternalServer(c, err)
1242+
return
1243+
}
1244+
helper.Success(c)
1245+
}

agent/app/dto/request/website.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ type WebsiteCreate struct {
3838
FtpConfig
3939
DataBaseConfig
4040
SSLConfig
41+
StreamConfig
42+
}
43+
44+
type StreamConfig struct {
45+
StreamPorts string `json:"streamPorts" validate:"required"`
46+
Name string `json:"name"`
47+
Algorithm string `json:"algorithm"`
48+
49+
Servers []dto.NginxUpstreamServer `json:"servers"`
50+
}
51+
52+
type StreamUpdate struct {
53+
WebsiteID uint `json:"websiteID" validate:"required"`
54+
55+
StreamConfig
4156
}
4257

4358
type WebsiteOptionReq struct {

agent/app/dto/response/website.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package response
33
import (
44
"time"
55

6+
"github.com/1Panel-dev/1Panel/agent/app/dto"
67
"github.com/1Panel-dev/1Panel/agent/app/model"
78
)
89

@@ -16,6 +17,9 @@ type WebsiteDTO struct {
1617
RuntimeType string `json:"runtimeType"`
1718
SiteDir string `json:"siteDir"`
1819
OpenBaseDir bool `json:"openBaseDir"`
20+
Algorithm string `json:"algorithm"`
21+
22+
Servers []dto.NginxUpstreamServer `json:"servers"`
1923
}
2024

2125
type WebsiteRes struct {

agent/app/model/website.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ type Website struct {
3737

3838
Favorite bool `json:"favorite"`
3939

40+
StreamPorts string `json:"streamPorts"`
41+
4042
Domains []WebsiteDomain `json:"domains" gorm:"-:migration"`
4143
WebsiteSSL WebsiteSSL `json:"webSiteSSL" gorm:"-:migration"`
4244
}

agent/app/service/nginx_utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func getNginxFull(website *model.Website) (dto.NginxFull, error) {
5151
if website != nil {
5252
nginxFull.Website = *website
5353
var siteNginxConfig dto.NginxConfig
54-
siteConfigPath := GetSitePath(*website, SiteConf)
54+
siteConfigPath := GetWebsiteConfigPath(*website)
5555
siteNginxConfig.FilePath = siteConfigPath
5656
siteNginxContent, err := os.ReadFile(siteConfigPath)
5757
if err != nil {

0 commit comments

Comments
 (0)