moar super network (#1010)

This commit is contained in:
Michael Quigley
2025-07-29 15:00:33 -04:00
parent 7fa4b84314
commit e79a25bf69
9 changed files with 58 additions and 30 deletions

View File

@@ -5,6 +5,12 @@ import (
"encoding/json"
"errors"
"fmt"
"net/url"
"os"
"os/signal"
"syscall"
"time"
tea "github.com/charmbracelet/bubbletea"
"github.com/go-openapi/runtime"
httptransport "github.com/go-openapi/runtime/client"
@@ -24,11 +30,6 @@ import (
"github.com/openziti/zrok/util"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"net/url"
"os"
"os/signal"
"syscall"
"time"
)
func init() {
@@ -111,6 +112,8 @@ func (cmd *accessPrivateCommand) run(_ *cobra.Command, args []string) {
func (cmd *accessPrivateCommand) accessLocal(args []string, root env_core.Root) {
shrToken := args[0]
superNetwork, _ := root.SuperNetwork()
zrok, err := root.Client()
if err != nil {
cmd.error(err)
@@ -171,6 +174,7 @@ func (cmd *accessPrivateCommand) accessLocal(args []string, root env_core.Root)
IdentityName: root.EnvironmentIdentityName(),
ShrToken: args[0],
RequestsChan: requests,
SuperNetwork: superNetwork,
})
if err != nil {
cmd.shutdown(accessResp.Payload.FrontendToken, root.Environment().ZitiIdentity, shrToken, zrok, auth)
@@ -190,6 +194,7 @@ func (cmd *accessPrivateCommand) accessLocal(args []string, root env_core.Root)
ShrToken: args[0],
RequestsChan: requests,
IdleTime: time.Minute,
SuperNetwork: superNetwork,
})
if err != nil {
cmd.shutdown(accessResp.Payload.FrontendToken, root.Environment().ZitiIdentity, shrToken, zrok, auth)
@@ -208,6 +213,7 @@ func (cmd *accessPrivateCommand) accessLocal(args []string, root env_core.Root)
IdentityName: root.EnvironmentIdentityName(),
ShrToken: args[0],
RequestsChan: requests,
SuperNetwork: superNetwork,
})
if err != nil {
cmd.shutdown(accessResp.Payload.FrontendToken, root.Environment().ZitiIdentity, shrToken, zrok, auth)
@@ -228,6 +234,7 @@ func (cmd *accessPrivateCommand) accessLocal(args []string, root env_core.Root)
IdentityName: root.EnvironmentIdentityName(),
ShrToken: args[0],
RequestsChan: requests,
SuperNetwork: superNetwork,
})
if err != nil {
cmd.shutdown(accessResp.Payload.FrontendToken, root.Environment().ZitiIdentity, shrToken, zrok, auth)
@@ -246,6 +253,7 @@ func (cmd *accessPrivateCommand) accessLocal(args []string, root env_core.Root)
cfg.Address = bindAddress
cfg.ResponseHeaders = cmd.responseHeaders
cfg.RequestsChan = requests
cfg.SuperNetwork = superNetwork
fe, err := proxy.NewFrontend(cfg)
if err != nil {
cmd.shutdown(accessResp.Payload.FrontendToken, root.Environment().ZitiIdentity, shrToken, zrok, auth)

View File

@@ -107,10 +107,7 @@ func (cmd *sharePrivateCommand) run(_ *cobra.Command, args []string) {
func (cmd *sharePrivateCommand) shareLocal(args []string, root env_core.Root) {
var target string
superNetwork := false
if root.Config() != nil {
superNetwork = root.Config().SuperNetwork
}
superNetwork, _ := root.SuperNetwork()
switch cmd.backendMode {
case "proxy":

View File

@@ -121,10 +121,7 @@ func (cmd *sharePublicCommand) run(_ *cobra.Command, args []string) {
func (cmd *sharePublicCommand) shareLocal(args []string, root env_core.Root) {
var target string
superNetwork := false
if root.Config() != nil {
superNetwork = root.Config().SuperNetwork
}
superNetwork, _ := root.SuperNetwork()
switch cmd.backendMode {
case "proxy":

View File

@@ -102,10 +102,7 @@ func (cmd *shareReservedCommand) shareLocal(args []string, root env_core.Root) {
shrToken := args[0]
var target string
superNetwork := false
if root.Config() != nil {
superNetwork = root.Config().SuperNetwork
}
superNetwork, _ := root.SuperNetwork()
zrok, err := root.Client()
if err != nil {

View File

@@ -27,6 +27,7 @@ type FrontendConfig struct {
ResponseHeaders []string
Tls *endpoints.TlsConfig
RequestsChan chan *endpoints.Request
SuperNetwork bool
}
func DefaultFrontendConfig(identityName string) *FrontendConfig {
@@ -57,6 +58,11 @@ func NewFrontend(cfg *FrontendConfig) (*Frontend, error) {
return nil, errors.Wrap(err, "error loading config")
}
zCfg.ConfigTypes = []string{sdk.ZrokProxyConfig}
if cfg.SuperNetwork {
zCfg.MaxDefaultConnections = 2
zCfg.MaxControlConnections = 1
logrus.Warnf("super networking enabled")
}
zCtx, err := ziti.NewContext(zCfg)
if err != nil {
return nil, errors.Wrap(err, "error loading ziti context")

View File

@@ -64,12 +64,11 @@ func NewHTTP(cfg *Config) (*HttpFrontend, error) {
return nil, errors.Wrap(err, "error loading ziti context")
}
zDialCtx := zitiDialContext{ctx: zCtx}
if root.Config() != nil {
if root.Config().SuperNetwork {
zCfg.MaxDefaultConnections = 2
zCfg.MaxControlConnections = 1
logrus.Warnf("super networking enabled")
}
superNetwork, _ := root.SuperNetwork()
if superNetwork {
zCfg.MaxDefaultConnections = 2
zCfg.MaxControlConnections = 1
logrus.Warnf("super networking enabled")
}
zTransport := http.DefaultTransport.(*http.Transport).Clone()
zTransport.DialContext = zDialCtx.Dial

View File

@@ -1,14 +1,15 @@
package tcpTunnel
import (
"net"
"time"
"github.com/openziti/sdk-golang/ziti"
"github.com/openziti/zrok/endpoints"
"github.com/openziti/zrok/environment"
"github.com/openziti/zrok/sdk/golang/sdk"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"net"
"time"
)
type FrontendConfig struct {
@@ -16,6 +17,7 @@ type FrontendConfig struct {
IdentityName string
ShrToken string
RequestsChan chan *endpoints.Request
SuperNetwork bool
}
type Frontend struct {
@@ -42,6 +44,12 @@ func NewFrontend(cfg *FrontendConfig) (*Frontend, error) {
return nil, errors.Wrap(err, "error loading config")
}
zCfg.ConfigTypes = []string{sdk.ZrokProxyConfig}
superNetwork, _ := env.SuperNetwork()
if superNetwork {
zCfg.MaxDefaultConnections = 2
zCfg.MaxControlConnections = 1
logrus.Warnf("super networking enabled")
}
zCtx, err := ziti.NewContext(zCfg)
if err != nil {
return nil, errors.Wrap(err, "error loading ziti context")

View File

@@ -1,15 +1,16 @@
package udpTunnel
import (
"net"
"sync"
"time"
"github.com/openziti/sdk-golang/ziti"
"github.com/openziti/zrok/endpoints"
"github.com/openziti/zrok/environment"
"github.com/openziti/zrok/sdk/golang/sdk"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"net"
"sync"
"time"
)
type FrontendConfig struct {
@@ -18,6 +19,7 @@ type FrontendConfig struct {
ShrToken string
RequestsChan chan *endpoints.Request
IdleTime time.Duration
SuperNetwork bool
}
type Frontend struct {
@@ -112,6 +114,12 @@ func NewFrontend(cfg *FrontendConfig) (*Frontend, error) {
return nil, errors.Wrap(err, "error loading config")
}
zCfg.ConfigTypes = []string{sdk.ZrokProxyConfig}
superNetwork, _ := env.SuperNetwork()
if superNetwork {
zCfg.MaxDefaultConnections = 2
zCfg.MaxControlConnections = 1
logrus.Warnf("super networking enabled")
}
zCtx, err := ziti.NewContext(zCfg)
if err != nil {
return nil, errors.Wrap(err, "error loading ziti context")

View File

@@ -2,6 +2,9 @@ package vpn
import (
"encoding/json"
"net"
"time"
"github.com/net-byte/vtun/common/config"
"github.com/net-byte/vtun/tun"
"github.com/openziti/sdk-golang/ziti"
@@ -10,14 +13,13 @@ import (
"github.com/openziti/zrok/sdk/golang/sdk"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"net"
"time"
)
type FrontendConfig struct {
IdentityName string
ShrToken string
RequestsChan chan *endpoints.Request
SuperNetwork bool
}
type Frontend struct {
@@ -40,6 +42,12 @@ func NewFrontend(cfg *FrontendConfig) (*Frontend, error) {
return nil, errors.Wrap(err, "error loading config")
}
zCfg.ConfigTypes = []string{sdk.ZrokProxyConfig}
superNetwork, _ := env.SuperNetwork()
if superNetwork {
zCfg.MaxDefaultConnections = 2
zCfg.MaxControlConnections = 1
logrus.Warnf("super networking enabled")
}
zCtx, err := ziti.NewContext(zCfg)
if err != nil {
return nil, errors.Wrap(err, "error loading ziti context")