gonet2 / agent Goto Github PK
View Code? Open in Web Editor NEWA gateway for games with stream multiplexing
License: MIT License
A gateway for games with stream multiplexing
License: MIT License
同一个grpc连接,当stream创建超过100个的话,超出的stream创建会卡死
也就是说agent和game之间最多只能创建100个session的链接
看到代码里有段逻辑是进行协议序号校验的,可以防止重放攻击:
// 数据包序列号验证
if seq_id != sess.PacketCount {
sess.Flag |= SESS_KICKED_OUT
return nil
}
很多情况下这可能造成误判,有时候并不是故意重放,比如客户端由于网络原因没有收到服务器回包,会重发上一次请求,这属于正常重放。
似乎是这里的case <-sess.Die无法进去,不知道该怎么改...
for {
// solve dead link problem:
// physical disconnection without any communcation between client and server
// will cause the read to block FOREVER, so a timeout is a rescue.
conn.SetReadDeadline(time.Now().Add(config.readDeadline))
// read 2B header
n, err := io.ReadFull(conn, header)
if err != nil {
log.Warningf("read header failed, ip:%v reason:%v size:%v", sess.IP, err, n)
return
}
size := binary.BigEndian.Uint16(header)
// alloc a byte slice of the size defined in the header for reading data
payload := make([]byte, size)
n, err = io.ReadFull(conn, payload)
if err != nil {
log.Warningf("read payload failed, ip:%v reason:%v size:%v", sess.IP, err, n)
return
}
// deliver the data to the input queue of agent()
select {
case in <- payload: // payload queued
case <-sess.Die:
log.Warningf("connection closed by logic, flag:%v ip:%v", sess.Flag, sess.IP)
return
}
}
panic: reflect: call of reflect.Value.Int on zero Value
goroutine 9 [running]:
reflect.Value.Int(0x0, 0x0, 0x0, 0x174d146)
/usr/local/go/src/reflect/value.go:908 +0x141
agent/vendor/golang.org/x/net/ipv4.sysfd(0x1a8d440, 0xc42000e1a8, 0x136d8c8, 0xc420041e60, 0xc420041fa8)
/Users/apple/gamejob/gonet2/src/agent/vendor/golang.org/x/net/ipv4/helper_unix.go:46 +0x196
agent/vendor/golang.org/x/net/ipv4.(*genericOpt).sysfd(0xc420041ec0, 0x16a2de0, 0x172e8c0, 0x1)
/Users/apple/gamejob/gonet2/src/agent/vendor/golang.org/x/net/ipv4/helper_unix.go:17 +0x57
agent/vendor/golang.org/x/net/ipv4.(*genericOpt).SetTOS(0xc420041ec0, 0xb8, 0xc42000e1a8, 0x1a8d440)
/Users/apple/gamejob/gonet2/src/agent/vendor/golang.org/x/net/ipv4/genericopt_posix.go:29 +0x45
agent/vendor/github.com/xtaci/kcp-go.(*Listener).SetDSCP(0xc420114680, 0x2e, 0x0, 0x0)
既然现在不依赖gvp/gvm了,是不是可以改下目录结构来支持go get
只要设定好了GOPATH, 直接
go get -u github.com/gonet2/{agent,game}
就可以clone并安装好agent和game
方便快速的体验
大神能支持websocket
Hello sir can you provide binary for Linux 32 bit please .I have tried to compile but i have error
go build
route.go:10:2: cannot find package "agent/client_handler" in any of:
/root/go/src/agent/client_handler (from $GOROOT)
/root/goworkspace/src/agent/client_handler (from $GOPATH)
buffer.go:11:2: cannot find package "agent/misc/packet" in any of:
/root/go/src/agent/misc/packet (from $GOROOT)
/root/goworkspace/src/agent/misc/packet (from $GOPATH)
agent.go:8:2: cannot find package "agent/pb" in any of:
/root/go/src/agent/pb (from $GOROOT)
/root/goworkspace/src/agent/pb (from $GOPATH)
startup.go:4:2: cannot find package "agent/services" in any of:
/root/go/src/agent/services (from $GOROOT)
/root/goworkspace/src/agent/services (from $GOPATH)
agent.go:9:2: cannot find package "agent/types" in any of:
/root/go/src/agent/types (from $GOROOT)
/root/goworkspace/src/agent/types (from $GOPATH)
agent.go:10:2: cannot find package "agent/utils" in any of:
/root/go/src/agent/utils (from $GOROOT)
/root/goworkspace/src/agent/utils (from $GOPATH)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.