瀏覽代碼

fix: remove `assert_eq` for `read_hello`

Yujia Qiao 4 年之前
父節點
當前提交
f772c7cfed
共有 1 個文件被更改,包括 7 次插入3 次删除
  1. 7 3
      src/protocol.rs

+ 7 - 3
src/protocol.rs

@@ -192,9 +192,13 @@ pub async fn read_hello<T: AsyncRead + AsyncWrite + Unpin>(conn: &mut T) -> Resu
             }
         }
         Hello::DataChannelHello(v, _) => {
-            // This assert should not fail because the version has already been
-            // checked by ControlChannelHello.
-            assert_eq!(v, CURRENT_PROTO_VERSION);
+            if v != CURRENT_PROTO_VERSION {
+                bail!(
+                    "Protocol version mismatched. Expected {}, got {}. Please update `rathole`.",
+                    CURRENT_PROTO_VERSION,
+                    v
+                );
+            }
         }
     }