This commit is contained in:
esrrhs 2019-10-26 12:07:20 +08:00
parent a13cd98e29
commit b15faae234
3 changed files with 19 additions and 9 deletions

View File

@ -256,7 +256,8 @@ func (p *Client) AcceptTcpConn(conn *net.TCPConn) {
p.sequence++ p.sequence++
sendICMP(p.id, p.sequence, *p.conn, p.ipaddrServer, p.targetAddr, clientConn.id, (uint32)(MyMsg_DATA), mb, sendICMP(p.id, p.sequence, *p.conn, p.ipaddrServer, p.targetAddr, clientConn.id, (uint32)(MyMsg_DATA), mb,
SEND_PROTO, RECV_PROTO, p.key, SEND_PROTO, RECV_PROTO, p.key,
p.tcpmode, p.tcpmode_buffersize, p.tcpmode_maxwin, p.tcpmode_resend_timems) p.tcpmode, p.tcpmode_buffersize, p.tcpmode_maxwin, p.tcpmode_resend_timems,
p.timeout)
p.sendPacket++ p.sendPacket++
p.sendPacketSize += (uint64)(len(mb)) p.sendPacketSize += (uint64)(len(mb))
} }
@ -310,7 +311,8 @@ func (p *Client) AcceptTcpConn(conn *net.TCPConn) {
p.sequence++ p.sequence++
sendICMP(p.id, p.sequence, *p.conn, p.ipaddrServer, p.targetAddr, clientConn.id, (uint32)(MyMsg_DATA), mb, sendICMP(p.id, p.sequence, *p.conn, p.ipaddrServer, p.targetAddr, clientConn.id, (uint32)(MyMsg_DATA), mb,
SEND_PROTO, RECV_PROTO, p.key, SEND_PROTO, RECV_PROTO, p.key,
p.tcpmode, p.tcpmode_buffersize, p.tcpmode_maxwin, p.tcpmode_resend_timems) p.tcpmode, p.tcpmode_buffersize, p.tcpmode_maxwin, p.tcpmode_resend_timems,
p.timeout)
p.sendPacket++ p.sendPacket++
p.sendPacketSize += (uint64)(len(mb)) p.sendPacketSize += (uint64)(len(mb))
} }
@ -381,7 +383,8 @@ func (p *Client) Accept() error {
clientConn.activeSendTime = now clientConn.activeSendTime = now
sendICMP(p.id, p.sequence, *p.conn, p.ipaddrServer, p.targetAddr, clientConn.id, (uint32)(MyMsg_DATA), bytes[:n], sendICMP(p.id, p.sequence, *p.conn, p.ipaddrServer, p.targetAddr, clientConn.id, (uint32)(MyMsg_DATA), bytes[:n],
SEND_PROTO, RECV_PROTO, p.key, SEND_PROTO, RECV_PROTO, p.key,
p.tcpmode, p.tcpmode_buffersize, p.tcpmode_maxwin, p.tcpmode_resend_timems) p.tcpmode, p.tcpmode_buffersize, p.tcpmode_maxwin, p.tcpmode_resend_timems,
p.timeout)
p.sequence++ p.sequence++
@ -483,7 +486,8 @@ func (p *Client) ping() {
b, _ := now.MarshalBinary() b, _ := now.MarshalBinary()
sendICMP(p.id, p.sequence, *p.conn, p.ipaddrServer, p.targetAddr, "", (uint32)(MyMsg_PING), b, sendICMP(p.id, p.sequence, *p.conn, p.ipaddrServer, p.targetAddr, "", (uint32)(MyMsg_PING), b,
SEND_PROTO, RECV_PROTO, p.key, SEND_PROTO, RECV_PROTO, p.key,
p.tcpmode, p.tcpmode_buffersize, p.tcpmode_maxwin, p.tcpmode_resend_timems) p.tcpmode, p.tcpmode_buffersize, p.tcpmode_maxwin, p.tcpmode_resend_timems,
p.timeout)
loggo.Info("ping %s %s %d %d %d %d", p.addrServer, now.String(), p.sproto, p.rproto, p.id, p.sequence) loggo.Info("ping %s %s %d %d %d %d", p.addrServer, now.String(), p.sproto, p.rproto, p.id, p.sequence)
p.sequence++ p.sequence++
} }

View File

@ -18,7 +18,8 @@ import (
func sendICMP(id int, sequence int, conn icmp.PacketConn, server *net.IPAddr, target string, func sendICMP(id int, sequence int, conn icmp.PacketConn, server *net.IPAddr, target string,
connId string, msgType uint32, data []byte, sproto int, rproto int, key int, connId string, msgType uint32, data []byte, sproto int, rproto int, key int,
tcpmode int, tcpmode_buffer_size int, tcpmode_maxwin int, tcpmode_resend_time int) { tcpmode int, tcpmode_buffer_size int, tcpmode_maxwin int, tcpmode_resend_time int,
timeout int) {
m := &MyMsg{ m := &MyMsg{
Id: connId, Id: connId,
@ -31,6 +32,7 @@ func sendICMP(id int, sequence int, conn icmp.PacketConn, server *net.IPAddr, ta
TcpmodeBuffersize: (int32)(tcpmode_buffer_size), TcpmodeBuffersize: (int32)(tcpmode_buffer_size),
TcpmodeMaxwin: (int32)(tcpmode_maxwin), TcpmodeMaxwin: (int32)(tcpmode_maxwin),
TcpmodeResendTimems: (int32)(tcpmode_resend_time), TcpmodeResendTimems: (int32)(tcpmode_resend_time),
Timeout: (int32)(timeout),
Magic: (int32)(MyMsg_MAGIC), Magic: (int32)(MyMsg_MAGIC),
} }

View File

@ -89,7 +89,8 @@ func (p *Server) processPacket(packet *Packet) {
loggo.Info("ping from %s %s %d %d %d", packet.src.String(), t.String(), packet.my.Rproto, packet.echoId, packet.echoSeq) loggo.Info("ping from %s %s %d %d %d", packet.src.String(), t.String(), packet.my.Rproto, packet.echoId, packet.echoSeq)
sendICMP(packet.echoId, packet.echoSeq, *p.conn, packet.src, "", "", (uint32)(MyMsg_PING), packet.my.Data, sendICMP(packet.echoId, packet.echoSeq, *p.conn, packet.src, "", "", (uint32)(MyMsg_PING), packet.my.Data,
(int)(packet.my.Rproto), -1, p.key, (int)(packet.my.Rproto), -1, p.key,
0, 0, 0, 0) 0, 0, 0, 0,
0)
return return
} }
@ -221,7 +222,8 @@ func (p *Server) RecvTCP(conn *ServerConn, id string, src *net.IPAddr) {
} }
sendICMP(p.echoId, p.echoSeq, *p.conn, src, "", id, (uint32)(MyMsg_DATA), mb, sendICMP(p.echoId, p.echoSeq, *p.conn, src, "", id, (uint32)(MyMsg_DATA), mb,
conn.rproto, -1, p.key, conn.rproto, -1, p.key,
0, 0, 0, 0) 0, 0, 0, 0,
0)
p.sendPacket++ p.sendPacket++
p.sendPacketSize += (uint64)(len(mb)) p.sendPacketSize += (uint64)(len(mb))
} }
@ -275,7 +277,8 @@ func (p *Server) RecvTCP(conn *ServerConn, id string, src *net.IPAddr) {
mb, _ := proto.Marshal(f) mb, _ := proto.Marshal(f)
sendICMP(p.echoId, p.echoSeq, *p.conn, src, "", id, (uint32)(MyMsg_DATA), mb, sendICMP(p.echoId, p.echoSeq, *p.conn, src, "", id, (uint32)(MyMsg_DATA), mb,
conn.rproto, -1, p.key, conn.rproto, -1, p.key,
0, 0, 0, 0) 0, 0, 0, 0,
0)
p.sendPacket++ p.sendPacket++
p.sendPacketSize += (uint64)(len(mb)) p.sendPacketSize += (uint64)(len(mb))
} }
@ -337,7 +340,8 @@ func (p *Server) Recv(conn *ServerConn, id string, src *net.IPAddr) {
sendICMP(p.echoId, p.echoSeq, *p.conn, src, "", id, (uint32)(MyMsg_DATA), bytes[:n], sendICMP(p.echoId, p.echoSeq, *p.conn, src, "", id, (uint32)(MyMsg_DATA), bytes[:n],
conn.rproto, -1, p.key, conn.rproto, -1, p.key,
0, 0, 0, 0) 0, 0, 0, 0,
0)
p.sendPacket++ p.sendPacket++
p.sendPacketSize += (uint64)(n) p.sendPacketSize += (uint64)(n)