forked from Mxmilu666/frp
chore(ci): update Go version and golangci-lint version
feat(linter): add new linters G118 and G704 refactor(proxy): optimize proxy status slice initialization fix(api): clarify comment regarding URL construction fix(deps): upgrade github.com/hashicorp/yamux to v0.1.2 docs(flags): improve DNS server flag description refactor(controller): simplify port range return logic refactor(featuregate): optimize enabled features string conversion
This commit is contained in:
4
.github/workflows/golangci-lint.yml
vendored
4
.github/workflows/golangci-lint.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-go@v5
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.24'
|
go-version: '1.25'
|
||||||
cache: false
|
cache: false
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
@@ -32,4 +32,4 @@ jobs:
|
|||||||
uses: golangci/golangci-lint-action@v8
|
uses: golangci/golangci-lint-action@v8
|
||||||
with:
|
with:
|
||||||
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
|
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
|
||||||
version: v2.3
|
version: v2.11
|
||||||
@@ -39,7 +39,9 @@ linters:
|
|||||||
- G404
|
- G404
|
||||||
- G501
|
- G501
|
||||||
- G115
|
- G115
|
||||||
|
- G118
|
||||||
- G204
|
- G204
|
||||||
|
- G704
|
||||||
severity: low
|
severity: low
|
||||||
confidence: low
|
confidence: low
|
||||||
govet:
|
govet:
|
||||||
|
|||||||
@@ -118,9 +118,9 @@ func (pm *Manager) HandleEvent(payload any) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (pm *Manager) GetAllProxyStatus() []*WorkingStatus {
|
func (pm *Manager) GetAllProxyStatus() []*WorkingStatus {
|
||||||
ps := make([]*WorkingStatus, 0)
|
|
||||||
pm.mu.RLock()
|
pm.mu.RLock()
|
||||||
defer pm.mu.RUnlock()
|
defer pm.mu.RUnlock()
|
||||||
|
ps := make([]*WorkingStatus, 0, len(pm.proxies))
|
||||||
for _, pxy := range pm.proxies {
|
for _, pxy := range pm.proxies {
|
||||||
ps = append(ps, pxy.GetStatus())
|
ps = append(ps, pxy.GetStatus())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -299,7 +299,7 @@ func runClientWithTokenAndIDs(token string, ids []string, unsafeFeatures *securi
|
|||||||
|
|
||||||
// Build URL with query parameters
|
// Build URL with query parameters
|
||||||
url := fmt.Sprintf("%s/api/v1/tunnel/frpc/config?token=%s&id=%s", apiServer, token, strings.Join(ids, ","))
|
url := fmt.Sprintf("%s/api/v1/tunnel/frpc/config?token=%s&id=%s", apiServer, token, strings.Join(ids, ","))
|
||||||
// #nosec G107 -- URL is constructed from trusted source (environment variable or hardcoded)
|
// URL is constructed from trusted source (environment variable or hardcoded)
|
||||||
req, err := http.NewRequest("GET", url, nil)
|
req, err := http.NewRequest("GET", url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create API request: %v", err)
|
return fmt.Errorf("failed to create API request: %v", err)
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -11,7 +11,7 @@ require (
|
|||||||
github.com/google/uuid v1.6.0
|
github.com/google/uuid v1.6.0
|
||||||
github.com/gorilla/mux v1.8.1
|
github.com/gorilla/mux v1.8.1
|
||||||
github.com/gorilla/websocket v1.5.0
|
github.com/gorilla/websocket v1.5.0
|
||||||
github.com/hashicorp/yamux v0.1.1
|
github.com/hashicorp/yamux v0.1.2
|
||||||
github.com/onsi/ginkgo/v2 v2.23.4
|
github.com/onsi/ginkgo/v2 v2.23.4
|
||||||
github.com/onsi/gomega v1.36.3
|
github.com/onsi/gomega v1.36.3
|
||||||
github.com/pelletier/go-toml/v2 v2.2.0
|
github.com/pelletier/go-toml/v2 v2.2.0
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ func RegisterClientCommonConfigFlags(cmd *cobra.Command, c *v1.ClientCommonConfi
|
|||||||
cmd.PersistentFlags().Int64VarP(&c.Log.MaxDays, "log_max_days", "", 3, "log file reversed days")
|
cmd.PersistentFlags().Int64VarP(&c.Log.MaxDays, "log_max_days", "", 3, "log file reversed days")
|
||||||
cmd.PersistentFlags().BoolVarP(&c.Log.DisablePrintColor, "disable_log_color", "", false, "disable log color in console")
|
cmd.PersistentFlags().BoolVarP(&c.Log.DisablePrintColor, "disable_log_color", "", false, "disable log color in console")
|
||||||
cmd.PersistentFlags().StringVarP(&c.Transport.TLS.ServerName, "tls_server_name", "", "", "specify the custom server name of tls certificate")
|
cmd.PersistentFlags().StringVarP(&c.Transport.TLS.ServerName, "tls_server_name", "", "", "specify the custom server name of tls certificate")
|
||||||
cmd.PersistentFlags().StringVarP(&c.DNSServer, "dns_server", "", "", "specify dns server instead of using system default one, support DoH url like https://1.1.1.1/dns-query")
|
cmd.PersistentFlags().StringVarP(&c.DNSServer, "dns_server", "", "", "specify dns server or DoH url (https://1.1.1.1/dns-query) instead of system default")
|
||||||
c.Transport.TLS.Enable = cmd.PersistentFlags().BoolP("tls_enable", "", true, "enable frpc tls")
|
c.Transport.TLS.Enable = cmd.PersistentFlags().BoolP("tls_enable", "", true, "enable frpc tls")
|
||||||
}
|
}
|
||||||
cmd.PersistentFlags().StringVarP(&c.User, "user", "u", "", "user")
|
cmd.PersistentFlags().StringVarP(&c.User, "user", "u", "", "user")
|
||||||
|
|||||||
@@ -375,7 +375,6 @@ func getRangePorts(addrs []string, difference, maxNumber int) []msg.PortsRange {
|
|||||||
if !isLast {
|
if !isLast {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
var ports []msg.PortsRange
|
|
||||||
_, portStr, err := net.SplitHostPort(addr)
|
_, portStr, err := net.SplitHostPort(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
@@ -384,9 +383,8 @@ func getRangePorts(addrs []string, difference, maxNumber int) []msg.PortsRange {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
ports = append(ports, msg.PortsRange{
|
return []msg.PortsRange{{
|
||||||
From: max(port-difference-5, port-maxNumber, 1),
|
From: max(port-difference-5, port-maxNumber, 1),
|
||||||
To: min(port+difference+5, port+maxNumber, 65535),
|
To: min(port+difference+5, port+maxNumber, 65535),
|
||||||
})
|
}}
|
||||||
return ports
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,8 +171,9 @@ func (f *featureGate) Add(features map[Feature]FeatureSpec) error {
|
|||||||
|
|
||||||
// String returns a string containing all enabled feature gates, formatted as "key1=value1,key2=value2,..."
|
// String returns a string containing all enabled feature gates, formatted as "key1=value1,key2=value2,..."
|
||||||
func (f *featureGate) String() string {
|
func (f *featureGate) String() string {
|
||||||
pairs := []string{}
|
enabled := f.enabled.Load().(map[Feature]bool)
|
||||||
for k, v := range f.enabled.Load().(map[Feature]bool) {
|
pairs := make([]string, 0, len(enabled))
|
||||||
|
for k, v := range enabled {
|
||||||
pairs = append(pairs, fmt.Sprintf("%s=%t", k, v))
|
pairs = append(pairs, fmt.Sprintf("%s=%t", k, v))
|
||||||
}
|
}
|
||||||
sort.Strings(pairs)
|
sort.Strings(pairs)
|
||||||
|
|||||||
Reference in New Issue
Block a user