mirror of
https://github.com/fatedier/frp.git
synced 2025-07-22 05:43:55 +07:00
support yaml/json/toml configuration format, make ini deprecated (#3599)
This commit is contained in:
@ -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++ {
|
||||
|
Reference in New Issue
Block a user