Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Peer is Dead. Long live the ID #466

Merged
merged 38 commits into from
Dec 23, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
cc7a869
threadsafe SeededRand
jbenet Dec 20, 2014
ec96a0b
util: fractional context
jbenet Dec 21, 2014
d399a93
peer/queue/sync: remove buffering
jbenet Dec 22, 2014
c84a714
peer change: peer.Peer -> peer.ID
jbenet Dec 19, 2014
10bb354
fix: the docker-test's make task
Dec 22, 2014
c2b21e4
routing/mock test: kill leaked goroutine
jbenet Dec 22, 2014
d996189
net/id_test: refactor tests into own func
jbenet Dec 23, 2014
4fe1dd9
net: have an explicit IdentifyConn on dial
jbenet Dec 23, 2014
497297b
net/mocknet: fixed listenaddrs (misrepresenting)
jbenet Dec 23, 2014
87c4fb2
Makefiles: build the test docker img
jbenet Dec 23, 2014
a10fb7a
core: set local listening addresses
jbenet Dec 23, 2014
2c95cb5
dht: bit nicer logging
jbenet Dec 23, 2014
4c13b95
dockertest script to run the test on any img
jbenet Dec 23, 2014
7952d95
added bootstrap logging
jbenet Dec 18, 2014
4d9f1f0
net: Connectedness bugfix
jbenet Dec 18, 2014
8b4c7cf
peerstream updated (data race)
jbenet Dec 18, 2014
b61b281
net/conns better printing of connections
jbenet Dec 18, 2014
d5789de
test(docker/network) disable color in daemon logs
Dec 18, 2014
b19a931
remote low SnR debug statement
Dec 18, 2014
e3f8f8c
rm low SnR debug statement
Dec 18, 2014
06d4df2
misc naming
Dec 19, 2014
3f9c126
fix: data race in test
Dec 19, 2014
0dbd86c
connectedness test timing
jbenet Dec 22, 2014
64a4abc
listen addresses: add Interface addresses
jbenet Dec 23, 2014
a7eb52a
dht: helpful debugging for no closer peers
jbenet Dec 23, 2014
d970f53
bitswap: network interface changed
jbenet Dec 23, 2014
55c8f8f
Revert "bitswap: network interface changed"
Dec 23, 2014
d0d220f
fix(bitswap) always dial
Dec 23, 2014
fb75184
fix(bitswap) always use prvivate `send` method to send
Dec 23, 2014
4ab4da7
style(bitswap) rename
Dec 23, 2014
a225568
style(bitswap) public methods at top
Dec 23, 2014
60f3a87
feat(bitswap/network) expose peerstore
Dec 23, 2014
070b633
style(bitswap) rename to network
Dec 23, 2014
c629464
fix(bitswap) always add addresses
Dec 23, 2014
27dc959
refactor(bitswap) bitswap.Network now abstracts ipfs.Network + ipfs.R…
Dec 23, 2014
c34132e
refactor(bitswap) change PeerInfo to ID in bitswap package
Dec 23, 2014
bd45adf
chore(bitswap) remove Peerstore() methods from bitswap.Network interface
Dec 23, 2014
a5018fc
net/mock: interface addresses
jbenet Dec 23, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ test: test_go test_sharness
test_expensive: test_go_expensive test_sharness_expensive

test_docker:
cd ./src/github.com/jbenet/go-ipfs
docker build -t zaqwsx_ipfs-test-img .
cd dockertest/ && make

test_go:
Expand Down
1 change: 0 additions & 1 deletion blockservice/blockservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func New(bs blockstore.Blockstore, rem exchange.Interface) (*BlockService, error
// TODO pass a context into this if the remote.HasBlock is going to remain here.
func (s *BlockService) AddBlock(b *blocks.Block) (u.Key, error) {
k := b.Key()
log.Debugf("blockservice: storing [%s] in datastore", k)
err := s.Blockstore.Put(b)
if err != nil {
return k, err
Expand Down
5 changes: 2 additions & 3 deletions blockservice/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import (

// Mocks returns |n| connected mock Blockservices
func Mocks(t *testing.T, n int) []*BlockService {
net := tn.VirtualNetwork(delay.Fixed(0))
rs := mockrouting.NewServer()
sg := bitswap.NewSessionGenerator(net, rs)
net := tn.VirtualNetwork(mockrouting.NewServer(), delay.Fixed(0))
sg := bitswap.NewSessionGenerator(net)

instances := sg.Instances(n)

Expand Down
2 changes: 1 addition & 1 deletion cmd/ipfs/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func identityConfig(nbits int) (config.Identity, error) {
}
ident.PrivKey = base64.StdEncoding.EncodeToString(skbytes)

id, err := peer.IDFromPubKey(pk)
id, err := peer.IDFromPublicKey(pk)
if err != nil {
return ident, err
}
Expand Down
25 changes: 15 additions & 10 deletions cmd/seccat/seccat.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,24 +109,28 @@ func main() {
}
}

func setupPeer(a args) (peer.Peer, peer.Peerstore, error) {
func setupPeer(a args) (peer.ID, peer.Peerstore, error) {
if a.keybits < 1024 {
return nil, nil, errors.New("Bitsize less than 1024 is considered unsafe.")
return "", nil, errors.New("Bitsize less than 1024 is considered unsafe.")
}

out("generating key pair...")
sk, pk, err := ci.GenerateKeyPair(ci.RSA, a.keybits)
if err != nil {
return nil, nil, err
return "", nil, err
}

ps := peer.NewPeerstore()
peer, err := ps.WithKeyPair(sk, pk)
p, err := peer.IDFromPublicKey(pk)
if err != nil {
return nil, nil, err
return "", nil, err
}
out("local peer id: %s", peer.ID())
return peer, ps, nil

ps := peer.NewPeerstore()
ps.AddPrivKey(p, sk)
ps.AddPubKey(p, pk)

out("local peer id: %s", p)
return p, ps, nil
}

func connect(args args) error {
Expand All @@ -149,12 +153,13 @@ func connect(args args) error {
rwc := &logRW{n: "conn", rw: conn}

// OK, let's setup the channel.
sg := secio.SessionGenerator{Local: p, Peerstore: ps}
sk := ps.PrivKey(p)
sg := secio.SessionGenerator{LocalID: p, PrivateKey: sk}
sess, err := sg.NewSession(nil, rwc)
if err != nil {
return err
}
out("remote peer id: %s", sess.RemotePeer().ID())
out("remote peer id: %s", sess.RemotePeer())
netcat(sess.ReadWriter().(io.ReadWriteCloser))
return nil
}
Expand Down
7 changes: 3 additions & 4 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
package config

import (
"crypto"
"crypto/x509"
"encoding/base64"
"os"
"path/filepath"

ic "github.com/jbenet/go-ipfs/crypto"
u "github.com/jbenet/go-ipfs/util"
"github.com/jbenet/go-ipfs/util/debugerror"
)
Expand Down Expand Up @@ -132,15 +131,15 @@ func Filename(configroot string) (string, error) {
}

// DecodePrivateKey is a helper to decode the users PrivateKey
func (i *Identity) DecodePrivateKey(passphrase string) (crypto.PrivateKey, error) {
func (i *Identity) DecodePrivateKey(passphrase string) (ic.PrivKey, error) {
pkb, err := base64.StdEncoding.DecodeString(i.PrivKey)
if err != nil {
return nil, err
}

// currently storing key unencrypted. in the future we need to encrypt it.
// TODO(security)
return x509.ParsePKCS1PrivateKey(pkb)
return ic.UnmarshalPrivateKey(pkb)
}

// Load reads given file and returns the read config, or error.
Expand Down
Loading