Skip to content

Commit

Permalink
stab an high number for default connmanager limits
Browse files Browse the repository at this point in the history
Signed-off-by: mudler <mudler@localai.io>
  • Loading branch information
mudler committed Oct 23, 2023
1 parent 10d370b commit 2d525b6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
14 changes: 14 additions & 0 deletions cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,18 @@ var CommonFlags []cli.Flag = []cli.Flag{
Usage: "List of discovery peers to use",
EnvVar: "EDGEVPNBOOTSTRAPPEERS",
},
&cli.IntFlag{
Name: "connection-high-water",
Usage: "max number of connection allowed",
EnvVar: "EDGEVPN_CONNECTION_HIGH_WATER",
Value: 0,
},
&cli.IntFlag{
Name: "connection-low-water",
Usage: "low number of connection allowed",
EnvVar: "EDGEVPN_CONNECTION_LOW_WATER",
Value: 0,
},
&cli.StringSliceFlag{
Name: "autorelay-static-peer",
Usage: "List of autorelay static peers to use",
Expand Down Expand Up @@ -427,6 +439,8 @@ func cliToOpts(c *cli.Context) ([]node.Option, []vpn.Option, *logger.Logger) {
StaticRelays: c.StringSlice("autorelay-static-peer"),
AutoRelayDiscoveryInterval: autorelayInterval,
OnlyStaticRelays: c.Bool("autorelay-static-only"),
HighWater: c.Int("connection-high-water"),
LowWater: c.Int("connection-low-water"),
},
Limit: config.ResourceLimit{
Enable: c.Bool("limit-enable"),
Expand Down
20 changes: 17 additions & 3 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ type Connection struct {
PeerTable map[string]peer.ID

MaxConnections int

LowWater int
HighWater int
}

// NAT is the structure relative to NAT configuration settings
Expand Down Expand Up @@ -268,10 +271,21 @@ func (c Config) ToOpts(l *logger.Logger) ([]node.Option, []vpn.Option, error) {
))
}

if c.Connection.MaxConnections != 0 {
if c.Connection.LowWater != 0 && c.Connection.HighWater != 0 {
cm, err := connmanager.NewConnManager(
c.Connection.LowWater,
c.Connection.HighWater,
connmanager.WithGracePeriod(80*time.Second),
)
if err != nil {
llger.Fatal("could not create connection manager")
}

libp2pOpts = append(libp2pOpts, libp2p.ConnectionManager(cm))
} else {
cm, err := connmanager.NewConnManager(
1,
c.Connection.MaxConnections,
9999999999,

Check failure on line 287 in pkg/config/config.go

View workflow job for this annotation

GitHub Actions / build

cannot use 9999999999 (untyped int constant) as int value in argument to connmanager.NewConnManager (overflows)
9999999999,

Check failure on line 288 in pkg/config/config.go

View workflow job for this annotation

GitHub Actions / build

cannot use 9999999999 (untyped int constant) as int value in argument to connmanager.NewConnManager (overflows)
connmanager.WithGracePeriod(80*time.Second),
)
if err != nil {
Expand Down

0 comments on commit 2d525b6

Please sign in to comment.