mirror of
https://github.com/openziti/ziti.git
synced 2026-10-12 23:32:02 +00:00
Tweaks, getting listener working for transwarp transport. (#44)
This commit is contained in:
@@ -29,12 +29,12 @@ func (self address) Dial(name string, _ *identity.TokenId) (transport.Connection
|
||||
return Dial(self.bindableAddress(), name)
|
||||
}
|
||||
|
||||
func (self address) Listen(_ string, _ *identity.TokenId, _ chan transport.Connection) (io.Closer, error) {
|
||||
return Listen(self.bindableAddress())
|
||||
func (self address) Listen(name string, _ *identity.TokenId, incoming chan transport.Connection) (io.Closer, error) {
|
||||
return Listen(self.bindableAddress(), name, incoming)
|
||||
}
|
||||
|
||||
func (self address) MustListen(name string, _ *identity.TokenId, _ chan transport.Connection) io.Closer {
|
||||
closer, err := self.Listen(name, nil, nil)
|
||||
func (self address) MustListen(name string, _ *identity.TokenId, incoming chan transport.Connection) io.Closer {
|
||||
closer, err := self.Listen(name, nil, incoming)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot listen (%w)", err))
|
||||
}
|
||||
|
||||
@@ -18,11 +18,12 @@ package transwarp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/netfoundry/ziti-foundation/transport"
|
||||
"io"
|
||||
"net"
|
||||
)
|
||||
|
||||
func Listen(bindAddress string) (io.Closer, error) {
|
||||
func Listen(bindAddress, name string, incoming chan transport.Connection) (io.Closer, error) {
|
||||
listenAddress, err := net.ResolveUDPAddr("udp", bindAddress)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error resolving bind address (%w)", err)
|
||||
@@ -33,5 +34,11 @@ func Listen(bindAddress string) (io.Closer, error) {
|
||||
return nil, fmt.Errorf("error listening (%w)", err)
|
||||
}
|
||||
|
||||
incoming <- newConnection(&transport.ConnectionDetail{
|
||||
Address: "transwarp" + bindAddress,
|
||||
InBound: true,
|
||||
Name: name,
|
||||
}, socket)
|
||||
|
||||
return socket, nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user