Tolerate bug in java ca implementation
This commit is contained in:
@@ -2202,18 +2202,26 @@ impl CaConn {
|
||||
CaMsgTy::VersionRes(n) => {
|
||||
// debug!("see incoming {:?} {:?}", self.remote_addr_dbg, msg);
|
||||
if n < 12 || n > 13 {
|
||||
error!("See some unexpected version {n} channel search may not work.");
|
||||
error!("see some unexpected version {n} channel search may not work.");
|
||||
Ready(Some(Ok(())))
|
||||
} else {
|
||||
if n != 13 {
|
||||
warn!("Received peer version {n}");
|
||||
warn!("received peer version {n}");
|
||||
}
|
||||
self.state = CaConnState::PeerReady;
|
||||
Ready(Some(Ok(())))
|
||||
}
|
||||
}
|
||||
CaMsgTy::CreateChanRes(k) => {
|
||||
warn!("got unexpected {k:?}",);
|
||||
Ready(Some(Ok(())))
|
||||
}
|
||||
CaMsgTy::AccessRightsRes(k) => {
|
||||
warn!("got unexpected {k:?}",);
|
||||
Ready(Some(Ok(())))
|
||||
}
|
||||
k => {
|
||||
warn!("Got some other unhandled message: {k:?}");
|
||||
warn!("got some other unhandled message: {k:?}");
|
||||
Ready(Some(Ok(())))
|
||||
}
|
||||
},
|
||||
@@ -2585,7 +2593,7 @@ impl CaConn {
|
||||
debug!("VersionRes({x})");
|
||||
self.weird_count += 1;
|
||||
if self.weird_count > 200 {
|
||||
std::process::exit(13);
|
||||
// std::process::exit(13);
|
||||
}
|
||||
}
|
||||
CaMsgTy::ChannelCloseRes(x) => {
|
||||
@@ -2824,14 +2832,20 @@ impl CaConn {
|
||||
Ok(Ready(Some(())))
|
||||
}
|
||||
CaConnState::Handshake => {
|
||||
match {
|
||||
let res = self.handle_handshake(cx);
|
||||
res
|
||||
} {
|
||||
Ready(Some(Ok(()))) => Ok(Ready(Some(()))),
|
||||
Ready(Some(Err(e))) => Err(e),
|
||||
Ready(None) => Ok(Ready(Some(()))),
|
||||
Pending => Ok(Pending),
|
||||
if true {
|
||||
// because of bad java clients which do not send a version, skip the handshake.
|
||||
self.state = CaConnState::PeerReady;
|
||||
self.handle_conn_state(tsnow, cx)
|
||||
} else {
|
||||
match {
|
||||
let res = self.handle_handshake(cx);
|
||||
res
|
||||
} {
|
||||
Ready(Some(Ok(()))) => Ok(Ready(Some(()))),
|
||||
Ready(Some(Err(e))) => Err(e),
|
||||
Ready(None) => Ok(Ready(Some(()))),
|
||||
Pending => Ok(Pending),
|
||||
}
|
||||
}
|
||||
}
|
||||
CaConnState::PeerReady => {
|
||||
|
||||
@@ -231,10 +231,10 @@ impl FindIocStream {
|
||||
error!("getsockname {ec}");
|
||||
return Err("can not convert raw socket to tokio socket".into());
|
||||
} else {
|
||||
if false {
|
||||
if true {
|
||||
let ipv4 = Ipv4Addr::from(addr.sin_addr.s_addr.to_ne_bytes());
|
||||
let tcp_port = u16::from_be(addr.sin_port);
|
||||
info!("bound local socket to {:?} port {}", ipv4, tcp_port);
|
||||
debug!("bound local socket to {} port {}", ipv4, tcp_port);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -366,7 +366,7 @@ impl FindIocStream {
|
||||
let mut good = true;
|
||||
if let CaMsgTy::VersionRes(v) = msgs[0].ty {
|
||||
if v != 13 {
|
||||
warn!("bad version: {msgs:?}");
|
||||
warn!("bad version in search response: {v}");
|
||||
good = false;
|
||||
}
|
||||
} else {
|
||||
@@ -375,8 +375,10 @@ impl FindIocStream {
|
||||
// trace2!("recv {:?} {:?}", src_addr, msgs);
|
||||
let mut res = Vec::new();
|
||||
if good {
|
||||
for msg in &msgs[1..] {
|
||||
// because of bad java CA implementation, consider also the first message
|
||||
for msg in &msgs[0..] {
|
||||
match &msg.ty {
|
||||
CaMsgTy::VersionRes(_) => {}
|
||||
CaMsgTy::SearchRes(k) => {
|
||||
let addr = SocketAddrV4::new(src_addr, k.tcp_port);
|
||||
res.push((SearchId(k.id), addr));
|
||||
|
||||
Reference in New Issue
Block a user