Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
1fa7c07d
Commit
1fa7c07d
authored
Sep 07, 2014
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up merge of bren2010's crypto branch and merge into master
parent
f19e2201
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
27 additions
and
14 deletions
+27
-14
importer/importer_test.go
importer/importer_test.go
+2
-2
routing/dht/dht.go
routing/dht/dht.go
+4
-1
routing/dht/dht_test.go
routing/dht/dht_test.go
+2
-2
routing/dht/ext_test.go
routing/dht/ext_test.go
+0
-2
swarm/conn.go
swarm/conn.go
+2
-0
swarm/swarm.go
swarm/swarm.go
+13
-7
swarm/swarm_test.go
swarm/swarm_test.go
+4
-0
No files found.
importer/importer_test.go
View file @
1fa7c07d
...
...
@@ -18,7 +18,7 @@ func TestFileConsistency(t *testing.T) {
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
r
,
err
:=
dag
.
NewDagReader
(
nd
)
r
,
err
:=
dag
.
NewDagReader
(
nd
,
nil
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -42,7 +42,7 @@ func TestFileConsistencyLargeBlocks(t *testing.T) {
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
r
,
err
:=
dag
.
NewDagReader
(
nd
)
r
,
err
:=
dag
.
NewDagReader
(
nd
,
nil
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
routing/dht/dht.go
View file @
1fa7c07d
...
...
@@ -648,7 +648,10 @@ func (dht *IpfsDHT) peerFromInfo(pbp *PBDHTMessage_PBPeer) (*peer.Peer, error) {
}
func
(
dht
*
IpfsDHT
)
loadProvidableKeys
()
error
{
kl
:=
dht
.
datastore
.
KeyList
()
kl
,
err
:=
dht
.
datastore
.
KeyList
()
if
err
!=
nil
{
return
err
}
for
_
,
k
:=
range
kl
{
dht
.
providers
.
AddProvider
(
u
.
Key
(
k
.
Bytes
()),
dht
.
self
)
}
...
...
routing/dht/dht_test.go
View file @
1fa7c07d
...
...
@@ -29,7 +29,7 @@ func setupDHTS(n int, t *testing.T) ([]*ma.Multiaddr, []*peer.Peer, []*IpfsDHT)
for
i
:=
0
;
i
<
4
;
i
++
{
p
:=
new
(
peer
.
Peer
)
p
.
AddAddress
(
addrs
[
i
])
sk
,
pk
,
err
:=
ci
.
GenerateKeyPair
(
ci
.
RSA
,
256
)
sk
,
pk
,
err
:=
ci
.
GenerateKeyPair
(
ci
.
RSA
,
512
)
if
err
!=
nil
{
panic
(
err
)
}
...
...
@@ -61,7 +61,7 @@ func setupDHTS(n int, t *testing.T) ([]*ma.Multiaddr, []*peer.Peer, []*IpfsDHT)
func
makePeer
(
addr
*
ma
.
Multiaddr
)
*
peer
.
Peer
{
p
:=
new
(
peer
.
Peer
)
p
.
AddAddress
(
addr
)
sk
,
pk
,
err
:=
ci
.
GenerateKeyPair
(
ci
.
RSA
,
256
)
sk
,
pk
,
err
:=
ci
.
GenerateKeyPair
(
ci
.
RSA
,
512
)
if
err
!=
nil
{
panic
(
err
)
}
...
...
routing/dht/ext_test.go
View file @
1fa7c07d
...
...
@@ -189,7 +189,6 @@ func TestNotFound(t *testing.T) {
// Reply with random peers to every message
fn
.
AddHandler
(
func
(
mes
*
swarm
.
Message
)
*
swarm
.
Message
{
t
.
Log
(
"Handling message..."
)
pmes
:=
new
(
PBDHTMessage
)
err
:=
proto
.
Unmarshal
(
mes
.
Data
,
pmes
)
if
err
!=
nil
{
...
...
@@ -252,7 +251,6 @@ func TestLessThanKResponses(t *testing.T) {
// Reply with random peers to every message
fn
.
AddHandler
(
func
(
mes
*
swarm
.
Message
)
*
swarm
.
Message
{
t
.
Log
(
"Handling message..."
)
pmes
:=
new
(
PBDHTMessage
)
err
:=
proto
.
Unmarshal
(
mes
.
Data
,
pmes
)
if
err
!=
nil
{
...
...
swarm/conn.go
View file @
1fa7c07d
...
...
@@ -25,6 +25,8 @@ type Conn struct {
Closed
chan
bool
Outgoing
*
msgio
.
Chan
Incoming
*
msgio
.
Chan
secIn
chan
[]
byte
secOut
chan
[]
byte
}
// ConnMap maps Keys (Peer.IDs) to Connections.
...
...
swarm/swarm.go
View file @
1fa7c07d
...
...
@@ -172,7 +172,7 @@ func (s *Swarm) handleNewConn(nconn net.Conn) {
}
newConnChans
(
conn
)
_
,
_
,
err
:=
ident
.
Handshake
(
s
.
local
,
p
,
conn
.
Incoming
.
MsgChan
,
conn
.
Outgoing
.
MsgChan
)
sin
,
sout
,
err
:=
ident
.
Handshake
(
s
.
local
,
p
,
conn
.
Incoming
.
MsgChan
,
conn
.
Outgoing
.
MsgChan
)
if
err
!=
nil
{
u
.
PErr
(
"%v
\n
"
,
err
.
Error
())
conn
.
Close
()
...
...
@@ -180,7 +180,7 @@ func (s *Swarm) handleNewConn(nconn net.Conn) {
}
// Get address to contact remote peer from
addr
:=
<-
conn
.
Incoming
.
MsgCha
n
addr
:=
<-
si
n
maddr
,
err
:=
ma
.
NewMultiaddr
(
string
(
addr
))
if
err
!=
nil
{
u
.
PErr
(
"Got invalid address from peer."
)
...
...
@@ -189,6 +189,9 @@ func (s *Swarm) handleNewConn(nconn net.Conn) {
}
p
.
AddAddress
(
maddr
)
conn
.
secIn
=
sin
conn
.
secOut
=
sout
err
=
s
.
StartConn
(
conn
)
if
err
!=
nil
{
s
.
Error
(
err
)
...
...
@@ -295,7 +298,7 @@ func (s *Swarm) fanOut() {
}
// queue it in the connection's buffer
conn
.
Out
going
.
MsgChan
<-
msg
.
Data
conn
.
sec
Out
<-
msg
.
Data
}
}
}
...
...
@@ -313,7 +316,7 @@ func (s *Swarm) fanIn(conn *Conn) {
case
<-
conn
.
Closed
:
goto
out
case
data
,
ok
:=
<-
conn
.
Incoming
.
MsgCha
n
:
case
data
,
ok
:=
<-
conn
.
secI
n
:
if
!
ok
{
e
:=
fmt
.
Errorf
(
"Error retrieving from conn: %v"
,
conn
.
Peer
.
Key
()
.
Pretty
())
s
.
Chan
.
Errors
<-
e
...
...
@@ -424,7 +427,7 @@ func (s *Swarm) GetConnection(id peer.ID, addr *ma.Multiaddr) (*peer.Peer, error
// Handle performing a handshake on a new connection and ensuring proper forward communication
func
(
s
*
Swarm
)
handleDialedCon
(
conn
*
Conn
)
error
{
_
,
_
,
err
:=
ident
.
Handshake
(
s
.
local
,
conn
.
Peer
,
conn
.
Incoming
.
MsgChan
,
conn
.
Outgoing
.
MsgChan
)
sin
,
sout
,
err
:=
ident
.
Handshake
(
s
.
local
,
conn
.
Peer
,
conn
.
Incoming
.
MsgChan
,
conn
.
Outgoing
.
MsgChan
)
if
err
!=
nil
{
return
err
}
...
...
@@ -433,10 +436,13 @@ func (s *Swarm) handleDialedCon(conn *Conn) error {
myaddr
:=
s
.
local
.
NetAddress
(
"tcp"
)
mastr
,
err
:=
myaddr
.
String
()
if
err
!=
nil
{
errors
.
New
(
"No local address to send to peer."
)
return
errors
.
New
(
"No local address to send to peer."
)
}
conn
.
Outgoing
.
MsgChan
<-
[]
byte
(
mastr
)
sout
<-
[]
byte
(
mastr
)
conn
.
secIn
=
sin
conn
.
secOut
=
sout
s
.
StartConn
(
conn
)
...
...
swarm/swarm_test.go
View file @
1fa7c07d
...
...
@@ -89,6 +89,10 @@ func TestSwarm(t *testing.T) {
t
.
Fatal
(
"error swarm dialing to peer"
,
err
)
}
//Since we arent doing a handshake, set up 'secure' channels
conn
.
secIn
=
conn
.
Incoming
.
MsgChan
conn
.
secOut
=
conn
.
Outgoing
.
MsgChan
swarm
.
StartConn
(
conn
)
// ok done, add it.
peers
=
append
(
peers
,
peer
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment