mirror of
https://github.com/openziti/ziti.git
synced 2026-10-13 23:59:53 +00:00
Migrated the old 'xgress_udp' implementation into the 'xgress_transport_udp'. The latter name is more fitting, because it's basically the UDP version of 'xgress_transport'.
Migrating the components that are shared between 'xgress_proxy_udp' and 'xgress_transport_udp' into the 'xgress_udp' package. The 'xgress_udp' package will contain code that is common to connection-tracked UDP implementations. This may again change when work starts on the UDP data plane transport. (#28)
This commit is contained in:
+2
-2
@@ -31,7 +31,7 @@ import (
|
||||
"github.com/netfoundry/ziti-fabric/xgress_proxy"
|
||||
"github.com/netfoundry/ziti-fabric/xgress_proxy_udp"
|
||||
"github.com/netfoundry/ziti-fabric/xgress_transport"
|
||||
"github.com/netfoundry/ziti-fabric/xgress_udp"
|
||||
"github.com/netfoundry/ziti-fabric/xgress_transport_udp"
|
||||
"github.com/netfoundry/ziti-foundation/channel2"
|
||||
"github.com/netfoundry/ziti-foundation/profiler"
|
||||
"github.com/netfoundry/ziti-foundation/util/info"
|
||||
@@ -131,7 +131,7 @@ func (router *Router) registerComponents() error {
|
||||
xgress.GlobalRegistry().Register("proxy", xgress_proxy.NewFactory(router.config.Id, router))
|
||||
xgress.GlobalRegistry().Register("proxy_udp", xgress_proxy_udp.NewFactory(router))
|
||||
xgress.GlobalRegistry().Register("transport", xgress_transport.NewFactory(router.config.Id, router))
|
||||
xgress.GlobalRegistry().Register("udp", xgress_udp.NewFactory(router.config.Id, router))
|
||||
xgress.GlobalRegistry().Register("udp", xgress_transport_udp.NewFactory(router.config.Id, router))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package xgress_udp
|
||||
package xgress_transport_udp
|
||||
|
||||
import (
|
||||
"github.com/netfoundry/ziti-foundation/transport/udp"
|
||||
@@ -14,12 +14,13 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package xgress_udp
|
||||
package xgress_transport_udp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/netfoundry/ziti-fabric/xgress"
|
||||
"github.com/netfoundry/ziti-fabric/xgress_udp"
|
||||
"github.com/netfoundry/ziti-foundation/identity/identity"
|
||||
"net"
|
||||
)
|
||||
@@ -41,7 +42,7 @@ func newDialer(id *identity.TokenId, ctrl xgress.CtrlChannel, options *xgress.Op
|
||||
|
||||
func (txd *dialer) Dial(destination string, sessionId *identity.TokenId, address xgress.Address, bindHandler xgress.BindHandler) error {
|
||||
pfxlog.Logger().Infof("Parsing %v for xgress address: %v", destination, address)
|
||||
packetAddress, err := parseAddress(destination)
|
||||
packetAddress, err := xgress_udp.Parse(destination)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot dial on invalid address [%s] (%s)", destination, err)
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package xgress_udp
|
||||
package xgress_transport_udp
|
||||
|
||||
import (
|
||||
"github.com/netfoundry/ziti-fabric/xgress"
|
||||
@@ -14,12 +14,13 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package xgress_udp
|
||||
package xgress_transport_udp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/netfoundry/ziti-fabric/xgress"
|
||||
"github.com/netfoundry/ziti-fabric/xgress_udp"
|
||||
"github.com/netfoundry/ziti-foundation/identity/identity"
|
||||
"github.com/netfoundry/ziti-foundation/transport/udp"
|
||||
"io"
|
||||
@@ -59,7 +60,7 @@ func (listener *listener) Listen(address string, bindHandler xgress.BindHandler)
|
||||
listener.bindHandler = bindHandler
|
||||
|
||||
pfxlog.Logger().Infof("parsing xgress address: %v", address)
|
||||
packetAddress, err := parseAddress(address)
|
||||
packetAddress, err := xgress_udp.Parse(address)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot listen on invalid address [%s] (%s)", address, err)
|
||||
}
|
||||
+20
-21
@@ -17,7 +17,6 @@
|
||||
package xgress_udp
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
@@ -29,27 +28,10 @@ var supportedNetworks = map[string]string{
|
||||
"unixgram": "",
|
||||
}
|
||||
|
||||
type packetAddress struct {
|
||||
network string
|
||||
address string
|
||||
}
|
||||
|
||||
func (pa *packetAddress) String() string {
|
||||
return fmt.Sprintf("packetAddress{network=%v, addr=%v}", pa.network, pa.address)
|
||||
}
|
||||
|
||||
func (pa *packetAddress) Network() string {
|
||||
return pa.network
|
||||
}
|
||||
|
||||
func (pa *packetAddress) Address() string {
|
||||
return pa.address
|
||||
}
|
||||
|
||||
func parseAddress(s string) (*packetAddress, error) {
|
||||
func Parse(s string) (*PacketAddress, error) {
|
||||
tokens := strings.Split(s, ":")
|
||||
if len(tokens) < 2 {
|
||||
return nil, errors.New("invalid format")
|
||||
return nil, fmt.Errorf("invalid format")
|
||||
}
|
||||
|
||||
network := tokens[0]
|
||||
@@ -60,5 +42,22 @@ func parseAddress(s string) (*packetAddress, error) {
|
||||
|
||||
address := strings.Join(tokens[1:], ":")
|
||||
|
||||
return &packetAddress{network, address}, nil
|
||||
return &PacketAddress{network, address}, nil
|
||||
}
|
||||
|
||||
func (pa *PacketAddress) String() string {
|
||||
return fmt.Sprintf("PacketAddress{network=[%v], addr=[%v]}", pa.network, pa.address)
|
||||
}
|
||||
|
||||
func (pa *PacketAddress) Network() string {
|
||||
return pa.network
|
||||
}
|
||||
|
||||
func (pa *PacketAddress) Address() string {
|
||||
return pa.address
|
||||
}
|
||||
|
||||
type PacketAddress struct {
|
||||
network string
|
||||
address string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user