mirror of https://github.com/fatedier/frp.git
commit
5a6d9f60c2
@ -1 +1,25 @@
|
||||
No feature changes, just a fix for the issue of no released assets in version 0.55.0.
|
||||
### Features
|
||||
|
||||
* Support range ports mapping in TOML/YAML/JSON configuration file by using go template syntax.
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
{{- range $_, $v := parseNumberRangePair "6000-6006,6007" "6000-6006,6007" }}
|
||||
[[proxies]]
|
||||
name = "tcp-{{ $v.First }}"
|
||||
type = "tcp"
|
||||
localPort = {{ $v.First }}
|
||||
remotePort = {{ $v.Second }}
|
||||
{{- end }}
|
||||
```
|
||||
|
||||
This will create 8 proxies such as `tcp-6000, tcp-6001, ... tcp-6007`.
|
||||
|
||||
* Health check supports custom request headers.
|
||||
* Enable compatibility mode for the Android system to solve the issues of incorrect log time caused by time zone problems and default DNS resolution failures.
|
||||
|
||||
### Fixes
|
||||
|
||||
* Fix the issue of incorrect interval time for rotating the log by day.
|
||||
* Disable quic-go's ECN support by default. It may cause issues on certain operating systems.
|
||||
|
@ -0,0 +1,52 @@
|
||||
// Copyright 2024 The frp Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/fatedier/frp/pkg/util/util"
|
||||
)
|
||||
|
||||
type NumberPair struct {
|
||||
First int64
|
||||
Second int64
|
||||
}
|
||||
|
||||
func parseNumberRangePair(firstRangeStr, secondRangeStr string) ([]NumberPair, error) {
|
||||
firstRangeNumbers, err := util.ParseRangeNumbers(firstRangeStr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
secondRangeNumbers, err := util.ParseRangeNumbers(secondRangeStr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(firstRangeNumbers) != len(secondRangeNumbers) {
|
||||
return nil, fmt.Errorf("first and second range numbers are not in pairs")
|
||||
}
|
||||
pairs := make([]NumberPair, 0, len(firstRangeNumbers))
|
||||
for i := 0; i < len(firstRangeNumbers); i++ {
|
||||
pairs = append(pairs, NumberPair{
|
||||
First: firstRangeNumbers[i],
|
||||
Second: secondRangeNumbers[i],
|
||||
})
|
||||
}
|
||||
return pairs, nil
|
||||
}
|
||||
|
||||
func parseNumberRange(firstRangeStr string) ([]int64, error) {
|
||||
return util.ParseRangeNumbers(firstRangeStr)
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
// Copyright 2024 The frp Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//go:build !android
|
||||
|
||||
package system
|
||||
|
||||
// EnableCompatibilityMode enables compatibility mode for different system.
|
||||
// For example, on Android, the inability to obtain the correct time zone will result in incorrect log time output.
|
||||
func EnableCompatibilityMode() {
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
// Copyright 2024 The frp Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func EnableCompatibilityMode() {
|
||||
fixTimezone()
|
||||
fixDNSResolver()
|
||||
}
|
||||
|
||||
// fixTimezone is used to try our best to fix timezone issue on some Android devices.
|
||||
func fixTimezone() {
|
||||
out, err := exec.Command("/system/bin/getprop", "persist.sys.timezone").Output()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
loc, err := time.LoadLocation(strings.TrimSpace(string(out)))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
time.Local = loc
|
||||
}
|
||||
|
||||
// fixDNSResolver will first attempt to resolve google.com to check if the current DNS is available.
|
||||
// If it is not available, it will default to using 8.8.8.8 as the DNS server.
|
||||
// This is a workaround for the issue that golang can't get the default DNS servers on Android.
|
||||
func fixDNSResolver() {
|
||||
// First, we attempt to resolve a domain. If resolution is successful, no modifications are necessary.
|
||||
// In real-world scenarios, users may have already configured /etc/resolv.conf, or compiled directly
|
||||
// in the Android environment instead of using cross-platform compilation, so this issue does not arise.
|
||||
if net.DefaultResolver != nil {
|
||||
timeoutCtx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
_, err := net.DefaultResolver.LookupHost(timeoutCtx, "google.com")
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
// If the resolution fails, use 8.8.8.8 as the DNS server.
|
||||
// Note: If there are other methods to obtain the default DNS servers, the default DNS servers should be used preferentially.
|
||||
net.DefaultResolver = &net.Resolver{
|
||||
PreferGo: true,
|
||||
Dial: func(ctx context.Context, network, _ string) (net.Conn, error) {
|
||||
return net.Dial(network, "8.8.8.8:53")
|
||||
},
|
||||
}
|
||||
}
|
@ -1,11 +1,9 @@
|
||||
package framework
|
||||
|
||||
type FRPClient struct {
|
||||
port int
|
||||
}
|
||||
import (
|
||||
clientsdk "github.com/fatedier/frp/pkg/sdk/client"
|
||||
)
|
||||
|
||||
func (f *Framework) FRPClient(port int) *FRPClient {
|
||||
return &FRPClient{
|
||||
port: port,
|
||||
}
|
||||
func (f *Framework) APIClientForFrpc(port int) *clientsdk.Client {
|
||||
return clientsdk.New("127.0.0.1", port)
|
||||
}
|
||||
|
Loading…
Reference in New Issue