mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-08 19:40:25 +08:00
优化代码
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
package teaconst
|
package teaconst
|
||||||
|
|
||||||
|
import "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// 流量统计
|
// 流量统计
|
||||||
|
|
||||||
@@ -10,4 +12,6 @@ var (
|
|||||||
|
|
||||||
NodeId int64 = 0
|
NodeId int64 = 0
|
||||||
NodeIdString = ""
|
NodeIdString = ""
|
||||||
|
|
||||||
|
GlobalProductName = nodeconfigs.DefaultProductName
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ func (this *HTTPAPIAction) runAction(action string, listType IPListType, item *p
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
req.Header.Set("User-Agent", "GoEdge-Node/"+teaconst.Version)
|
req.Header.Set("User-Agent", teaconst.GlobalProductName+"-Node/"+teaconst.Version)
|
||||||
resp, err := httpAPIClient.Do(req)
|
resp, err := httpAPIClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -949,6 +949,22 @@ func (this *HTTPRequest) Format(source string) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// product
|
||||||
|
if prefix == "product" {
|
||||||
|
switch suffix {
|
||||||
|
case "name":
|
||||||
|
if sharedNodeConfig.ProductConfig != nil && len(sharedNodeConfig.ProductConfig.Name) > 0 {
|
||||||
|
return sharedNodeConfig.ProductConfig.Name
|
||||||
|
}
|
||||||
|
return teaconst.GlobalProductName
|
||||||
|
case "version":
|
||||||
|
if sharedNodeConfig.ProductConfig != nil && len(sharedNodeConfig.ProductConfig.Version) > 0 {
|
||||||
|
return sharedNodeConfig.ProductConfig.Version
|
||||||
|
}
|
||||||
|
return teaconst.Version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return "${" + varName + "}"
|
return "${" + varName + "}"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -713,4 +713,9 @@ func (this *Node) onReload(config *nodeconfigs.NodeConfig) {
|
|||||||
time.Local = location
|
time.Local = location
|
||||||
this.timezone = timeZone
|
this.timezone = timeZone
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// product information
|
||||||
|
if config.ProductConfig != nil {
|
||||||
|
teaconst.GlobalProductName = config.ProductConfig.Name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user