mirror of
https://github.com/openziti/zrok.git
synced 2024-11-07 08:44:14 +01:00
roughed in udpTunnel.Backend (#306)
This commit is contained in:
parent
12fad0d74c
commit
a4684328b6
@ -5,6 +5,7 @@ import (
|
||||
"github.com/openziti/sdk-golang/ziti/config"
|
||||
"github.com/openziti/sdk-golang/ziti/edge"
|
||||
"github.com/openziti/transport/v2/tcp"
|
||||
"github.com/openziti/zrok/endpoints"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"net"
|
||||
@ -63,6 +64,6 @@ func (b *Backend) handle(conn net.Conn) {
|
||||
_ = conn.Close()
|
||||
return
|
||||
}
|
||||
go txer(conn, rConn)
|
||||
go txer(rConn, conn)
|
||||
go endpoints.TXer(conn, rConn)
|
||||
go endpoints.TXer(rConn, conn)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"github.com/openziti/sdk-golang/ziti"
|
||||
"github.com/openziti/sdk-golang/ziti/config"
|
||||
"github.com/openziti/transport/v2"
|
||||
"github.com/openziti/zrok/endpoints"
|
||||
"github.com/openziti/zrok/model"
|
||||
"github.com/openziti/zrok/zrokdir"
|
||||
"github.com/pkg/errors"
|
||||
@ -63,8 +64,8 @@ func (f *Frontend) Stop() {
|
||||
|
||||
func (f *Frontend) accept(conn transport.Conn) {
|
||||
if zConn, err := f.zCtx.Dial(f.cfg.ShrToken); err == nil {
|
||||
go txer(conn, zConn)
|
||||
go txer(zConn, conn)
|
||||
go endpoints.TXer(conn, zConn)
|
||||
go endpoints.TXer(zConn, conn)
|
||||
logrus.Infof("accepted '%v' <=> '%v'", conn.RemoteAddr(), zConn.RemoteAddr())
|
||||
} else {
|
||||
logrus.Errorf("error dialing '%v': %v", f.cfg.ShrToken, err)
|
||||
|
@ -1,4 +1,4 @@
|
||||
package tcpTunnel
|
||||
package endpoints
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
@ -8,7 +8,7 @@ import (
|
||||
|
||||
const bufSz = 10240
|
||||
|
||||
func txer(from, to net.Conn) {
|
||||
func TXer(from, to net.Conn) {
|
||||
logrus.Debugf("started '%v' -> '%v'", from.RemoteAddr(), to.RemoteAddr())
|
||||
defer logrus.Debugf("exited '%v' -> '%v'", from.RemoteAddr(), to.RemoteAddr())
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"github.com/openziti/sdk-golang/ziti"
|
||||
"github.com/openziti/sdk-golang/ziti/config"
|
||||
"github.com/openziti/sdk-golang/ziti/edge"
|
||||
"github.com/openziti/zrok/endpoints"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"net"
|
||||
@ -56,5 +57,18 @@ func (b *Backend) Run() error {
|
||||
|
||||
func (b *Backend) handle(conn net.Conn) {
|
||||
logrus.Infof("handling '%v'", conn.RemoteAddr())
|
||||
_ = conn.Close()
|
||||
defer logrus.Infof("completed '%v'", conn.RemoteAddr())
|
||||
|
||||
if rAddr, err := net.ResolveUDPAddr("udp", b.cfg.EndpointAddress); err == nil {
|
||||
if rConn, err := net.DialUDP("udp", nil, rAddr); err == nil {
|
||||
go endpoints.TXer(conn, rConn)
|
||||
go endpoints.TXer(rConn, conn)
|
||||
} else {
|
||||
logrus.Errorf("error dialing '%v': %v", rAddr, err)
|
||||
_ = conn.Close()
|
||||
return
|
||||
}
|
||||
} else {
|
||||
logrus.Errorf("error resolving '%v': %v", b.cfg.EndpointAddress, err)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user