mirror of
https://github.com/openziti/zrok.git
synced 2025-06-20 09:48:07 +02: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/config"
|
||||||
"github.com/openziti/sdk-golang/ziti/edge"
|
"github.com/openziti/sdk-golang/ziti/edge"
|
||||||
"github.com/openziti/transport/v2/tcp"
|
"github.com/openziti/transport/v2/tcp"
|
||||||
|
"github.com/openziti/zrok/endpoints"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"net"
|
"net"
|
||||||
@ -63,6 +64,6 @@ func (b *Backend) handle(conn net.Conn) {
|
|||||||
_ = conn.Close()
|
_ = conn.Close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
go txer(conn, rConn)
|
go endpoints.TXer(conn, rConn)
|
||||||
go txer(rConn, conn)
|
go endpoints.TXer(rConn, conn)
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"github.com/openziti/sdk-golang/ziti"
|
"github.com/openziti/sdk-golang/ziti"
|
||||||
"github.com/openziti/sdk-golang/ziti/config"
|
"github.com/openziti/sdk-golang/ziti/config"
|
||||||
"github.com/openziti/transport/v2"
|
"github.com/openziti/transport/v2"
|
||||||
|
"github.com/openziti/zrok/endpoints"
|
||||||
"github.com/openziti/zrok/model"
|
"github.com/openziti/zrok/model"
|
||||||
"github.com/openziti/zrok/zrokdir"
|
"github.com/openziti/zrok/zrokdir"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@ -63,8 +64,8 @@ func (f *Frontend) Stop() {
|
|||||||
|
|
||||||
func (f *Frontend) accept(conn transport.Conn) {
|
func (f *Frontend) accept(conn transport.Conn) {
|
||||||
if zConn, err := f.zCtx.Dial(f.cfg.ShrToken); err == nil {
|
if zConn, err := f.zCtx.Dial(f.cfg.ShrToken); err == nil {
|
||||||
go txer(conn, zConn)
|
go endpoints.TXer(conn, zConn)
|
||||||
go txer(zConn, conn)
|
go endpoints.TXer(zConn, conn)
|
||||||
logrus.Infof("accepted '%v' <=> '%v'", conn.RemoteAddr(), zConn.RemoteAddr())
|
logrus.Infof("accepted '%v' <=> '%v'", conn.RemoteAddr(), zConn.RemoteAddr())
|
||||||
} else {
|
} else {
|
||||||
logrus.Errorf("error dialing '%v': %v", f.cfg.ShrToken, err)
|
logrus.Errorf("error dialing '%v': %v", f.cfg.ShrToken, err)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package tcpTunnel
|
package endpoints
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
const bufSz = 10240
|
const bufSz = 10240
|
||||||
|
|
||||||
func txer(from, to net.Conn) {
|
func TXer(from, to net.Conn) {
|
||||||
logrus.Debugf("started '%v' -> '%v'", from.RemoteAddr(), to.RemoteAddr())
|
logrus.Debugf("started '%v' -> '%v'", from.RemoteAddr(), to.RemoteAddr())
|
||||||
defer logrus.Debugf("exited '%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"
|
||||||
"github.com/openziti/sdk-golang/ziti/config"
|
"github.com/openziti/sdk-golang/ziti/config"
|
||||||
"github.com/openziti/sdk-golang/ziti/edge"
|
"github.com/openziti/sdk-golang/ziti/edge"
|
||||||
|
"github.com/openziti/zrok/endpoints"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"net"
|
"net"
|
||||||
@ -56,5 +57,18 @@ func (b *Backend) Run() error {
|
|||||||
|
|
||||||
func (b *Backend) handle(conn net.Conn) {
|
func (b *Backend) handle(conn net.Conn) {
|
||||||
logrus.Infof("handling '%v'", conn.RemoteAddr())
|
logrus.Infof("handling '%v'", conn.RemoteAddr())
|
||||||
|
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()
|
_ = conn.Close()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logrus.Errorf("error resolving '%v': %v", b.cfg.EndpointAddress, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user