Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit 5b20119

Browse files
committed
将部分"TeaWeb"文字改成常量,以便于用户可以自行编译修改
1 parent f84ce5d commit 5b20119

9 files changed

Lines changed: 14 additions & 12 deletions

File tree

teaconfigs/agents/source_nginx_status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (this *NginxStatusSource) Execute(params map[string]string) (value interfac
6868
"cost": time.Since(before).Seconds(),
6969
}, err
7070
}
71-
req.Header.Set("User-Agent", "TeaWeb/"+teaconst.TeaVersion)
71+
req.Header.Set("User-Agent", teaconst.TeaProductCode+"/"+teaconst.TeaVersion)
7272

7373
client := teautils.SharedHttpClient(timeout)
7474
resp, err := client.Do(req)

teaconfigs/agents/source_teaweb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (this *TeaWebSource) Execute(params map[string]string) (value interface{},
5959
}
6060
return value, err
6161
}
62-
req.Header.Set("User-Agent", "TeaWeb/"+teaconst.TeaVersion)
62+
req.Header.Set("User-Agent", teaconst.TeaProductCode+"/"+teaconst.TeaVersion)
6363

6464
timeout := this.Timeout
6565
if timeout <= 0 {

teaconfigs/agents/source_url_connectivity.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (this *URLConnectivitySource) Execute(params map[string]string) (value inte
7676
for _, param := range this.Params {
7777
_, ok := query[param.Name]
7878
if ok {
79-
query[param.Name ] = append(query[param.Name], param.Value)
79+
query[param.Name] = append(query[param.Name], param.Value)
8080
} else {
8181
query[param.Name] = []string{param.Value}
8282
}
@@ -116,7 +116,7 @@ func (this *URLConnectivitySource) Execute(params map[string]string) (value inte
116116

117117
_, ok := this.lookupHeader("User-Agent")
118118
if !ok {
119-
req.Header.Set("User-Agent", "TeaWeb/"+teaconst.TeaVersion)
119+
req.Header.Set("User-Agent", teaconst.TeaProductCode+"/"+teaconst.TeaVersion)
120120
}
121121

122122
if this.Method == "POST" {

teaconfigs/agents/source_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (this *WebHookSource) Execute(params map[string]string) (value interface{},
8686
for _, param := range this.Params {
8787
_, ok := query[param.Name]
8888
if ok {
89-
query[param.Name ] = append(query[param.Name], param.Value)
89+
query[param.Name] = append(query[param.Name], param.Value)
9090
} else {
9191
query[param.Name] = []string{param.Value}
9292
}
@@ -119,7 +119,7 @@ func (this *WebHookSource) Execute(params map[string]string) (value interface{},
119119

120120
_, ok := this.lookupHeader("User-Agent")
121121
if !ok {
122-
req.Header.Set("User-Agent", "TeaWeb/"+teaconst.TeaVersion)
122+
req.Header.Set("User-Agent", teaconst.TeaProductCode+"/"+teaconst.TeaVersion)
123123
}
124124

125125
if this.Method == "POST" {

teaconfigs/backend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ func (this *BackendConfig) CheckHealth() bool {
297297
logs.Error(err)
298298
return false
299299
}
300-
req.Header.Set("User-Agent", "TeaWeb/"+teaconst.TeaVersion)
300+
req.Header.Set("User-Agent", teaconst.TeaProductCode+"/"+teaconst.TeaVersion)
301301
client := teautils.SharedHttpClient(timeout)
302302
resp, err := client.Do(req)
303303
if err != nil {

teaconfigs/fastcgi.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (this *FastcgiConfig) Validate() error {
5454
this.paramsMap["SCRIPT_FILENAME"] = ""
5555
}
5656
if !this.paramsMap.Has("SERVER_SOFTWARE") {
57-
this.paramsMap["SERVER_SOFTWARE"] = "teaweb/" + teaconst.TeaVersion
57+
this.paramsMap["SERVER_SOFTWARE"] = teaconst.TeaProductCode + "/" + teaconst.TeaVersion
5858
}
5959
if !this.paramsMap.Has("REDIRECT_STATUS") {
6060
this.paramsMap["REDIRECT_STATUS"] = "200"

teaconfigs/notices/media_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func (this *NoticeWebhookMedia) Send(user string, subject string, body string) (
8888
if err != nil {
8989
return nil, err
9090
}
91-
req.Header.Set("User-Agent", "TeaWeb/"+teaconst.TeaVersion)
91+
req.Header.Set("User-Agent", teaconst.TeaProductCode+"/"+teaconst.TeaVersion)
9292

9393
if len(this.Headers) > 0 {
9494
for _, h := range this.Headers {

teaconfigs/notices/setting.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package notices
22

33
import (
44
"github.com/TeaWeb/code/teaconfigs/shared"
5+
"github.com/TeaWeb/code/teaconst"
56
"github.com/iwind/TeaGo/Tea"
67
"github.com/iwind/TeaGo/files"
78
"github.com/iwind/TeaGo/logs"
@@ -163,9 +164,9 @@ func (this *NoticeSetting) NotifyReceivers(level NoticeLevel, receivers []*Notic
163164
}
164165
subjectContent := subject
165166
if len(subjectContent) == 0 {
166-
subjectContent = "[TeaWeb][" + FindNoticeLevelName(level) + "]有新的通知"
167-
} else if !strings.HasPrefix(subject, "[TeaWeb]") {
168-
subjectContent = "[TeaWeb][" + FindNoticeLevelName(level) + "]" + subject
167+
subjectContent = "[" + teaconst.TeaProductName + "][" + FindNoticeLevelName(level) + "]有新的通知"
168+
} else if !strings.HasPrefix(subject, "["+teaconst.TeaProductName+"]") {
169+
subjectContent = "[" + teaconst.TeaProductName + "][" + FindNoticeLevelName(level) + "]" + subject
169170
}
170171
_, err := raw.Send(user, subjectContent, body)
171172
if err != nil {

teaconst/const.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ const (
55

66
TeaProcessName = "teaweb" // 进程名
77
TeaProductName = "TeaWeb" // 产品名
8+
TeaProductCode = "TeaWeb" // 产品代号,会用在一些对外访问的User-Agent里面,一定要是英文
89
)

0 commit comments

Comments
 (0)