support yaml/json/toml configuration format, make ini deprecated (#3599)

This commit is contained in:
fatedier
2023-09-06 10:18:02 +08:00
committed by GitHub
parent 885b029fcf
commit c95311d1a0
103 changed files with 4178 additions and 3829 deletions

View File

@ -6,6 +6,8 @@ import (
"strconv"
"sync"
"time"
"github.com/fatedier/frp/pkg/config/types"
)
const (
@ -39,7 +41,7 @@ type Manager struct {
mu sync.Mutex
}
func NewManager(netType string, bindAddr string, allowPorts map[int]struct{}) *Manager {
func NewManager(netType string, bindAddr string, allowPorts []types.PortsRange) *Manager {
pm := &Manager{
reservedPorts: make(map[string]*PortCtx),
usedPorts: make(map[int]*PortCtx),
@ -48,8 +50,14 @@ func NewManager(netType string, bindAddr string, allowPorts map[int]struct{}) *M
netType: netType,
}
if len(allowPorts) > 0 {
for port := range allowPorts {
pm.freePorts[port] = struct{}{}
for _, pair := range allowPorts {
if pair.Single > 0 {
pm.freePorts[pair.Single] = struct{}{}
} else {
for i := pair.Start; i <= pair.End; i++ {
pm.freePorts[i] = struct{}{}
}
}
}
} else {
for i := MinPort; i <= MaxPort; i++ {