diff --git a/pkg/app2/client.go b/pkg/app2/client.go index 912134a8d..c24cca523 100644 --- a/pkg/app2/client.go +++ b/pkg/app2/client.go @@ -1,6 +1,7 @@ package app2 import ( + "net" "net/rpc" "github.com/skycoin/dmsg/cipher" @@ -52,7 +53,7 @@ func (c *Client) Dial(remote routing.Addr) (*Conn, error) { } // Listen listens on the specified `port` for the incoming connections. -func (c *Client) Listen(port routing.Port) (*Listener, error) { +func (c *Client) Listen(port routing.Port) (net.Listener, error) { local := routing.Addr{ PubKey: c.pk, Port: port, diff --git a/pkg/app2/conn.go b/pkg/app2/conn.go index 6913315a0..f250ea662 100644 --- a/pkg/app2/conn.go +++ b/pkg/app2/conn.go @@ -2,14 +2,16 @@ package app2 import ( "net" + "time" + "github.com/pkg/errors" "github.com/skycoin/skywire/pkg/routing" ) // Conn is a connection from app client to the server. type Conn struct { id uint16 - rpc ConnRPCClient + rpc ServerRPCClient local routing.Addr remote routing.Addr } @@ -33,3 +35,15 @@ func (c *Conn) LocalAddr() net.Addr { func (c *Conn) RemoteAddr() net.Addr { return c.remote } + +func (c *Conn) SetDeadline(t time.Time) error { + return errors.New("method not implemented") +} + +func (c *Conn) SetReadDeadline(t time.Time) error { + return errors.New("method not implemented") +} + +func (c *Conn) SetWriteDeadline(t time.Time) error { + return errors.New("method not implemented") +} diff --git a/pkg/app2/listener.go b/pkg/app2/listener.go index ee1122509..b1854ba5e 100644 --- a/pkg/app2/listener.go +++ b/pkg/app2/listener.go @@ -9,11 +9,11 @@ import ( // Listener is a listener for app server connections. type Listener struct { id uint16 - rpc ListenerRPCClient + rpc ServerRPCClient addr routing.Addr } -func (l *Listener) Accept() (*Conn, error) { +func (l *Listener) Accept() (net.Conn, error) { connID, err := l.rpc.Accept(l.id) if err != nil { return nil, err diff --git a/pkg/app2/server_rpc_client.go b/pkg/app2/server_rpc_client.go index e277d18e3..bb7a5e842 100644 --- a/pkg/app2/server_rpc_client.go +++ b/pkg/app2/server_rpc_client.go @@ -17,24 +17,6 @@ type ServerRPCClient interface { CloseListener(id uint16) error } -// ListenerRPCClient describes RPC interface to communicate with the server. -// Contains funcs for `Listener` and `Conn`. -type ListenerRPCClient interface { - Accept(id uint16) (uint16, error) - CloseListener(id uint16) error - Write(connID uint16, b []byte) (int, error) - Read(connID uint16, b []byte) (int, error) - CloseConn(id uint16) error -} - -// ConnRPCClient describes RPC interface to communicate with the server. -// Contains funcs for `Conn`. -type ConnRPCClient interface { - Write(id uint16, b []byte) (int, error) - Read(id uint16, b []byte) (int, error) - CloseConn(id uint16) error -} - // serverRPCClient implements `ServerRPCClient`. type serverRPCCLient struct { rpc *rpc.Client