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" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"net/url"
"os"
"os/signal"
"syscall"
"time"
tea "github.com/charmbracelet/bubbletea" tea "github.com/charmbracelet/bubbletea"
"github.com/go-openapi/runtime" "github.com/go-openapi/runtime"
httptransport "github.com/go-openapi/runtime/client" httptransport "github.com/go-openapi/runtime/client"
@@ -24,11 +30,6 @@ import (
"github.com/openziti/zrok/util" "github.com/openziti/zrok/util"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"net/url"
"os"
"os/signal"
"syscall"
"time"
) )
func init() { func init() {
@@ -111,6 +112,8 @@ func (cmd *accessPrivateCommand) run(_ *cobra.Command, args []string) {
func (cmd *accessPrivateCommand) accessLocal(args []string, root env_core.Root) { func (cmd *accessPrivateCommand) accessLocal(args []string, root env_core.Root) {
shrToken := args[0] shrToken := args[0]
superNetwork, _ := root.SuperNetwork()
zrok, err := root.Client() zrok, err := root.Client()
if err != nil { if err != nil {
cmd.error(err) cmd.error(err)
@@ -171,6 +174,7 @@ func (cmd *accessPrivateCommand) accessLocal(args []string, root env_core.Root)
IdentityName: root.EnvironmentIdentityName(), IdentityName: root.EnvironmentIdentityName(),
ShrToken: args[0], ShrToken: args[0],
RequestsChan: requests, RequestsChan: requests,
SuperNetwork: superNetwork,
}) })
if err != nil { if err != nil {
cmd.shutdown(accessResp.Payload.FrontendToken, root.Environment().ZitiIdentity, shrToken, zrok, auth) 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], ShrToken: args[0],
RequestsChan: requests, RequestsChan: requests,
IdleTime: time.Minute, IdleTime: time.Minute,
SuperNetwork: superNetwork,
}) })
if err != nil { if err != nil {
cmd.shutdown(accessResp.Payload.FrontendToken, root.Environment().ZitiIdentity, shrToken, zrok, auth) 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(), IdentityName: root.EnvironmentIdentityName(),
ShrToken: args[0], ShrToken: args[0],
RequestsChan: requests, RequestsChan: requests,
SuperNetwork: superNetwork,
}) })
if err != nil { if err != nil {
cmd.shutdown(accessResp.Payload.FrontendToken, root.Environment().ZitiIdentity, shrToken, zrok, auth) 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(), IdentityName: root.EnvironmentIdentityName(),
ShrToken: args[0], ShrToken: args[0],
RequestsChan: requests, RequestsChan: requests,
SuperNetwork: superNetwork,
}) })
if err != nil { if err != nil {
cmd.shutdown(accessResp.Payload.FrontendToken, root.Environment().ZitiIdentity, shrToken, zrok, auth) 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.Address = bindAddress
cfg.ResponseHeaders = cmd.responseHeaders cfg.ResponseHeaders = cmd.responseHeaders
cfg.RequestsChan = requests cfg.RequestsChan = requests
cfg.SuperNetwork = superNetwork
fe, err := proxy.NewFrontend(cfg) fe, err := proxy.NewFrontend(cfg)
if err != nil { if err != nil {
cmd.shutdown(accessResp.Payload.FrontendToken, root.Environment().ZitiIdentity, shrToken, zrok, auth) 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) { func (cmd *sharePrivateCommand) shareLocal(args []string, root env_core.Root) {
var target string var target string
superNetwork := false superNetwork, _ := root.SuperNetwork()
if root.Config() != nil {
superNetwork = root.Config().SuperNetwork
}
switch cmd.backendMode { switch cmd.backendMode {
case "proxy": 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) { func (cmd *sharePublicCommand) shareLocal(args []string, root env_core.Root) {
var target string var target string
superNetwork := false superNetwork, _ := root.SuperNetwork()
if root.Config() != nil {
superNetwork = root.Config().SuperNetwork
}
switch cmd.backendMode { switch cmd.backendMode {
case "proxy": case "proxy":

View File

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

View File

@@ -27,6 +27,7 @@ type FrontendConfig struct {
ResponseHeaders []string ResponseHeaders []string
Tls *endpoints.TlsConfig Tls *endpoints.TlsConfig
RequestsChan chan *endpoints.Request RequestsChan chan *endpoints.Request
SuperNetwork bool
} }
func DefaultFrontendConfig(identityName string) *FrontendConfig { func DefaultFrontendConfig(identityName string) *FrontendConfig {
@@ -57,6 +58,11 @@ func NewFrontend(cfg *FrontendConfig) (*Frontend, error) {
return nil, errors.Wrap(err, "error loading config") return nil, errors.Wrap(err, "error loading config")
} }
zCfg.ConfigTypes = []string{sdk.ZrokProxyConfig} zCfg.ConfigTypes = []string{sdk.ZrokProxyConfig}
if cfg.SuperNetwork {
zCfg.MaxDefaultConnections = 2
zCfg.MaxControlConnections = 1
logrus.Warnf("super networking enabled")
}
zCtx, err := ziti.NewContext(zCfg) zCtx, err := ziti.NewContext(zCfg)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "error loading ziti context") 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") return nil, errors.Wrap(err, "error loading ziti context")
} }
zDialCtx := zitiDialContext{ctx: zCtx} zDialCtx := zitiDialContext{ctx: zCtx}
if root.Config() != nil { superNetwork, _ := root.SuperNetwork()
if root.Config().SuperNetwork { if superNetwork {
zCfg.MaxDefaultConnections = 2 zCfg.MaxDefaultConnections = 2
zCfg.MaxControlConnections = 1 zCfg.MaxControlConnections = 1
logrus.Warnf("super networking enabled") logrus.Warnf("super networking enabled")
}
} }
zTransport := http.DefaultTransport.(*http.Transport).Clone() zTransport := http.DefaultTransport.(*http.Transport).Clone()
zTransport.DialContext = zDialCtx.Dial zTransport.DialContext = zDialCtx.Dial

View File

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

View File

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

View File

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