示例#1
0
文件: conn.go 项目: droyo/styx
func newConn(srv *Server, rwc io.ReadWriteCloser) *conn {
	var msize int64 = styxproto.DefaultMaxSize
	if srv.MaxSize > 0 {
		if srv.MaxSize > styxproto.MinBufSize {
			msize = srv.MaxSize
		} else {
			msize = styxproto.MinBufSize
		}
	}
	var enc *styxproto.Encoder
	var dec *styxproto.Decoder
	if srv.TraceLog != nil {
		enc = tracing.Encoder(rwc, func(m styxproto.Msg) {
			srv.TraceLog.Printf("← %03d %s", m.Tag(), m)
		})
		dec = tracing.Decoder(rwc, func(m styxproto.Msg) {
			srv.TraceLog.Printf("→ %03d %s", m.Tag(), m)
		})
	} else {
		enc = styxproto.NewEncoder(rwc)
		dec = styxproto.NewDecoder(rwc)
	}
	return &conn{
		Decoder:    dec,
		Encoder:    enc,
		srv:        srv,
		rwc:        rwc,
		cx:         context.TODO(),
		msize:      msize,
		sessionFid: util.NewMap(),
		pendingReq: util.NewMap(),
		qidpool:    qidpool.New(),
	}
}
示例#2
0
文件: session.go 项目: droyo/styx
func newSession(c *conn, m fattach) *Session {
	s := &Session{
		User:     string(m.Uname()),
		Access:   string(m.Aname()),
		conn:     c,
		files:    util.NewMap(),
		authC:    make(chan error, 1),
		requests: make(chan Request),
	}
	return s
}
示例#3
0
文件: pool.go 项目: droyo/styx
// New returns a new, empty Pool.
func New() *Pool {
	return &Pool{m: util.NewMap()}
}