This commit is contained in:
esrrhs committed 2018-12-19 14:38:44 +08:00
1 parent 743b82dda4
commit 2beaecc533
4 files changed
+78 -35

No files matched your search

+6 -8
View File
@@ -7,7 +7,7 @@ import (
"time"
)
func NewClient(addr string, server string, target string, timeout int, proto int) (*Client, error) {
func NewClient(addr string, server string, target string, timeout int, sproto int, rproto int) (*Client, error) {
ipaddr, err := net.ResolveUDPAddr("udp", addr)
if err != nil {
@@ -26,13 +26,15 @@ func NewClient(addr string, server string, target string, timeout int, proto int
addrServer: server,
targetAddr: target,
timeout: timeout,
proto: proto,
sproto: sproto,
rproto: rproto,
}, nil
}
type Client struct {
timeout int
proto int
sproto int
rproto int
ipaddr *net.UDPAddr
addr string
@@ -147,16 +149,12 @@ func (p *Client) Accept() error {
}
clientConn.activeTime = now
sendICMP(*p.conn, p.ipaddrServer, p.targetAddr, clientConn.id, (uint32)(DATA), bytes[:n], p.proto)
sendICMP(*p.conn, p.ipaddrServer, p.targetAddr, clientConn.id, (uint32)(DATA), bytes[:n], p.sproto, p.rproto)
}
}
func (p *Client) processPacket(packet *Packet) {
if packet.data == nil {
return
}
fmt.Printf("processPacket %s %s %d\n", packet.id, packet.src.String(), len(packet.data))
clientConn := p.localIdToConnMap[packet.id]