add
This commit is contained in:
1 parent
1f8263a322
commit
2b6ecc47ae
8 files changed
+198
-51
No files matched your search
@@ -17,7 +17,8 @@ const (
|
||||
)
|
||||
|
||||
func NewClient(addr string, server string, target string, timeout int, key int,
|
||||
tcpmode int, tcpmode_buffersize int, tcpmode_maxwin int, tcpmode_resend_timems int, tcpmode_compress int) (*Client, error) {
|
||||
tcpmode int, tcpmode_buffersize int, tcpmode_maxwin int, tcpmode_resend_timems int, tcpmode_compress int,
|
||||
tcpmode_stat int) (*Client, error) {
|
||||
|
||||
var ipaddr *net.UDPAddr
|
||||
var tcpaddr *net.TCPAddr
|
||||
@@ -56,6 +57,7 @@ func NewClient(addr string, server string, target string, timeout int, key int,
|
||||
tcpmode_maxwin: tcpmode_maxwin,
|
||||
tcpmode_resend_timems: tcpmode_resend_timems,
|
||||
tcpmode_compress: tcpmode_compress,
|
||||
tcpmode_stat: tcpmode_stat,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -72,6 +74,7 @@ type Client struct {
|
||||
tcpmode_maxwin int
|
||||
tcpmode_resend_timems int
|
||||
tcpmode_compress int
|
||||
tcpmode_stat int
|
||||
|
||||
ipaddr *net.UDPAddr
|
||||
tcpaddr *net.TCPAddr
|
||||
@@ -209,7 +212,7 @@ func (p *Client) AcceptTcpConn(conn *net.TCPConn) {
|
||||
uuid := UniqueId()
|
||||
tcpsrcaddr := conn.RemoteAddr().(*net.TCPAddr)
|
||||
|
||||
fm := NewFrameMgr(p.tcpmode_buffersize, p.tcpmode_maxwin, p.tcpmode_resend_timems, p.tcpmode_compress)
|
||||
fm := NewFrameMgr(p.tcpmode_buffersize, p.tcpmode_maxwin, p.tcpmode_resend_timems, p.tcpmode_compress, p.tcpmode_stat)
|
||||
|
||||
now := time.Now()
|
||||
clientConn := &ClientConn{tcpaddr: tcpsrcaddr, id: uuid, activeRecvTime: now, activeSendTime: now, close: false,
|
||||
@@ -233,7 +236,7 @@ func (p *Client) AcceptTcpConn(conn *net.TCPConn) {
|
||||
p.sequence++
|
||||
sendICMP(p.id, p.sequence, *p.conn, p.ipaddrServer, p.targetAddr, clientConn.id, (uint32)(MyMsg_DATA), mb,
|
||||
SEND_PROTO, RECV_PROTO, p.key,
|
||||
p.tcpmode, p.tcpmode_buffersize, p.tcpmode_maxwin, p.tcpmode_resend_timems, p.tcpmode_compress,
|
||||
p.tcpmode, p.tcpmode_buffersize, p.tcpmode_maxwin, p.tcpmode_resend_timems, p.tcpmode_compress, p.tcpmode_stat,
|
||||
p.timeout)
|
||||
p.sendPacket++
|
||||
p.sendPacketSize += (uint64)(len(mb))
|
||||
@@ -293,7 +296,7 @@ func (p *Client) AcceptTcpConn(conn *net.TCPConn) {
|
||||
p.sequence++
|
||||
sendICMP(p.id, p.sequence, *p.conn, p.ipaddrServer, p.targetAddr, clientConn.id, (uint32)(MyMsg_DATA), mb,
|
||||
SEND_PROTO, RECV_PROTO, p.key,
|
||||
p.tcpmode, 0, 0, 0, 0,
|
||||
p.tcpmode, 0, 0, 0, 0, 0,
|
||||
0)
|
||||
p.sendPacket++
|
||||
p.sendPacketSize += (uint64)(len(mb))
|
||||
@@ -354,7 +357,7 @@ func (p *Client) AcceptTcpConn(conn *net.TCPConn) {
|
||||
p.sequence++
|
||||
sendICMP(p.id, p.sequence, *p.conn, p.ipaddrServer, p.targetAddr, clientConn.id, (uint32)(MyMsg_DATA), mb,
|
||||
SEND_PROTO, RECV_PROTO, p.key,
|
||||
p.tcpmode, 0, 0, 0, 0,
|
||||
p.tcpmode, 0, 0, 0, 0, 0,
|
||||
0)
|
||||
p.sendPacket++
|
||||
p.sendPacketSize += (uint64)(len(mb))
|
||||
@@ -426,7 +429,7 @@ func (p *Client) Accept() error {
|
||||
clientConn.activeSendTime = now
|
||||
sendICMP(p.id, p.sequence, *p.conn, p.ipaddrServer, p.targetAddr, clientConn.id, (uint32)(MyMsg_DATA), bytes[:n],
|
||||
SEND_PROTO, RECV_PROTO, p.key,
|
||||
p.tcpmode, 0, 0, 0, 0,
|
||||
p.tcpmode, 0, 0, 0, 0, 0,
|
||||
p.timeout)
|
||||
|
||||
p.sequence++
|
||||
@@ -529,7 +532,7 @@ func (p *Client) ping() {
|
||||
b, _ := now.MarshalBinary()
|
||||
sendICMP(p.id, p.sequence, *p.conn, p.ipaddrServer, p.targetAddr, "", (uint32)(MyMsg_PING), b,
|
||||
SEND_PROTO, RECV_PROTO, p.key,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0)
|
||||
loggo.Info("ping %s %s %d %d %d %d", p.addrServer, now.String(), p.sproto, p.rproto, p.id, p.sequence)
|
||||
p.sequence++
|
||||
|
||||
Reference in new issue
Block a user