mirror of
https://github.com/openziti/ziti.git
synced 2026-10-13 15:51:21 +00:00
final rebase from tproxy config
This commit is contained in:
@@ -35,8 +35,9 @@ link:
|
||||
{{ if .Router.IsFabric }}#{{ end }} getSessionTimeout: {{ .Router.Listener.GetSessionTimeout.Seconds }}s
|
||||
{{ if .Router.IsFabric }}#{{ end }}{{ if .Router.TunnelerDisabled }}#{{ end }} - binding: tunnel
|
||||
{{ if .Router.IsFabric }}#{{ end }}{{ if .Router.TunnelerDisabled }}#{{ end }} options:
|
||||
{{ if .Router.IsFabric }}#{{ end }}{{ if .Router.TunnelerDisabled }}#{{ end }} mode: host #tproxy|host
|
||||
|
||||
{{ if .Router.IsFabric }}#{{ end }}{{ if .Router.TunnelerDisabled }}#{{ end }}{{ if .Router.Tproxy }}#{{ end }} mode: host
|
||||
{{ if .Router.IsFabric }}#{{ end }}{{ if .Router.TunnelerDisabled }}#{{ end }}{{ if .Router.Tproxy }} resolver: udp://{{ .Router.Edge.AdvertisedHost }}:53{{ else }}#{{ end }}
|
||||
{{ if .Router.IsFabric }}#{{ end }}{{ if .Router.TunnelerDisabled }}#{{ end }}{{ if .Router.Tproxy }} lanIf: {{ .Router.Edge.LanInterface }}{{ else }}#{{ end }}
|
||||
{{ if or .Router.IsFabric }}
|
||||
csr:
|
||||
country: US
|
||||
@@ -86,4 +87,5 @@ forwarder:
|
||||
xgressDialQueueLength: {{ .Router.Forwarder.XgressDialQueueLength }}
|
||||
xgressDialWorkerCount: {{ .Router.Forwarder.XgressDialWorkerCount }}
|
||||
linkDialQueueLength: {{ .Router.Forwarder.LinkDialQueueLength }}
|
||||
linkDialWorkerCount: {{ .Router.Forwarder.LinkDialWorkerCount }}
|
||||
linkDialWorkerCount: {{ .Router.Forwarder.LinkDialWorkerCount }}
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/openziti/channel/v2"
|
||||
edge "github.com/openziti/edge/controller/config"
|
||||
fabCtrl "github.com/openziti/fabric/controller"
|
||||
@@ -28,8 +31,6 @@ import (
|
||||
"github.com/openziti/ziti/ziti/cmd/ziti/constants"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -120,6 +121,7 @@ type RouterTemplateValues struct {
|
||||
IsFabric bool
|
||||
IsWss bool
|
||||
TunnelerDisabled bool
|
||||
Tproxy bool
|
||||
IdentityCert string
|
||||
IdentityServerCert string
|
||||
IdentityKey string
|
||||
@@ -135,6 +137,7 @@ type EdgeRouterTemplateValues struct {
|
||||
Port string
|
||||
IPOverride string
|
||||
AdvertisedHost string
|
||||
LanInterface string
|
||||
}
|
||||
|
||||
type WSSRouterTemplateValues struct {
|
||||
|
||||
@@ -19,17 +19,18 @@ package cmd
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers"
|
||||
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates"
|
||||
"github.com/openziti/ziti/ziti/cmd/ziti/constants"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
type EnvVariableTemplateData struct {
|
||||
@@ -112,6 +113,8 @@ func NewCmdCreateConfigEnvironment() *cobra.Command {
|
||||
{constants.ZitiRouterIdentityKeyVarName, constants.ZitiRouterIdentityKeyVarDescription, data.Router.IdentityKey},
|
||||
{constants.ZitiRouterIdentityCAVarName, constants.ZitiRouterIdentityCAVarDescription, data.Router.IdentityCA},
|
||||
{constants.ZitiEdgeRouterIPOverrideVarName, constants.ZitiEdgeRouterIPOverrideVarDescription, data.Router.Edge.IPOverride},
|
||||
{constants.ZitiRouterAdvertisedHostVarName, constants.ZitiRouterAdvertisedHostVarDescription, data.Router.Edge.AdvertisedHost},
|
||||
{constants.ZitiEdgeRouterLanInterfaceVarName, constants.ZitiEdgeRouterLanInterfaceVarDescription, data.Router.Edge.LanInterface},
|
||||
{constants.ZitiCtrlListenerAddressVarName, constants.ZitiCtrlListenerAddressVarDescription, data.Controller.ListenerAddress},
|
||||
{constants.ZitiCtrlAdvertisedAddressVarName, constants.ZitiCtrlAdvertisedAddressVarDescription, data.Controller.AdvertisedAddress},
|
||||
{constants.ZitiEdgeCtrlListenerHostPortVarName, constants.ZitiEdgeCtrlListenerHostPortVarDescription, data.Controller.Edge.ListenerHostPort},
|
||||
@@ -183,6 +186,7 @@ func NewCmdCreateConfigEnvironment() *cobra.Command {
|
||||
"%-40s %-50s %s\n"+
|
||||
"%-40s %-50s %s\n"+
|
||||
"%-40s %-50s %s\n"+
|
||||
"%-40s %-50s %s\n"+
|
||||
"%-40s %-50s %s",
|
||||
constants.ZitiHomeVarName, constants.ZitiHomeVarDescription, data.ZitiHome,
|
||||
constants.ZitiCtrlPortVarName, constants.ZitiCtrlPortVarDescription, data.Controller.Port,
|
||||
@@ -200,6 +204,7 @@ func NewCmdCreateConfigEnvironment() *cobra.Command {
|
||||
constants.ZitiRouterIdentityCAVarName, constants.ZitiRouterIdentityCAVarDescription, data.Router.IdentityCA,
|
||||
constants.ZitiEdgeRouterIPOverrideVarName, constants.ZitiEdgeRouterIPOverrideVarDescription, data.Router.Edge.IPOverride,
|
||||
constants.ZitiRouterAdvertisedHostVarName, constants.ZitiRouterAdvertisedHostVarDescription, data.Router.Edge.AdvertisedHost,
|
||||
constants.ZitiEdgeRouterLanInterfaceVarName, constants.ZitiEdgeRouterLanInterfaceVarDescription, data.Router.Edge.LanInterface,
|
||||
constants.ZitiCtrlIdentityCertVarName, constants.ZitiCtrlIdentityCertVarDescription, data.Controller.IdentityCert,
|
||||
constants.ZitiCtrlIdentityServerCertVarName, constants.ZitiCtrlIdentityServerCertVarDescription, data.Controller.IdentityServerCert,
|
||||
constants.ZitiCtrlIdentityKeyVarName, constants.ZitiCtrlIdentityKeyVarDescription, data.Controller.IdentityKey,
|
||||
|
||||
@@ -18,11 +18,12 @@ package cmd
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -37,6 +38,7 @@ type CreateConfigRouterOptions struct {
|
||||
WssEnabled bool
|
||||
IsPrivate bool
|
||||
TunnelerDisabled bool
|
||||
Tproxy bool
|
||||
}
|
||||
|
||||
var routerOptions = CreateConfigRouterOptions{}
|
||||
|
||||
@@ -18,10 +18,11 @@ package cmd
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers"
|
||||
"github.com/openziti/ziti/ziti/cmd/ziti/constants"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers"
|
||||
"github.com/openziti/ziti/ziti/cmd/ziti/constants"
|
||||
)
|
||||
|
||||
func SetZitiRouterIdentity(r *RouterTemplateValues, routerName string) {
|
||||
@@ -36,6 +37,12 @@ func SetZitiRouterIdentity(r *RouterTemplateValues, routerName string) {
|
||||
r.Edge.IPOverride = edgeRouterIPOverride
|
||||
}
|
||||
|
||||
// Egde Router Lan Interface
|
||||
edgeRouterLanInterface := os.Getenv(constants.ZitiEdgeRouterLanInterfaceVarName)
|
||||
if edgeRouterLanInterface != "" {
|
||||
r.Edge.LanInterface = edgeRouterLanInterface
|
||||
}
|
||||
|
||||
externalDNS := os.Getenv(constants.ExternalDNSVarName)
|
||||
edgeRouterRawName := os.Getenv(constants.ZitiEdgeRouterRawNameVarName)
|
||||
if externalDNS != "" {
|
||||
|
||||
@@ -18,15 +18,16 @@ package cmd
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers"
|
||||
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/templates"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -65,6 +66,7 @@ func NewCmdCreateConfigRouterEdge() *cobra.Command {
|
||||
data.Router.IsWss = routerOptions.WssEnabled
|
||||
data.Router.IsPrivate = routerOptions.IsPrivate
|
||||
data.Router.TunnelerDisabled = routerOptions.TunnelerDisabled
|
||||
data.Router.Tproxy = routerOptions.Tproxy
|
||||
},
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
routerOptions.Cmd = cmd
|
||||
@@ -84,6 +86,7 @@ func (options *CreateConfigRouterOptions) addEdgeFlags(cmd *cobra.Command) {
|
||||
cmd.Flags().BoolVar(&options.WssEnabled, optionWSS, defaultWSS, wssDescription)
|
||||
cmd.Flags().BoolVar(&options.IsPrivate, optionPrivate, defaultPrivate, privateDescription)
|
||||
cmd.PersistentFlags().BoolVarP(&options.TunnelerDisabled, "disableTunneler", "t", false, "whether the router has tunneling disabled")
|
||||
cmd.PersistentFlags().BoolVarP(&options.Tproxy, "Tproxy", "x", false, "enable tproxy if disableTunneler")
|
||||
cmd.PersistentFlags().StringVarP(&options.RouterName, optionRouterName, "n", "", "name of the router")
|
||||
err := cmd.MarkPersistentFlagRequired(optionRouterName)
|
||||
if err != nil {
|
||||
@@ -98,6 +101,11 @@ func (options *CreateConfigRouterOptions) runEdgeRouter(data *ConfigTemplateValu
|
||||
return errors.New("Flags for private and wss configs are mutually exclusive. You must choose private or wss, not both")
|
||||
}
|
||||
|
||||
// Ensure disableTunneler and Tproxy are not both used
|
||||
if options.TunnelerDisabled && options.Tproxy {
|
||||
return errors.New("Flags for TunnelerDisabled and Tproxy are mutually exclusive. You must choose one, but not both")
|
||||
}
|
||||
|
||||
tmpl, err := template.New("edge-router-config").Parse(routerConfigEdgeTemplate)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -107,4 +107,6 @@ const (
|
||||
ZitiEdgeRouterIPOverrideVarDescription = "Override the default edge router IP with a custom IP, this IP will also be added to the PKI"
|
||||
ZitiRouterAdvertisedHostVarName = "ZITI_ROUTER_ADVERTISED_HOST"
|
||||
ZitiRouterAdvertisedHostVarDescription = "The advertised host of the router"
|
||||
ZitiEdgeRouterLanInterfaceVarName = "ZITI_EDGE_ROUTER_LAN_INTERFACE"
|
||||
ZitiEdgeRouterLanInterfaceVarDescription = "The inteface on host of the router to insert iptables ingress filter rules"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user