mirror of
https://github.com/openziti/zrok.git
synced 2025-08-17 19:31:12 +02:00
moar super network (#1010)
This commit is contained in:
@@ -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)
|
||||
|
@@ -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":
|
||||
|
@@ -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":
|
||||
|
@@ -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 {
|
||||
|
@@ -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")
|
||||
|
@@ -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
|
||||
|
@@ -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")
|
||||
|
@@ -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")
|
||||
|
@@ -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")
|
||||
|
Reference in New Issue
Block a user