mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 05:57:03 +09:00
quic.ListenAddrs returns addrs
This commit is contained in:
parent
eeea38bf2a
commit
5f2f7daa35
1 changed files with 6 additions and 4 deletions
|
@ -27,7 +27,7 @@ func New() Quic {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Quic interface {
|
type Quic interface {
|
||||||
ListenAddrs(ctx context.Context, addrs ...string) (err error)
|
ListenAddrs(ctx context.Context, addrs ...string) (listenAddrs []net.Addr, err error)
|
||||||
transport.Transport
|
transport.Transport
|
||||||
app.ComponentRunnable
|
app.ComponentRunnable
|
||||||
}
|
}
|
||||||
|
@ -74,10 +74,11 @@ func (q *quicTransport) Run(ctx context.Context) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
q.listCtx, q.listCtxCancel = context.WithCancel(context.Background())
|
q.listCtx, q.listCtxCancel = context.WithCancel(context.Background())
|
||||||
return q.ListenAddrs(ctx, q.conf.ListenAddrs...)
|
_, err = q.ListenAddrs(ctx, q.conf.ListenAddrs...)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *quicTransport) ListenAddrs(ctx context.Context, addrs ...string) (err error) {
|
func (q *quicTransport) ListenAddrs(ctx context.Context, addrs ...string) (listenAddrs []net.Addr, err error) {
|
||||||
q.mu.Lock()
|
q.mu.Lock()
|
||||||
defer q.mu.Unlock()
|
defer q.mu.Unlock()
|
||||||
var tlsConf tls.Config
|
var tlsConf tls.Config
|
||||||
|
@ -93,8 +94,9 @@ func (q *quicTransport) ListenAddrs(ctx context.Context, addrs ...string) (err e
|
||||||
for _, listAddr := range addrs {
|
for _, listAddr := range addrs {
|
||||||
list, err := quic.ListenAddr(listAddr, &tlsConf, q.quicConf)
|
list, err := quic.ListenAddr(listAddr, &tlsConf, q.quicConf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
listenAddrs = append(listenAddrs, list.Addr())
|
||||||
q.listeners = append(q.listeners, list)
|
q.listeners = append(q.listeners, list)
|
||||||
go q.acceptLoop(q.listCtx, list)
|
go q.acceptLoop(q.listCtx, list)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue