mirror of
https://github.com/wangyu-/udp2raw.git
synced 2025-01-19 14:29:34 +08:00
fixed sed ack_seq of faketcp mode
This commit is contained in:
parent
66e6e7946a
commit
b0c8448fdf
33
main.cpp
33
main.cpp
@ -976,6 +976,7 @@ int keep_connection_client(conn_info_t &conn_info) //for client
|
|||||||
}
|
}
|
||||||
if(conn_info.state.client_current_state==client_syn_sent )
|
if(conn_info.state.client_current_state==client_syn_sent )
|
||||||
{
|
{
|
||||||
|
assert(raw_mode==mode_faketcp);
|
||||||
if(get_current_time()-conn_info.last_state_time>client_handshake_timeout)
|
if(get_current_time()-conn_info.last_state_time>client_handshake_timeout)
|
||||||
{
|
{
|
||||||
conn_info.state.client_current_state=client_nothing;
|
conn_info.state.client_current_state=client_nothing;
|
||||||
@ -985,6 +986,7 @@ int keep_connection_client(conn_info_t &conn_info) //for client
|
|||||||
else if(get_current_time()-conn_info.last_hb_sent_time>client_retry_interval)
|
else if(get_current_time()-conn_info.last_hb_sent_time>client_retry_interval)
|
||||||
{
|
{
|
||||||
mylog(log_info,"retry send sync\n");
|
mylog(log_info,"retry send sync\n");
|
||||||
|
send_info.seq=send_info.first_seq;
|
||||||
send_bare(raw_info,0,0); /////////////send
|
send_bare(raw_info,0,0); /////////////send
|
||||||
conn_info.last_hb_sent_time=get_current_time();
|
conn_info.last_hb_sent_time=get_current_time();
|
||||||
}
|
}
|
||||||
@ -1002,6 +1004,8 @@ int keep_connection_client(conn_info_t &conn_info) //for client
|
|||||||
{
|
{
|
||||||
if(raw_mode==mode_faketcp)
|
if(raw_mode==mode_faketcp)
|
||||||
{
|
{
|
||||||
|
send_info.seq=send_info.first_seq+1;
|
||||||
|
send_info.ack_seq=send_info.first_ack_seq;
|
||||||
send_bare(raw_info,0,0);/////////////send
|
send_bare(raw_info,0,0);/////////////send
|
||||||
}
|
}
|
||||||
else if(raw_mode==mode_udp||raw_mode==mode_icmp)
|
else if(raw_mode==mode_udp||raw_mode==mode_icmp)
|
||||||
@ -1262,7 +1266,15 @@ int client_on_raw_recv(conn_info_t &conn_info)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(recv_info.ack_seq!=send_info.first_seq+1)
|
||||||
|
{
|
||||||
|
mylog(log_info,"unexpected ack_seq:%d ,should be %d\n",recv_info.ack_seq,send_info.first_seq+1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
send_info.ack_seq=recv_info.seq+1;
|
send_info.ack_seq=recv_info.seq+1;
|
||||||
|
send_info.first_ack_seq=send_info.ack_seq;
|
||||||
|
|
||||||
send_info.psh=0;
|
send_info.psh=0;
|
||||||
send_info.syn=0;
|
send_info.syn=0;
|
||||||
send_info.ack=1;
|
send_info.ack=1;
|
||||||
@ -1304,7 +1316,8 @@ int client_on_raw_recv(conn_info_t &conn_info)
|
|||||||
printf("not a heartbeat\n");
|
printf("not a heartbeat\n");
|
||||||
return 0;
|
return 0;
|
||||||
}*/
|
}*/
|
||||||
|
send_info.seq=send_info.first_seq+1;
|
||||||
|
send_info.ack_seq=send_info.first_ack_seq;
|
||||||
|
|
||||||
conn_info.oppsite_id= ntohl(* ((uint32_t *)&data[0]));
|
conn_info.oppsite_id= ntohl(* ((uint32_t *)&data[0]));
|
||||||
|
|
||||||
@ -1830,9 +1843,22 @@ int server_on_raw_recv_multi()
|
|||||||
if( recv_info.syn==0&&recv_info.ack==1 &&data_len==0) //received ack as expect
|
if( recv_info.syn==0&&recv_info.ack==1 &&data_len==0) //received ack as expect
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if(recv_info.ack_seq!=send_info.first_seq+1)
|
||||||
|
{
|
||||||
|
mylog(log_info,"[%s]unexpect ack_seq %d,should be\n",ip_port,recv_info.ack_seq,send_info.first_seq+1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if(recv_info.seq!=send_info.first_ack_seq)
|
||||||
|
{
|
||||||
|
mylog(log_info,"[%s]unexpect seq %d,should be\n",ip_port,recv_info.seq,send_info.first_ack_seq);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
send_info.syn=0;
|
send_info.syn=0;
|
||||||
send_info.ack=1;
|
send_info.ack=1;
|
||||||
send_info.seq+=1;////////is this right?
|
//send_info.seq+=1;////////is this right?
|
||||||
|
|
||||||
|
send_info.seq=send_info.first_seq+1;
|
||||||
|
send_info.ack_seq=send_info.first_ack_seq;
|
||||||
|
|
||||||
conn_info.my_id=get_true_random_number_nz();
|
conn_info.my_id=get_true_random_number_nz();
|
||||||
send_handshake(raw_info,conn_info.my_id,0,const_id); //////////////send
|
send_handshake(raw_info,conn_info.my_id,0,const_id); //////////////send
|
||||||
@ -1877,6 +1903,9 @@ int server_on_raw_recv_multi()
|
|||||||
send_info.syn=0;
|
send_info.syn=0;
|
||||||
send_info.ack=1;
|
send_info.ack=1;
|
||||||
|
|
||||||
|
send_info.seq=send_info.first_seq+1;
|
||||||
|
send_info.ack_seq=send_info.first_ack_seq;
|
||||||
|
|
||||||
conn_info.my_id=get_true_random_number_nz();
|
conn_info.my_id=get_true_random_number_nz();
|
||||||
mylog(log_info,"[%s]re-sent handshake\n",ip_port);
|
mylog(log_info,"[%s]re-sent handshake\n",ip_port);
|
||||||
send_handshake(raw_info,conn_info.my_id,0,const_id);
|
send_handshake(raw_info,conn_info.my_id,0,const_id);
|
||||||
|
@ -1061,6 +1061,11 @@ int recv_raw_tcp(raw_info_t &raw_info,char * &payload,int &payloadlen)
|
|||||||
payloadlen = ip_payloadlen-tcphdrlen;
|
payloadlen = ip_payloadlen-tcphdrlen;
|
||||||
|
|
||||||
payload=tcp_begin+tcphdrlen;
|
payload=tcp_begin+tcphdrlen;
|
||||||
|
|
||||||
|
if (recv_info.syn == 0 && recv_info.ack == 1&& payloadlen != 0) //only modify send_info when the packet is not part of handshake
|
||||||
|
{
|
||||||
|
send_info.ack_seq=recv_info.seq;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user