@raul
is connectionGater workable ? for implementing custom handshake methods …
i tried
func (cg *MyConnectionGater) InterceptUpgraded(conn network.Conn) (allow bool, reason control.DisconnectReason) {
//TODO implement me
//panic("implement me")
fmt.Println("Status : ", conn.ConnState().Transport)
if conn.Stat().Direction == 1 {
challengeStream, err := conn.NewStream(context.Background())
if err != nil {
fmt.Println("Failed to start stream")
return false, 0
}
_, err = challengeStream.Write([]byte("hello"))
if err != nil {
fmt.Println("Failed to send challenge")
return false, 0
}
} else {
streams := conn.GetStreams()
if len(streams) == 0 {
return false, 0
}
challengeStream := streams[0]
var buf []byte
_, err := challengeStream.Read(buf)
if err != nil {
fmt.Println("Failed to receive challenge")
return false, 0
}
}
return true, 0
}
but it fails to open a stream
is there any ways to authorise a peer with CA certs