I don't think i understand what you mean.
I havent zitified the server. server is livekit behind ziti.
I am trying to zitify end-user app(uses pion/webrtc
), because end-user app needs to connect to ziti so it can access the server.
If i understand it correctly, end-user app needs to be able to send and receive udp data. i forked relevant pion repos. currently it gets stuck on ice state connecting
from the livekit and end-user app gets stuck at ice state checking
.
The relevant debug code:
type zitiPacketConn struct {
zitiNet net.Conn
net net.PacketConn
network string
}
func (z *zitiPacketConn) ReadFrom(b []byte) (int, net.Addr, error) {
// Read data from the Ziti connection
var t []byte
s, err := z.zitiNet.Read(t)
if err != nil {
return 0, nil, err
}
z.zitiNet.SetDeadline(time.Now().Add(5 * time.Second))
log.Print("PACKEEEEEEEEEEEEET ", string(t), " ", string(s))
// Addressing is abstract in Ziti, so return a dummy address
// return n, &net.UDPAddr{IP: net.IPv4zero, Port: 0}, nil
n, addr, err := z.net.ReadFrom(b)
log.Print("OLDPACKEEEEEEEEEEEET ", string(b), " ", string(n))
return n, addr, err
}
func (z *zitiPacketConn) WriteTo(b []byte, addr net.Addr) (int, error) {
// Write data to the Ziti connection
log.Print("WRIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIITE TO ", addr)
fallback := &openziti.FallbackDialer{
UnderlayDialer: &net.Dialer{},
}
dialer := openziti.ZitiContexts.NewDialerWithFallback(context.Background(), fallback)
// Dial the Ziti service
log.Print("ooooooooooooooooooooo ", addr.String())
conn, err := dialer.Dial(z.network, addr.String())
if err != nil {
return 0, err
}
i, err := conn.Write(b)
if err != nil {
log.Print(err)
}
i, err = z.net.WriteTo(b, addr)
return i, err
}
func (z *zitiPacketConn) Close() error {
// Close the Ziti session
return z.zitiNet.Close()
}
func (z *zitiPacketConn) LocalAddr() net.Addr {
// Return a placeholder address; Ziti abstracts this
return &net.UDPAddr{IP: net.IPv4zero, Port: 0}
}
func (z *zitiPacketConn) SetDeadline(t time.Time) error {
return z.zitiNet.SetDeadline(t)
}
func (z *zitiPacketConn) SetReadDeadline(t time.Time) error {
return z.zitiNet.SetReadDeadline(t)
}
func (z *zitiPacketConn) SetWriteDeadline(t time.Time) error {
return z.zitiNet.SetWriteDeadline(t)
}
// ListenPacket announces on the local network address.
func (n *Net) ListenPacket(network string, address string) (net.PacketConn, error) {
fallback := &openziti.FallbackDialer{
UnderlayDialer: &net.Dialer{},
}
dialer := openziti.ZitiContexts.NewDialerWithFallback(context.Background(), fallback)
// Dial the Ziti service
log.Print("iiiiiiiiiiiiiiiii ", address, network)
conn, err := dialer.Dial(network, "12.34.56.78:3478")
if err != nil {
return nil, err
}
log.Print("4444444444444444")
ne, err := net.ListenPacket(network, address)
if err != nil {
return nil, err
}
return &zitiPacketConn{zitiNet: conn, net: ne, network: network}, nil
// return net.ListenPacket(network, address)
}
If i turn on my local ziti tunnel and try to run the end-user app, ReadFrom OLDPACKEEEEEEEEEEEET
gets data. If i turn off local ziti tunnel neither OLDPACKEEEEEEEEEEEET
or the PACKEEEEEEEEEEEEET
gets any data.
Questions:
in WriteTo(
:
i, err := conn.Write(b)
if err != nil {
log.Print(err)
}
i, err = z.net.WriteTo(b, addr)
Do nets WriteTo
and zitis Write
, behave the same way in this context?
Same question about zitis read
and nets ReadFrom