add
This commit is contained in:
parent
d25f8499f6
commit
a71309c8cc
@ -48,8 +48,8 @@ Usage:
|
|||||||
-tcp 设置是否转发tcp,默认0
|
-tcp 设置是否转发tcp,默认0
|
||||||
Set the switch to forward tcp, the default is 0
|
Set the switch to forward tcp, the default is 0
|
||||||
|
|
||||||
-tcp_bs tcp的发送接收缓冲区大小,默认10MB
|
-tcp_bs tcp的发送接收缓冲区大小,默认1MB
|
||||||
Tcp send and receive buffer size, default 10MB
|
Tcp send and receive buffer size, default 1MB
|
||||||
|
|
||||||
-tcp_mw tcp的最大窗口,默认10000
|
-tcp_mw tcp的最大窗口,默认10000
|
||||||
The maximum window of tcp, the default is 10000
|
The maximum window of tcp, the default is 10000
|
||||||
@ -82,7 +82,7 @@ func main() {
|
|||||||
timeout := flag.Int("timeout", 60, "conn timeout")
|
timeout := flag.Int("timeout", 60, "conn timeout")
|
||||||
key := flag.Int("key", 0, "key")
|
key := flag.Int("key", 0, "key")
|
||||||
tcpmode := flag.Int("tcp", 0, "tcp mode")
|
tcpmode := flag.Int("tcp", 0, "tcp mode")
|
||||||
tcpmode_buffersize := flag.Int("tcp_bs", 10*1024*1024, "tcp mode buffer size")
|
tcpmode_buffersize := flag.Int("tcp_bs", 1*1024*1024, "tcp mode buffer size")
|
||||||
tcpmode_maxwin := flag.Int("tcp_mw", 10000, "tcp mode max win")
|
tcpmode_maxwin := flag.Int("tcp_mw", 10000, "tcp mode max win")
|
||||||
tcpmode_resend_timems := flag.Int("tcp_rst", 400, "tcp mode resend time ms")
|
tcpmode_resend_timems := flag.Int("tcp_rst", 400, "tcp mode resend time ms")
|
||||||
tcpmode_compress := flag.Int("tcp_gz", 0, "tcp data compress")
|
tcpmode_compress := flag.Int("tcp_gz", 0, "tcp data compress")
|
||||||
|
20
server.go
20
server.go
@ -123,17 +123,14 @@ func (p *Server) processPacket(packet *Packet) {
|
|||||||
if packet.my.Tcpmode > 0 {
|
if packet.my.Tcpmode > 0 {
|
||||||
|
|
||||||
addr := packet.my.Target
|
addr := packet.my.Target
|
||||||
ipaddrTarget, err := net.ResolveTCPAddr("tcp", addr)
|
|
||||||
if err != nil {
|
|
||||||
loggo.Error("Error ResolveUDPAddr for tcp addr: %s %s", addr, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
targetConn, err := net.DialTCP("tcp", nil, ipaddrTarget)
|
c, err := net.DialTimeout("tcp", addr, time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
loggo.Error("Error listening for tcp packets: %s", err.Error())
|
loggo.Error("Error listening for tcp packets: %s", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
targetConn := c.(*net.TCPConn)
|
||||||
|
ipaddrTarget := targetConn.RemoteAddr().(*net.TCPAddr)
|
||||||
|
|
||||||
fm := NewFrameMgr((int)(packet.my.TcpmodeBuffersize), (int)(packet.my.TcpmodeMaxwin), (int)(packet.my.TcpmodeResendTimems), (int)(packet.my.TcpmodeCompress),
|
fm := NewFrameMgr((int)(packet.my.TcpmodeBuffersize), (int)(packet.my.TcpmodeMaxwin), (int)(packet.my.TcpmodeResendTimems), (int)(packet.my.TcpmodeCompress),
|
||||||
(int)(packet.my.TcpmodeStat))
|
(int)(packet.my.TcpmodeStat))
|
||||||
@ -148,17 +145,14 @@ func (p *Server) processPacket(packet *Packet) {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
addr := packet.my.Target
|
addr := packet.my.Target
|
||||||
ipaddrTarget, err := net.ResolveUDPAddr("udp", addr)
|
|
||||||
if err != nil {
|
|
||||||
loggo.Error("Error ResolveUDPAddr for udp addr: %s %s", addr, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
targetConn, err := net.DialUDP("udp", nil, ipaddrTarget)
|
c, err := net.DialTimeout("udp", addr, time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
loggo.Error("Error listening for udp packets: %s", err.Error())
|
loggo.Error("Error listening for tcp packets: %s", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
targetConn := c.(*net.UDPConn)
|
||||||
|
ipaddrTarget := targetConn.RemoteAddr().(*net.UDPAddr)
|
||||||
|
|
||||||
localConn = &ServerConn{timeout: (int)(packet.my.Timeout), conn: targetConn, ipaddrTarget: ipaddrTarget, id: id, activeRecvTime: now, activeSendTime: now, close: false,
|
localConn = &ServerConn{timeout: (int)(packet.my.Timeout), conn: targetConn, ipaddrTarget: ipaddrTarget, id: id, activeRecvTime: now, activeSendTime: now, close: false,
|
||||||
rproto: (int)(packet.my.Rproto), tcpmode: (int)(packet.my.Tcpmode)}
|
rproto: (int)(packet.my.Rproto), tcpmode: (int)(packet.my.Tcpmode)}
|
||||||
|
Loading…
Reference in New Issue
Block a user