Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

你好,发现一个问题,不知道是不是一个bug #53

Closed
mylonly opened this issue Jun 20, 2019 · 0 comments
Closed

你好,发现一个问题,不知道是不是一个bug #53

mylonly opened this issue Jun 20, 2019 · 0 comments

Comments

@mylonly
Copy link

mylonly commented Jun 20, 2019

问题描述如下:
我是用了auth plugin,但是每次断线重连之后在plugin这块都会直接返回connection close的error信息,跟踪代码后发现,在renewSessionForClient方法中,在p.pluginContainer.postDial(sess)时,当前session的状态依然是Closed,导致后续写消息直接判断状态返回了,
现修改如下:


func (p *peer) renewSessionForClient(sess *session, dialFunc func() (net.Conn, error), addr string, protoFuncs []ProtoFunc) error {
	var conn, dialErr = dialFunc()
	if dialErr != nil {
		return dialErr
	}
	if p.tlsConfig != nil {
		conn = tls.Client(conn, p.tlsConfig)
	}
	oldIP := sess.LocalAddr().String()
	oldID := sess.ID()
	oldConn := sess.getConn()
	if oldConn != nil {
		oldConn.Close()
	}
	sess.socket.Reset(conn, protoFuncs...)
	if oldIP == oldID {
		sess.socket.SetID(sess.LocalAddr().String())
	} else {
		sess.socket.SetID(oldID)
	}
	atomic.StoreInt32(&sess.status, statusOk) //将状态修改放在plugin之前
	if rerr := p.pluginContainer.postDial(sess); rerr != nil {
		sess.Close()
		return rerr.ToError()
	}
	// atomic.StoreInt32(&sess.status, statusOk)
	AnywayGo(sess.startReadAndHandle)
	p.sessHub.Set(sess)
	return nil
}

不知道这样改动会不会引发其他问题,还没有完全吃透teleport的源码

@andeya andeya closed this as completed in 90cd90c Jun 24, 2019
andeya added a commit that referenced this issue Oct 21, 2019
Change-Id: I8c740e6174e16bba19eba1f46767c9f0abb096e4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant