Skip to content

Commit

Permalink
remove Conn.New
Browse files Browse the repository at this point in the history
  • Loading branch information
navigaid committed Jan 1, 1970
1 parent 499dd95 commit d0fe346
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 36 deletions.
2 changes: 1 addition & 1 deletion cmd/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func main() {
log.Println("connected:", c.Id)

rpcServer := rpc.NewServer()
rpcServer.Register(new(rpcimpl.Conn))
// rpcServer.Register(new(rpcimpl.Conn))
rpcServer.Register(new(rpcimpl.WsConn))
rpcServer.Register(new(rpcimpl.GRPCConn))
log.Println("serveconn")
Expand Down
36 changes: 1 addition & 35 deletions pkg/api/rpc/impl/rpcimpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,40 +57,6 @@ func (h *Bash) Execute(req Request, res *Response) error {
return err
}

type Conn struct{}

type ConnRequest struct {
Id string
Nonce string
}

type ConnResponse struct {
Message string
}

func (c *Conn) New(req ConnRequest, res *ConnResponse) error {
log.Println("Conn.New called with", req)

if req.Id == "" {
return errors.New("id cannot be empty")
}
if req.Nonce == "" {
return errors.New("nonce cannot be empty")
}
// log.Println(config.Default)
res.Message = "OK"
conn := dial.Dial(config.Default)
dial.HandshakeAppend(conn, req.Nonce)
println("dial.HandshakeAppend")
go serveHTTP(conn)
return nil
}

func serveHTTP(conn net.Conn) {
conn.Write([]byte("HTTP/1.1 200 OK\r\nContent-Length: 76\r\nContent-Type: text/plain; charset=utf-8\r\nDate: Wed, 19 Jul 1972 19:00:00 GMT\r\n\r\nGo is a general-purpose language designed with systems programming in mind.\n"))
// conn.Close()
}

type WsConn struct{}

type WsConnRequest struct {
Expand Down Expand Up @@ -203,7 +169,7 @@ type GRPCConnResponse struct {
Message string
}

func (*GRPCConn) New(req ConnRequest, res *ConnResponse) error {
func (*GRPCConn) New(req GRPCConnRequest, res *GRPCConnResponse) error {
log.Println("GRPCConn.New called with", req)

if req.Id == "" {
Expand Down
2 changes: 2 additions & 0 deletions pkg/hub/slavepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ func NewSlave(w http.ResponseWriter) (*Slave, error) {
log.Println("connected:", slave.UUID, slave.RemoteAddr)

GlobalSlavePool.Add(slave)
/*
factory := func() (net.Conn, error) {
log.Println("infactory")
nonce := uuid.New().String()
Expand All @@ -181,6 +182,7 @@ func NewSlave(w http.ResponseWriter) (*Slave, error) {
return conn, nil
}
_ = factory
*/
// log.Println("pool.NewChannelPool")
// slave.Pool, err = pool.NewChannelPool(5, 30, factory)
// if err != nil {
Expand Down

0 comments on commit d0fe346

Please sign in to comment.