support the configure of url in "http" section

This commit is contained in:
XueBing
2016-12-18 22:40:58 +08:00
parent 47db75e921
commit edf4bc431d
10 changed files with 227 additions and 106 deletions

View File

@@ -19,6 +19,7 @@ import (
"sync"
"time"
"github.com/fatedier/frp/src/models/config"
"github.com/fatedier/frp/src/models/consts"
)
@@ -29,15 +30,8 @@ var (
)
type ServerMetric struct {
Name string `json:"name"`
Type string `json:"type"`
BindAddr string `json:"bind_addr"`
ListenPort int64 `json:"listen_port"`
CustomDomains []string `json:"custom_domains"`
Status string `json:"status"`
UseEncryption bool `json:"use_encryption"`
UseGzip bool `json:"use_gzip"`
PrivilegeMode bool `json:"privilege_mode"`
config.ProxyServerConf
StatusDesc string `json:"status_desc"`
// statistics
CurrentConns int64 `json:"current_conns"`
@@ -110,24 +104,16 @@ func GetProxyMetrics(proxyName string) *ServerMetric {
}
}
func SetProxyInfo(proxyName string, proxyType, bindAddr string,
useEncryption, useGzip, privilegeMode bool, customDomains []string,
listenPort int64) {
func SetProxyInfo(p config.ProxyServerConf) {
smMutex.Lock()
info, ok := ServerMetricInfoMap[proxyName]
info, ok := ServerMetricInfoMap[p.Name]
if !ok {
info = &ServerMetric{}
info.Daily = make([]*DailyServerStats, 0)
}
info.Name = proxyName
info.Type = proxyType
info.UseEncryption = useEncryption
info.UseGzip = useGzip
info.PrivilegeMode = privilegeMode
info.BindAddr = bindAddr
info.ListenPort = listenPort
info.CustomDomains = customDomains
ServerMetricInfoMap[proxyName] = info
info.ProxyServerConf = p
ServerMetricInfoMap[p.Name] = info
smMutex.Unlock()
}
@@ -137,7 +123,7 @@ func SetStatus(proxyName string, status int64) {
smMutex.RUnlock()
if ok {
metric.mutex.Lock()
metric.Status = consts.StatusStr[status]
metric.StatusDesc = consts.StatusStr[status]
metric.mutex.Unlock()
}
}