Merge pull request #1563 from openziti/prep-for-ziti-merge-p1

Reorganize code in preparation for merging to ziti repo, first pass.
This commit is contained in:
Paul Lorenz
2023-08-04 16:35:13 -04:00
committed by GitHub
42 changed files with 45 additions and 131 deletions
+1 -1
View File
@@ -14,7 +14,7 @@
limitations under the License.
*/
package edge_common
package common
const (
EdgeBinding = "edge"
+1 -1
View File
@@ -39,13 +39,13 @@ import (
managementOperations "github.com/openziti/edge-api/rest_management_api_server/operations"
"github.com/openziti/edge-api/rest_model"
edgeConfig "github.com/openziti/edge/controller/config"
"github.com/openziti/edge/controller/events"
"github.com/openziti/edge/controller/internal/permissions"
"github.com/openziti/edge/controller/model"
"github.com/openziti/edge/controller/oidc_auth"
"github.com/openziti/edge/controller/persistence"
"github.com/openziti/edge/controller/response"
"github.com/openziti/edge/eid"
"github.com/openziti/edge/events"
"github.com/openziti/edge/internal/cert"
"github.com/openziti/edge/internal/jwtsigner"
"github.com/openziti/fabric/controller/api"
@@ -20,10 +20,10 @@ import (
"fmt"
"github.com/michaelquigley/pfxlog"
"github.com/openziti/channel/v2"
"github.com/openziti/edge/common"
"github.com/openziti/edge/controller/env"
"github.com/openziti/edge/controller/model"
"github.com/openziti/edge/controller/persistence"
"github.com/openziti/edge/edge_common"
"github.com/openziti/edge/pb/edge_ctrl_pb"
"github.com/openziti/fabric/controller/idgen"
"github.com/openziti/fabric/controller/models"
@@ -105,7 +105,7 @@ func (self *createTerminatorHandler) CreateTerminator(ctx *CreateTerminatorReque
},
Service: ctx.session.ServiceId,
Router: ctx.sourceRouter.Id,
Binding: edge_common.EdgeBinding,
Binding: common.EdgeBinding,
Address: "hosted:" + ctx.session.Token,
InstanceId: ctx.req.InstanceId,
InstanceSecret: ctx.req.InstanceSecret,
@@ -20,9 +20,9 @@ import (
"fmt"
"github.com/michaelquigley/pfxlog"
"github.com/openziti/channel/v2"
"github.com/openziti/edge/common"
"github.com/openziti/edge/controller/env"
"github.com/openziti/edge/controller/persistence"
"github.com/openziti/edge/edge_common"
"github.com/openziti/edge/pb/edge_ctrl_pb"
"github.com/openziti/fabric/controller/models"
"github.com/openziti/fabric/controller/network"
@@ -114,7 +114,7 @@ func (self *createTunnelTerminatorHandler) CreateTerminator(ctx *CreateTunnelTer
},
Service: ctx.session.ServiceId,
Router: ctx.sourceRouter.Id,
Binding: edge_common.TunnelBinding,
Binding: common.TunnelBinding,
Address: ctx.req.Address,
InstanceId: ctx.req.InstanceId,
InstanceSecret: ctx.req.InstanceSecret,
@@ -19,9 +19,9 @@ package handler_edge_ctrl
import (
"github.com/michaelquigley/pfxlog"
"github.com/openziti/channel/v2"
"github.com/openziti/edge/common"
"github.com/openziti/edge/controller/env"
"github.com/openziti/edge/controller/persistence"
"github.com/openziti/edge/edge_common"
"github.com/openziti/edge/pb/edge_ctrl_pb"
"github.com/sirupsen/logrus"
"google.golang.org/protobuf/proto"
@@ -78,7 +78,7 @@ func (self *removeTerminatorHandler) RemoveTerminator(ctx *RemoveTerminatorReque
return
}
terminator := ctx.verifyTerminator(ctx.req.TerminatorId, edge_common.EdgeBinding)
terminator := ctx.verifyTerminator(ctx.req.TerminatorId, common.EdgeBinding)
if ctx.err != nil {
self.returnError(ctx, ctx.err)
return
@@ -18,8 +18,8 @@ package handler_edge_ctrl
import (
"github.com/openziti/channel/v2"
"github.com/openziti/edge/common"
"github.com/openziti/edge/controller/env"
"github.com/openziti/edge/edge_common"
"github.com/openziti/edge/pb/edge_ctrl_pb"
"github.com/sirupsen/logrus"
)
@@ -61,7 +61,7 @@ func (self *removeTunnelTerminatorHandler) RemoveTerminator(ctx *RemoveTunnelTer
return
}
t := ctx.verifyTerminator(ctx.terminatorId, edge_common.TunnelBinding)
t := ctx.verifyTerminator(ctx.terminatorId, common.TunnelBinding)
if ctx.err != nil {
self.returnError(ctx, ctx.err)
return
@@ -18,8 +18,8 @@ package handler_edge_ctrl
import (
"github.com/openziti/channel/v2"
"github.com/openziti/edge/common"
"github.com/openziti/edge/controller/env"
"github.com/openziti/edge/edge_common"
"github.com/openziti/edge/pb/edge_ctrl_pb"
"github.com/openziti/metrics"
"time"
@@ -69,7 +69,7 @@ func (self *tunnelHealthEventHandler) handleHealthEvent(ctx *TunnelHealthEventRe
return
}
terminator := ctx.verifyTerminator(ctx.terminatorId, edge_common.TunnelBinding)
terminator := ctx.verifyTerminator(ctx.terminatorId, common.TunnelBinding)
if terminator != nil && ctx.err == nil {
if ctx.checkPassed {
self.serviceHealthCheckPassedCounter.Update(terminator.Service, time.Now(), 1)
@@ -19,9 +19,9 @@ package handler_edge_ctrl
import (
"github.com/michaelquigley/pfxlog"
"github.com/openziti/channel/v2"
"github.com/openziti/edge/common"
"github.com/openziti/edge/controller/env"
"github.com/openziti/edge/controller/persistence"
"github.com/openziti/edge/edge_common"
"github.com/openziti/edge/pb/edge_ctrl_pb"
"github.com/sirupsen/logrus"
"google.golang.org/protobuf/proto"
@@ -82,7 +82,7 @@ func (self *updateTerminatorHandler) UpdateTerminator(ctx *UpdateTerminatorReque
ctx.loadSession(ctx.req.SessionToken)
ctx.checkSessionType(persistence.SessionTypeBind)
ctx.checkSessionFingerprints(ctx.req.Fingerprints)
terminator := ctx.verifyTerminator(ctx.req.TerminatorId, edge_common.EdgeBinding)
terminator := ctx.verifyTerminator(ctx.req.TerminatorId, common.EdgeBinding)
ctx.updateTerminator(terminator, ctx.req, ctx.newChangeContext())
@@ -19,8 +19,8 @@ package handler_edge_ctrl
import (
"github.com/michaelquigley/pfxlog"
"github.com/openziti/channel/v2"
"github.com/openziti/edge/common"
"github.com/openziti/edge/controller/env"
"github.com/openziti/edge/edge_common"
"github.com/openziti/edge/pb/edge_ctrl_pb"
"github.com/sirupsen/logrus"
"google.golang.org/protobuf/proto"
@@ -76,7 +76,7 @@ func (self *updateTunnelTerminatorHandler) UpdateTerminator(ctx *UpdateTunnelTer
logrus.Debug("update request received")
terminator := ctx.verifyTerminator(ctx.req.TerminatorId, edge_common.TunnelBinding)
terminator := ctx.verifyTerminator(ctx.req.TerminatorId, common.TunnelBinding)
ctx.updateTerminator(terminator, ctx.req, ctx.newTunnelChangeContext())
if ctx.err != nil {
self.returnError(ctx, ctx.err)
@@ -19,9 +19,9 @@ package policy
import (
"fmt"
"github.com/michaelquigley/pfxlog"
"github.com/openziti/edge/common/runner"
"github.com/openziti/edge/controller/env"
"github.com/openziti/edge/controller/model"
"github.com/openziti/edge/runner"
"github.com/openziti/fabric/controller/change"
"github.com/sirupsen/logrus"
"time"
@@ -19,12 +19,12 @@ package policy
import (
"fmt"
"github.com/michaelquigley/pfxlog"
"github.com/openziti/edge/common/runner"
"github.com/openziti/fabric/controller/change"
"time"
"github.com/openziti/edge/controller/env"
"github.com/openziti/edge/controller/persistence"
"github.com/openziti/edge/runner"
"go.etcd.io/bbolt"
)
+5 -6
View File
@@ -24,7 +24,6 @@ import (
"github.com/michaelquigley/pfxlog"
"github.com/openziti/edge/controller/apierror"
"github.com/openziti/edge/controller/persistence"
"github.com/openziti/edge/crypto"
"github.com/openziti/edge/eid"
edgeCert "github.com/openziti/edge/internal/cert"
"github.com/openziti/edge/pb/edge_cmd_pb"
@@ -361,7 +360,7 @@ func (self *AuthenticatorManager) PatchSelf(authenticatorSelf *AuthenticatorSelf
}
func (self *AuthenticatorManager) HashPassword(password string) *HashedPassword {
newResult := crypto.Hash(password)
newResult := Hash(password)
b64Password := base64.StdEncoding.EncodeToString(newResult.Hash)
b64Salt := base64.StdEncoding.EncodeToString(newResult.Salt)
@@ -373,7 +372,7 @@ func (self *AuthenticatorManager) HashPassword(password string) *HashedPassword
}
func (self *AuthenticatorManager) ReHashPassword(password string, salt []byte) *HashedPassword {
newResult := crypto.ReHash(password, salt)
newResult := ReHash(password, salt)
b64Password := base64.StdEncoding.EncodeToString(newResult.Hash)
b64Salt := base64.StdEncoding.EncodeToString(newResult.Salt)
@@ -802,9 +801,9 @@ func (self *AuthenticatorManager) ProtobufToAuthenticator(msg *edge_cmd_pb.Authe
}
type HashedPassword struct {
RawResult *crypto.HashResult //raw byte hash results
Salt string //base64 encoded hash
Password string //base64 encoded hash
RawResult *HashResult //raw byte hash results
Salt string //base64 encoded hash
Password string //base64 encoded hash
}
type AuthenticatorListQueryResult struct {
+2 -2
View File
@@ -2,8 +2,8 @@ package model
import (
"github.com/michaelquigley/pfxlog"
"github.com/openziti/edge/common"
"github.com/openziti/edge/controller/persistence"
"github.com/openziti/edge/edge_common"
"github.com/openziti/edge/pb/edge_cmd_pb"
"github.com/openziti/fabric/controller/change"
"github.com/openziti/fabric/controller/command"
@@ -74,7 +74,7 @@ type terminator interface {
}
func (self *CreateEdgeTerminatorCmd) getTerminatorSession(tx *bbolt.Tx, terminator terminator, context string) (*persistence.Session, error) {
if terminator.GetBinding() != edge_common.EdgeBinding {
if terminator.GetBinding() != common.EdgeBinding {
return nil, errors.Errorf("%vterminator %v with identity %v is not edge terminator. Can't share identity", context, terminator.GetId(), terminator.GetInstanceId())
}
+1 -2
View File
@@ -21,7 +21,6 @@ import (
"errors"
"github.com/openziti/edge/controller/apierror"
"github.com/openziti/edge/controller/persistence"
"github.com/openziti/edge/crypto"
"github.com/openziti/edge/eid"
"github.com/openziti/edge/internal/cert"
"github.com/openziti/fabric/controller/change"
@@ -82,7 +81,7 @@ func (module *EnrollModuleUpdb) Process(ctx EnrollmentContext) (*EnrollmentResul
}
password = val.(string)
hash := crypto.Hash(password)
hash := Hash(password)
encodedPassword := base64.StdEncoding.EncodeToString(hash.Hash)
encodedSalt := base64.StdEncoding.EncodeToString(hash.Salt)
+1 -1
View File
@@ -14,7 +14,7 @@
limitations under the License.
*/
package crypto
package model
import (
"crypto/rand"
+3 -3
View File
@@ -19,6 +19,7 @@ package server
import (
"fmt"
"github.com/openziti/channel/v2"
runner2 "github.com/openziti/edge/common/runner"
"github.com/openziti/edge/controller/handler_edge_mgmt"
sync2 "github.com/openziti/edge/controller/sync_strats"
"github.com/openziti/edge/pb/edge_ctrl_pb"
@@ -35,7 +36,6 @@ import (
"github.com/openziti/edge/controller/handler_edge_ctrl"
_ "github.com/openziti/edge/controller/internal/routes"
"github.com/openziti/edge/controller/model"
"github.com/openziti/edge/runner"
"github.com/openziti/fabric/config"
"github.com/openziti/storage/boltz"
)
@@ -45,7 +45,7 @@ type Controller struct {
AppEnv *env.AppEnv
xmgmt *submgmt
xctrl *subctrl
policyEngine runner.Runner
policyEngine runner2.Runner
isLoaded bool
initModulesOnce sync.Once
initialized bool
@@ -78,7 +78,7 @@ func NewController(cfg config.Configurable, host env.HostController) (*Controlle
pfxlog.Logger().Infof("edge controller instance id: %s", c.AppEnv.InstanceId)
pe, err := runner.NewRunner(policyMinFreq, policyMaxFreq, func(e error, enforcer runner.Operation) {
pe, err := runner2.NewRunner(policyMinFreq, policyMaxFreq, func(e error, enforcer runner2.Operation) {
pfxlog.Logger().
WithField("cause", e).
WithField("enforcerName", enforcer.GetName()).
-84
View File
@@ -1,84 +0,0 @@
/*
Copyright NetFoundry Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package logconf
import (
"fmt"
"github.com/sirupsen/logrus"
"strings"
)
type Logging struct {
Level string `yaml:"level"`
Format string `yaml:"format"`
}
func (l *Logging) SetLoggingOptions() error {
fl := strings.TrimSpace(l.Level)
if fl == "" {
fl = "info"
}
lvl, err := logrus.ParseLevel(fl)
if err != nil {
return fmt.Errorf("invalid logging level [%s] specified", l.Level)
}
if logrus.GetLevel() != lvl && (logrus.GetLevel() == logrus.InfoLevel || logrus.GetLevel() < lvl) {
fmt.Printf("Changing log level from %v to %v\n", logrus.GetLevel(), lvl)
logrus.SetLevel(lvl)
}
fmt, err := parseFormat(l.Format)
if err != nil {
return err
}
if fmt != nil {
logrus.SetFormatter(fmt)
}
return nil
}
func parseFormat(f string) (logrus.Formatter, error) {
mf := strings.ToLower(strings.TrimSpace(f))
switch strings.ToLower(mf) {
case "":
return nil, nil
case "default":
return nil, nil
case "text":
return &logrus.TextFormatter{
DisableColors: true,
FullTimestamp: true,
}, nil
case "json":
return &logrus.JSONFormatter{}, nil
case "console":
return &logrus.TextFormatter{
ForceColors: true,
}, nil
}
return nil, fmt.Errorf("invalid log formatter [%s]", f)
}
+1 -1
View File
@@ -19,9 +19,9 @@ package fabric
import (
"github.com/michaelquigley/pfxlog"
"github.com/openziti/channel/v2"
"github.com/openziti/edge/common/runner"
"github.com/openziti/edge/controller/env"
"github.com/openziti/edge/pb/edge_ctrl_pb"
"github.com/openziti/edge/runner"
routerEnv "github.com/openziti/fabric/router/env"
"google.golang.org/protobuf/proto"
"time"
+1 -1
View File
@@ -25,9 +25,9 @@ import (
"github.com/kataras/go-events"
"github.com/michaelquigley/pfxlog"
"github.com/openziti/channel/v2"
"github.com/openziti/edge/common/runner"
"github.com/openziti/edge/controller/oidc_auth"
"github.com/openziti/edge/pb/edge_ctrl_pb"
"github.com/openziti/edge/runner"
"github.com/openziti/fabric/router/env"
cmap "github.com/orcaman/concurrent-map/v2"
"github.com/sirupsen/logrus"
+2 -2
View File
@@ -20,7 +20,7 @@ import (
"fmt"
"github.com/michaelquigley/pfxlog"
"github.com/mitchellh/mapstructure"
"github.com/openziti/edge/edge_common"
"github.com/openziti/edge/common"
"github.com/openziti/edge/pb/edge_ctrl_pb"
"github.com/openziti/fabric/router"
"github.com/openziti/identity"
@@ -241,7 +241,7 @@ func (config *Config) loadListener(rootConfigMap map[interface{}]interface{}) er
if value, found := submap["binding"]; found {
binding := value.(string)
if binding == edge_common.EdgeBinding {
if binding == common.EdgeBinding {
if value, found := submap["address"]; found {
address := value.(string)
+3 -3
View File
@@ -2,7 +2,7 @@ package xgress_edge
import (
"github.com/openziti/channel/v2"
"github.com/openziti/edge/edge_common"
"github.com/openziti/edge/common"
"github.com/openziti/fabric/router/xgress"
"github.com/stretchr/testify/require"
"testing"
@@ -113,7 +113,7 @@ const (
func newTestConfigWithConnectOptions() xgress.OptionsData {
return xgress.OptionsData{
"binding": edge_common.EdgeBinding,
"binding": common.EdgeBinding,
"address": "tls:0.0.0.0:3022",
"options": map[interface{}]interface{}{
"advertise": "127.0.0.1:3022",
@@ -126,7 +126,7 @@ func newTestConfigWithConnectOptions() xgress.OptionsData {
func newTestConfigWithoutConnectOptions() xgress.OptionsData {
return xgress.OptionsData{
"binding": edge_common.EdgeBinding,
"binding": common.EdgeBinding,
"address": "tls:0.0.0.0:3022",
"options": map[interface{}]interface{}{
"advertise": "127.0.0.1:3022",
+3 -3
View File
@@ -29,7 +29,7 @@ import (
"github.com/go-openapi/strfmt"
"github.com/google/uuid"
"github.com/openziti/edge-api/rest_model"
"github.com/openziti/edge/edge_common"
"github.com/openziti/edge/common"
"github.com/openziti/edge/eid"
"github.com/openziti/edge/router/enroll"
"github.com/openziti/edge/router/fabric"
@@ -458,10 +458,10 @@ func (ctx *TestContext) startEdgeRouter() {
stateManager := fabric.NewStateManager()
xgressEdgeFactory := xgress_edge.NewFactory(config, NewVersionProviderTest(), stateManager, ctx.router.GetMetricsRegistry())
xgress.GlobalRegistry().Register(edge_common.EdgeBinding, xgressEdgeFactory)
xgress.GlobalRegistry().Register(common.EdgeBinding, xgressEdgeFactory)
xgressEdgeTunnelFactory := xgress_edge_tunnel.NewFactory(ctx.router, config, stateManager)
xgress.GlobalRegistry().Register(edge_common.TunnelBinding, xgressEdgeTunnelFactory)
xgress.GlobalRegistry().Register(common.TunnelBinding, xgressEdgeTunnelFactory)
ctx.Req.NoError(ctx.router.RegisterXrctrl(xgressEdgeFactory))
ctx.Req.NoError(ctx.router.RegisterXrctrl(xgressEdgeTunnelFactory))
+1 -1
View File
@@ -20,7 +20,7 @@ package tests
import (
"fmt"
events2 "github.com/openziti/edge/events"
events2 "github.com/openziti/edge/controller/events"
"github.com/openziti/fabric/controller/xt_smartrouting"
"github.com/openziti/fabric/event"
"github.com/openziti/foundation/v2/stringz"
+1 -1
View File
@@ -5,8 +5,8 @@ import (
"github.com/michaelquigley/pfxlog"
"github.com/mitchellh/mapstructure"
"github.com/openziti/edge-api/rest_model"
"github.com/openziti/edge/health"
"github.com/openziti/edge/tunnel"
"github.com/openziti/edge/tunnel/health"
"github.com/openziti/edge/tunnel/utils"
"github.com/openziti/foundation/v2/genext"
"github.com/openziti/foundation/v2/stringz"
+1 -1
View File
@@ -19,9 +19,9 @@ package intercept
import (
"github.com/michaelquigley/pfxlog"
"github.com/openziti/edge-api/rest_model"
"github.com/openziti/edge/health"
"github.com/openziti/edge/tunnel"
"github.com/openziti/edge/tunnel/entities"
"github.com/openziti/edge/tunnel/health"
"github.com/openziti/edge/tunnel/router"
"github.com/openziti/edge/tunnel/utils"
"github.com/openziti/sdk-golang/ziti"
+1 -1
View File
@@ -20,10 +20,10 @@ import (
"fmt"
"github.com/michaelquigley/pfxlog"
"github.com/openziti/edge-api/rest_model"
"github.com/openziti/edge/health"
"github.com/openziti/edge/tunnel"
"github.com/openziti/edge/tunnel/dns"
"github.com/openziti/edge/tunnel/entities"
"github.com/openziti/edge/tunnel/health"
"github.com/openziti/foundation/v2/stringz"
"github.com/openziti/sdk-golang/ziti"
"github.com/pkg/errors"
+1 -1
View File
@@ -3,7 +3,7 @@ package tunnel
import (
"encoding/json"
"github.com/openziti/edge-api/rest_model"
"github.com/openziti/edge/health"
"github.com/openziti/edge/tunnel/health"
"github.com/openziti/sdk-golang/ziti"
"github.com/openziti/sdk-golang/ziti/edge"
"github.com/sirupsen/logrus"