-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af83519
commit 9a4f883
Showing
5 changed files
with
38 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,5 @@ | ||
package ipfs | ||
|
||
import ( | ||
"github.com/joincloud/peers-touch-go/network/transport" | ||
"github.com/libp2p/go-libp2p-core/host" | ||
"github.com/libp2p/go-libp2p-core/network" | ||
"github.com/libp2p/go-libp2p-core/protocol" | ||
) | ||
|
||
type ipfsTransportClient struct { | ||
host host.Host | ||
protocol protocol.ID | ||
conn network.Conn | ||
local string | ||
remote string | ||
} | ||
|
||
func (i *ipfsTransportClient) Recv(message *transport.Message) error { | ||
panic("implement me") | ||
} | ||
|
||
func (i *ipfsTransportClient) Send(message *transport.Message) error { | ||
panic("implement me") | ||
} | ||
|
||
func (i *ipfsTransportClient) Close() error { | ||
panic("implement me") | ||
} | ||
|
||
func (i *ipfsTransportClient) Local() string { | ||
return i.local | ||
} | ||
|
||
func (i *ipfsTransportClient) Remote() string { | ||
return i.remote | ||
*ipfsTransportSocket | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,39 @@ | ||
package ipfs | ||
|
||
import ( | ||
"bufio" | ||
|
||
"github.com/joincloud/peers-touch-go/codec" | ||
"github.com/joincloud/peers-touch-go/network/transport" | ||
"github.com/libp2p/go-libp2p-core/host" | ||
"github.com/libp2p/go-libp2p-core/network" | ||
"github.com/libp2p/go-libp2p-core/protocol" | ||
) | ||
|
||
type ipfsTransportListener struct { | ||
it *ipfsTransport | ||
opts transport.ListenOptions | ||
host host.Host | ||
pid protocol.ID | ||
opts transport.ListenOptions | ||
codec codec.Codec | ||
} | ||
|
||
func (i *ipfsTransportListener) Addr() string { | ||
return i.it.host.Addrs()[0].String() | ||
return i.host.Addrs()[0].String() | ||
} | ||
|
||
func (i *ipfsTransportListener) Close() error { | ||
return i.it.host.Close() | ||
i.host.RemoveStreamHandler(i.pid) | ||
return nil | ||
} | ||
|
||
func (i *ipfsTransportListener) Accept(f func(socket transport.Socket)) error { | ||
for { | ||
|
||
} | ||
func (i *ipfsTransportListener) Accept(fn func(socket transport.Socket)) error { | ||
i.host.SetStreamHandler(i.pid, func(s network.Stream) { | ||
fn(&ipfsTransportSocket{ | ||
stream: s, | ||
r: bufio.NewReader(s), | ||
w: bufio.NewWriter(s), | ||
codec: i.codec, | ||
}) | ||
}) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters