add quic dialer

This commit is contained in:
ginuerzh
2021-12-17 00:23:08 +08:00
parent c7f5da6ac7
commit 965c6846dd
15 changed files with 385 additions and 71 deletions

View File

@ -114,6 +114,11 @@ func (d *kcpDialer) Handshake(ctx context.Context, conn net.Conn, options ...dia
}
session, ok := d.sessions[opts.Addr]
if session != nil && session.conn != conn {
conn.Close()
return nil, errors.New("kcp: unrecognized connection")
}
if !ok || session.session == nil {
s, err := d.initSession(opts.Addr, conn, config)
if err != nil {
@ -138,7 +143,7 @@ func (d *kcpDialer) Handshake(ctx context.Context, conn net.Conn, options ...dia
func (d *kcpDialer) initSession(addr string, conn net.Conn, config *kcp_util.Config) (*muxSession, error) {
pc, ok := conn.(net.PacketConn)
if !ok {
return nil, errors.New("wrong connection type")
return nil, errors.New("kcp: wrong connection type")
}
kcpconn, err := kcp.NewConn(addr,