chore: log server address on connect, log realm peer address candidates
This commit is contained in:
parent
c1868d5c14
commit
97a341690a
6 changed files with 15 additions and 7 deletions
|
|
@ -640,7 +640,7 @@ func (c *clientConfig) realmConfig(addr *realm.Addr) (*client.Config, error) {
|
|||
logger.Debug("realm client connect request started",
|
||||
zap.String("realm", addr.RealmID),
|
||||
zap.String("attempt", attempt),
|
||||
zap.Int("addresses", len(localAddrs)))
|
||||
zap.Strings("addresses", addrPortStrings(localAddrs)))
|
||||
connectStart := time.Now()
|
||||
connectResp, err := rClient.Connect(ctx, addr.RealmID, realm.ConnectRequest{
|
||||
Addresses: addrPortStrings(localAddrs),
|
||||
|
|
@ -652,7 +652,7 @@ func (c *clientConfig) realmConfig(addr *realm.Addr) (*client.Config, error) {
|
|||
logger.Debug("realm client connect response received",
|
||||
zap.String("realm", addr.RealmID),
|
||||
zap.String("attempt", attempt),
|
||||
zap.Int("serverAddresses", len(connectResp.Addresses)),
|
||||
zap.Strings("serverAddresses", connectResp.Addresses),
|
||||
zap.String("duration", formatLogDuration(time.Since(connectStart))))
|
||||
peerAddrs, err := parseAddrPorts(connectResp.Addresses)
|
||||
if err != nil {
|
||||
|
|
@ -661,7 +661,7 @@ func (c *clientConfig) realmConfig(addr *realm.Addr) (*client.Config, error) {
|
|||
logger.Debug("realm client punch started",
|
||||
zap.String("realm", addr.RealmID),
|
||||
zap.String("attempt", attempt),
|
||||
zap.Int("candidates", len(peerAddrs)))
|
||||
zap.Strings("candidates", connectResp.Addresses))
|
||||
punchStart := time.Now()
|
||||
result, err := realm.Punch(ctx, baseConn, localAddrs, peerAddrs, connectResp.PunchMetadata, realm.PunchConfig{
|
||||
Timeout: c.Realm.PunchTimeout,
|
||||
|
|
@ -1220,6 +1220,7 @@ func formatLogDuration(d time.Duration) string {
|
|||
|
||||
func connectLog(info *client.HandshakeInfo, count int) {
|
||||
logger.Info("connected to server",
|
||||
zap.String("addr", info.ServerAddr.String()),
|
||||
zap.Bool("udpEnabled", info.UDPEnabled),
|
||||
zap.Uint64("tx", info.Tx),
|
||||
zap.Int("count", count))
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ func runPing(v *viper.Viper, addr string) {
|
|||
}
|
||||
defer c.Close()
|
||||
logger.Info("connected to server",
|
||||
zap.String("addr", info.ServerAddr.String()),
|
||||
zap.Bool("udpEnabled", info.UDPEnabled),
|
||||
zap.Uint64("tx", info.Tx))
|
||||
|
||||
|
|
|
|||
|
|
@ -546,7 +546,7 @@ func (r *realmServerRuntime) register(ctx context.Context) (realmSession, error)
|
|||
localAddrs := r.currentAddrs()
|
||||
logger.Debug("realm registration started",
|
||||
zap.String("realm", r.realmID),
|
||||
zap.Int("addresses", len(localAddrs)))
|
||||
zap.Strings("addresses", addrPortStrings(localAddrs)))
|
||||
start := time.Now()
|
||||
registerResp, err := r.client.Register(ctx, r.realmID, addrPortStrings(localAddrs))
|
||||
if err != nil {
|
||||
|
|
@ -559,7 +559,7 @@ func (r *realmServerRuntime) register(ctx context.Context) (realmSession, error)
|
|||
zap.String("duration", formatLogDuration(time.Since(start))))
|
||||
logger.Info("realm registered",
|
||||
zap.String("realm", r.realmID),
|
||||
zap.Int("addresses", len(localAddrs)),
|
||||
zap.Strings("addresses", addrPortStrings(localAddrs)),
|
||||
zap.Int("ttl", sess.ttl))
|
||||
return sess, nil
|
||||
}
|
||||
|
|
@ -674,7 +674,7 @@ func (r *realmServerRuntime) eventsLoop(ctx context.Context, sess realmSession)
|
|||
logger.Debug("realm punch event received",
|
||||
zap.String("realm", r.realmID),
|
||||
zap.String("attempt", shortAttempt(ev.Nonce)),
|
||||
zap.Int("addresses", len(ev.Addresses)))
|
||||
zap.Strings("addresses", ev.Addresses))
|
||||
go r.respond(ctx, ev)
|
||||
}
|
||||
}
|
||||
|
|
@ -743,7 +743,7 @@ func (r *realmServerRuntime) respond(ctx context.Context, ev *realm.PunchEvent)
|
|||
logger.Debug("realm punch response started",
|
||||
zap.String("realm", r.realmID),
|
||||
zap.String("attempt", attempt),
|
||||
zap.Int("candidates", len(peerAddrs)))
|
||||
zap.Strings("candidates", ev.Addresses))
|
||||
start := time.Now()
|
||||
result, err := r.puncher.Respond(ctx, ev.Nonce, freshAddrs, peerAddrs, ev.PunchMetadata, realm.PunchConfig{
|
||||
Timeout: r.config.PunchTimeout,
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ func runSpeedtest(v *viper.Viper, sizeBased bool) {
|
|||
}
|
||||
defer c.Close()
|
||||
logger.Info("connected to server",
|
||||
zap.String("addr", info.ServerAddr.String()),
|
||||
zap.Bool("udpEnabled", info.UDPEnabled),
|
||||
zap.Uint64("tx", info.Tx))
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ type HyUDPConn interface {
|
|||
type HandshakeInfo struct {
|
||||
UDPEnabled bool
|
||||
Tx uint64 // 0 if using BBR
|
||||
ServerAddr net.Addr
|
||||
}
|
||||
|
||||
func NewClient(config *Config) (Client, *HandshakeInfo, error) {
|
||||
|
|
@ -166,6 +167,7 @@ func (c *clientImpl) connect() (*HandshakeInfo, error) {
|
|||
return &HandshakeInfo{
|
||||
UDPEnabled: authResp.UDPEnabled,
|
||||
Tx: actualTx,
|
||||
ServerAddr: c.config.ServerAddr,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -209,6 +209,7 @@ func TestClientServerHandshakeInfo(t *testing.T) {
|
|||
assert.Equal(t, &client.HandshakeInfo{
|
||||
UDPEnabled: true,
|
||||
Tx: 123456,
|
||||
ServerAddr: udpAddr,
|
||||
}, info)
|
||||
|
||||
// Close server 1 and client 1
|
||||
|
|
@ -242,6 +243,7 @@ func TestClientServerHandshakeInfo(t *testing.T) {
|
|||
assert.Equal(t, &client.HandshakeInfo{
|
||||
UDPEnabled: false,
|
||||
Tx: 100000,
|
||||
ServerAddr: udpAddr,
|
||||
}, info)
|
||||
|
||||
// Close server 2 and client 2
|
||||
|
|
@ -272,6 +274,7 @@ func TestClientServerHandshakeInfo(t *testing.T) {
|
|||
assert.Equal(t, &client.HandshakeInfo{
|
||||
UDPEnabled: true,
|
||||
Tx: 0,
|
||||
ServerAddr: udpAddr,
|
||||
}, info)
|
||||
|
||||
// Close server 3 and client 3
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue