Example #1
0
File: nat.go Project: rht/ipget
	ma "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
	manet "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net"

	nat "github.com/noffle/ipget/Godeps/_workspace/src/github.com/fd/go-nat"
	notifier "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/thirdparty/notifier"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
	goprocess "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/goprocess"
	periodic "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/goprocess/periodic"
)

var (
	// ErrNoMapping signals no mapping exists for an address
	ErrNoMapping = errors.New("mapping not established")
)

var log = logging.Logger("nat")

// MappingDuration is a default port mapping duration.
// Port mappings are renewed every (MappingDuration / 3)
const MappingDuration = time.Second * 60

// CacheTime is the time a mapping will cache an external address for
const CacheTime = time.Second * 15

// DiscoverNAT looks for a NAT device in the network and
// returns an object that can manage port mappings.
func DiscoverNAT() *NAT {
	nat, err := nat.DiscoverGateway()
	if err != nil {
		log.Debug("DiscoverGateway error:", err)
		return nil
Example #2
0
package ipfsaddr

import (
	"errors"
	"strings"

	ma "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"

	peer "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
)

var log = logging.Logger("ipfsaddr")

// ErrInvalidAddr signals an address is not a valid ipfs address.
var ErrInvalidAddr = errors.New("invalid ipfs address")

type IPFSAddr interface {
	ID() peer.ID
	Multiaddr() ma.Multiaddr
	Transport() ma.Multiaddr
	String() string
	Equal(b interface{}) bool
}

type ipfsAddr struct {
	ma ma.Multiaddr
	id peer.ID
}

func (a ipfsAddr) ID() peer.ID {
Example #3
0
File: config.go Project: rht/ipget
// package config implements the ipfs config file datastructures and utilities.
package config

import (
	"bytes"
	"encoding/json"
	"fmt"
	"os"
	"path/filepath"
	"strings"

	u "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/util"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
)

var log = logging.Logger("config")

// Config is used to load IPFS config files.
type Config struct {
	Identity         Identity              // local node's peer identity
	Datastore        Datastore             // local node's storage
	Addresses        Addresses             // local node's addresses
	Mounts           Mounts                // local node's mount points
	Version          Version               // local node's version management
	Discovery        Discovery             // local node's discovery mechanisms
	Ipns             Ipns                  // Ipns settings
	Bootstrap        []string              // local nodes's bootstrap peer addresses
	Tour             Tour                  // local node's tour position
	Gateway          Gateway               // local node's gateway server options
	SupernodeRouting SupernodeClientConfig // local node's routing servers (if SupernodeRouting enabled)
	API              API                   // local node's API settings
Example #4
0
File: gc.go Project: rht/ipget
package corerepo

import (
	key "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/blocks/key"
	"github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/core"
	context "github.com/noffle/ipget/Godeps/_workspace/src/golang.org/x/net/context"

	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
)

var log = logging.Logger("corerepo")

type KeyRemoved struct {
	Key key.Key
}

func GarbageCollect(n *core.IpfsNode, ctx context.Context) error {
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel() // in case error occurs during operation
	keychan, err := n.Blockstore.AllKeysChan(ctx)
	if err != nil {
		return err
	}
	for k := range keychan { // rely on AllKeysChan to close chan
		if !n.Pinning.IsPinned(k) {
			err := n.Blockstore.DeleteBlock(k)
			if err != nil {
				return err
			}
		}
	}
Example #5
0
	"time"

	proto "github.com/noffle/ipget/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
	key "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/blocks/key"
	peer "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer"
	routing "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing"
	dhtpb "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing/dht/pb"
	u "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/util"
	"github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/util/testutil"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
	ds "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-datastore"
	ma "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
	context "github.com/noffle/ipget/Godeps/_workspace/src/golang.org/x/net/context"
)

var log = logging.Logger("mockrouter")

type client struct {
	datastore ds.Datastore
	server    server
	peer      testutil.Identity
}

// FIXME(brian): is this method meant to simulate putting a value into the network?
func (c *client) PutValue(ctx context.Context, key key.Key, val []byte) error {
	log.Debugf("PutValue: %s", key)
	rec := new(dhtpb.Record)
	rec.Value = val
	rec.Key = proto.String(string(key))
	rec.TimeReceived = proto.String(u.FormatRFC3339(time.Now()))
	data, err := proto.Marshal(rec)
Example #6
0
File: diag.go Project: rht/ipget
	"sync"
	"time"

	ggio "github.com/noffle/ipget/Godeps/_workspace/src/github.com/gogo/protobuf/io"
	proto "github.com/noffle/ipget/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
	pb "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/diagnostics/pb"
	host "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/host"
	inet "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/net"
	peer "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer"
	protocol "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/protocol"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
	ctxio "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-context/io"
	context "github.com/noffle/ipget/Godeps/_workspace/src/golang.org/x/net/context"
)

var log = logging.Logger("diagnostics")

// ProtocolDiag is the diagnostics protocol.ID
var ProtocolDiag protocol.ID = "/ipfs/diagnostics"

var ErrAlreadyRunning = errors.New("diagnostic with that ID already running")

const ResponseTimeout = time.Second * 10
const HopTimeoutDecrement = time.Second * 2

// Diagnostics is a net service that manages requesting and responding to diagnostic
// requests
type Diagnostics struct {
	host host.Host
	self peer.ID
Example #7
0
File: key.go Project: rht/ipget
import (
	"bytes"
	"io"
	"testing"

	u "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/util"
	testutil "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/util/testutil"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"

	ic "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/crypto"
	peer "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer"

	ma "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
)

var log = logging.Logger("boguskey")

// TestBogusPrivateKey is a key used for testing (to avoid expensive keygen)
type TestBogusPrivateKey []byte

// TestBogusPublicKey is a key used for testing (to avoid expensive keygen)
type TestBogusPublicKey []byte

func (pk TestBogusPublicKey) Verify(data, sig []byte) (bool, error) {
	log.Errorf("TestBogusPublicKey.Verify -- this better be a test!")
	return bytes.Equal(data, reverse(sig)), nil
}

func (pk TestBogusPublicKey) Bytes() ([]byte, error) {
	return []byte(pk), nil
}
Example #8
0
File: peer.go Project: rht/ipget
import (
	"encoding/hex"
	"encoding/json"
	"fmt"
	"strings"

	b58 "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-base58"
	ma "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
	mh "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-multihash"

	ic "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/crypto"
	u "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/util"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
)

var log = logging.Logger("peer")

// ID represents the identity of a peer.
type ID string

// Pretty returns a b58-encoded string of the ID
func (id ID) Pretty() string {
	return IDB58Encode(id)
}

func (id ID) Loggable() map[string]interface{} {
	return map[string]interface{}{
		"peerID": id.Pretty(),
	}
}
Example #9
0
File: repub.go Project: rht/ipget
	peer "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer"
	path "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/path"
	"github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing"
	dhtpb "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing/dht/pb"

	proto "github.com/noffle/ipget/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
	ds "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-datastore"
	goprocess "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/goprocess"
	gpctx "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/goprocess/context"
	context "github.com/noffle/ipget/Godeps/_workspace/src/golang.org/x/net/context"
)

var errNoEntry = errors.New("no previous entry")

var log = logging.Logger("ipns-repub")

var DefaultRebroadcastInterval = time.Hour * 4

const DefaultRecordLifetime = time.Hour * 24

type Republisher struct {
	r  routing.IpfsRouting
	ds ds.Datastore
	ps peer.Peerstore

	Interval time.Duration

	// how long records that are republished should be valid for
	RecordLifetime time.Duration
Example #10
0
File: conn.go Project: rht/ipget
	"net"
	"time"

	ic "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/crypto"
	peer "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer"
	u "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/util"
	lgbl "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/util/eventlog/loggables"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
	msgio "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-msgio"
	mpool "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-msgio/mpool"
	ma "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
	manet "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net"
	context "github.com/noffle/ipget/Godeps/_workspace/src/golang.org/x/net/context"
)

var log = logging.Logger("conn")

// ReleaseBuffer puts the given byte array back into the buffer pool,
// first verifying that it is the correct size
func ReleaseBuffer(b []byte) {
	log.Debugf("Releasing buffer! (cap,size = %d, %d)", cap(b), len(b))
	mpool.ByteSlicePool.Put(uint32(cap(b)), b)
}

// singleConn represents a single connection to another Peer (IPFS Node).
type singleConn struct {
	local  peer.ID
	remote peer.ID
	maconn manet.Conn
	msgrw  msgio.ReadWriteCloser
	event  io.Closer
Example #11
0
File: offline.go Project: rht/ipget
	"errors"
	"time"

	proto "github.com/noffle/ipget/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
	key "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/blocks/key"
	ci "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/crypto"
	"github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer"
	routing "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing"
	pb "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing/dht/pb"
	record "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing/record"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
	ds "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-datastore"
	context "github.com/noffle/ipget/Godeps/_workspace/src/golang.org/x/net/context"
)

var log = logging.Logger("offlinerouting")

var ErrOffline = errors.New("routing system in offline mode")

func NewOfflineRouter(dstore ds.Datastore, privkey ci.PrivKey) routing.IpfsRouting {
	return &offlineRouting{
		datastore: dstore,
		sk:        privkey,
	}
}

// offlineRouting implements the IpfsRouting interface,
// but only provides the capability to Put and Get signed dht
// records to and from the local datastore.
type offlineRouting struct {
	datastore ds.Datastore
Example #12
0
	ggio "github.com/noffle/ipget/Godeps/_workspace/src/github.com/gogo/protobuf/io"
	context "github.com/noffle/ipget/Godeps/_workspace/src/golang.org/x/net/context"

	key "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/blocks/key"
	host "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/host"
	inet "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/net"
	peer "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer"
	dhtpb "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing/dht/pb"
	kbucket "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing/kbucket"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
)

const ProtocolSNR = "/ipfs/supernoderouting"

var log = logging.Logger("supernode/proxy")

type Proxy interface {
	Bootstrap(context.Context) error
	HandleStream(inet.Stream)
	SendMessage(ctx context.Context, m *dhtpb.Message) error
	SendRequest(ctx context.Context, m *dhtpb.Message) (*dhtpb.Message, error)
}

type standard struct {
	Host host.Host

	remoteInfos []peer.PeerInfo // addr required for bootstrapping
	remoteIDs   []peer.ID       // []ID is required for each req. here, cached for performance.
}
Example #13
0
File: system.go Project: rht/ipget
	"sync"
	"time"

	key "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/blocks/key"
	dag "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/merkledag"
	namesys "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/namesys"
	ci "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/crypto"
	path "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/path"
	pin "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/pin"
	ft "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/unixfs"

	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
	context "github.com/noffle/ipget/Godeps/_workspace/src/golang.org/x/net/context"
)

var log = logging.Logger("ipnsfs")

var ErrIsDirectory = errors.New("error: is a directory")

// Filesystem is the writeable fuse filesystem structure
type Filesystem struct {
	ctx context.Context

	dserv dag.DAGService

	nsys namesys.NameSystem

	resolver *path.Resolver

	pins pin.Pinner
Example #14
0
	trickle "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/importer/trickle"
	mdag "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/merkledag"
	pin "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/pin"
	ft "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/unixfs"
	uio "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/unixfs/io"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
)

var ErrSeekFail = errors.New("failed to seek properly")
var ErrSeekEndNotImpl = errors.New("SEEK_END currently not implemented")
var ErrUnrecognizedWhence = errors.New("unrecognized whence")

// 2MB
var writebufferSize = 1 << 21

var log = logging.Logger("dagio")

// DagModifier is the only struct licensed and able to correctly
// perform surgery on a DAG 'file'
// Dear god, please rename this to something more pleasant
type DagModifier struct {
	dagserv mdag.DAGService
	curNode *mdag.Node
	mp      pin.ManualPinner

	splitter   chunk.SplitterGen
	ctx        context.Context
	readCancel func()

	writeStart uint64
	curWrOff   uint64
Example #15
0
File: routing.go Project: rht/ipget
import (
	"fmt"

	proto "github.com/noffle/ipget/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
	mh "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-multihash"
	"github.com/noffle/ipget/Godeps/_workspace/src/golang.org/x/net/context"

	key "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/blocks/key"
	pb "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/namesys/pb"
	path "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/path"
	routing "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
)

var log = logging.Logger("namesys")

// routingResolver implements NSResolver for the main IPFS SFS-like naming
type routingResolver struct {
	routing routing.IpfsRouting
}

// NewRoutingResolver constructs a name resolver using the IPFS Routing system
// to implement SFS-like naming on top.
func NewRoutingResolver(route routing.IpfsRouting) Resolver {
	if route == nil {
		panic("attempt to create resolver with nil routing system")
	}

	return &routingResolver{routing: route}
}
Example #16
0
File: addr.go Project: rht/ipget
package addrutil

import (
	"fmt"

	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"

	ma "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
	manet "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net"
	context "github.com/noffle/ipget/Godeps/_workspace/src/golang.org/x/net/context"
)

var log = logging.Logger("p2p/net/swarm/addr")

// SupportedTransportStrings is the list of supported transports for the swarm.
// These are strings of encapsulated multiaddr protocols. E.g.:
//   /ip4/tcp
var SupportedTransportStrings = []string{
	"/ip4/tcp",
	"/ip6/tcp",
	// "/ip4/udp/utp", disabled because the lib is broken
	// "/ip6/udp/utp", disabled because the lib is broken
	// "/ip4/udp/udt", disabled because the lib doesnt work on arm
	// "/ip6/udp/udt", disabled because the lib doesnt work on arm
}

// SupportedTransportProtocols is the list of supported transports for the swarm.
// These are []ma.Protocol lists. Populated at runtime from SupportedTransportStrings
var SupportedTransportProtocols = [][]ma.Protocol{}

func init() {
Example #17
0
File: bitswap.go Project: rht/ipget
	key "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/blocks/key"
	exchange "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/exchange"
	decision "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/exchange/bitswap/decision"
	bsmsg "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/exchange/bitswap/message"
	bsnet "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/exchange/bitswap/network"
	notifications "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/exchange/bitswap/notifications"
	wantlist "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/exchange/bitswap/wantlist"
	peer "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer"
	"github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/thirdparty/delay"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
	process "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/goprocess"
	procctx "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/goprocess/context"
	context "github.com/noffle/ipget/Godeps/_workspace/src/golang.org/x/net/context"
)

var log = logging.Logger("bitswap")

const (
	// maxProvidersPerRequest specifies the maximum number of providers desired
	// from the network. This value is specified because the network streams
	// results.
	// TODO: if a 'non-nice' strategy is implemented, consider increasing this value
	maxProvidersPerRequest = 3
	providerRequestTimeout = time.Second * 10
	hasBlockTimeout        = time.Second * 15
	provideTimeout         = time.Second * 15
	sizeBatchRequestChan   = 32
	// kMaxPriority is the max priority as defined by the bitswap protocol
	kMaxPriority = math.MaxInt32

	HasBlockBufferSize    = 256
Example #18
0
package path

import (
	"errors"
	"fmt"
	"time"

	mh "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-multihash"
	"github.com/noffle/ipget/Godeps/_workspace/src/golang.org/x/net/context"

	key "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/blocks/key"
	merkledag "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/merkledag"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
)

var log = logging.Logger("path")

// Paths after a protocol must contain at least one component
var ErrNoComponents = errors.New(
	"path must contain at least one component")

// ErrNoLink is returned when a link is not found in a path
type ErrNoLink struct {
	name string
	node mh.Multihash
}

func (e ErrNoLink) Error() string {
	return fmt.Sprintf("no link named %q under %s", e.name, e.node.B58String())
}
Example #19
0
File: add.go Project: rht/ipget
	"os"
	gopath "path"

	context "github.com/noffle/ipget/Godeps/_workspace/src/golang.org/x/net/context"

	"github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/commands/files"
	core "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/core"
	importer "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/importer"
	chunk "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/importer/chunk"
	merkledag "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/merkledag"
	"github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/pin"
	unixfs "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/unixfs"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
)

var log = logging.Logger("coreunix")

// Add builds a merkledag from the a reader, pinning all objects to the local
// datastore. Returns a key representing the root node.
func Add(n *core.IpfsNode, r io.Reader) (string, error) {
	// TODO more attractive function signature importer.BuildDagFromReader

	dagNode, err := importer.BuildDagFromReader(
		n.DAG,
		chunk.NewSizeSplitter(r, chunk.DefaultBlockSize),
		importer.BasicPinnerCB(n.Pinning.GetManual()),
	)
	if err != nil {
		return "", err
	}
	k, err := dagNode.Key()
Example #20
0
File: ping.go Project: rht/ipget
import (
	"bytes"
	"errors"
	"io"
	"time"

	context "github.com/noffle/ipget/Godeps/_workspace/src/golang.org/x/net/context"

	host "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/host"
	inet "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/net"
	peer "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer"
	u "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/util"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
)

var log = logging.Logger("ping")

const PingSize = 32

const ID = "/ipfs/ping"

type PingService struct {
	Host host.Host
}

func NewPingService(h host.Host) *PingService {
	ps := &PingService{h}
	h.SetStreamHandler(ID, ps.PingHandler)
	return ps
}
Example #21
0
import (
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"os"
	"path/filepath"

	"github.com/facebookgo/atomicfile"
	"github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/repo/config"
	"github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/util"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
)

var log = logging.Logger("fsrepo")

// ReadConfigFile reads the config from `filename` into `cfg`.
func ReadConfigFile(filename string, cfg interface{}) error {
	f, err := os.Open(filename)
	if err != nil {
		return err
	}
	defer f.Close()
	if err := json.NewDecoder(f).Decode(cfg); err != nil {
		return fmt.Errorf("Failure to decode config: %s", err)
	}
	return nil
}

// WriteConfigFile writes the config from `cfg` into `filename`.
Example #22
0
File: table.go Project: rht/ipget
// package kbucket implements a kademlia 'k-bucket' routing table.
package kbucket

import (
	"fmt"
	"sort"
	"sync"
	"time"

	peer "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
)

var log = logging.Logger("table")

// RoutingTable defines the routing table.
type RoutingTable struct {

	// ID of the local peer
	local ID

	// Blanket lock, refine later for better performance
	tabLock sync.RWMutex

	// latency metrics
	metrics peer.Metrics

	// Maximum acceptable latency for peers in this cluster
	maxLatency time.Duration

	// kBuckets define all the fingers to other nodes.
Example #23
0
File: mdns.go Project: rht/ipget
	"io/ioutil"
	golog "log"
	"net"
	"sync"
	"time"

	"github.com/noffle/ipget/Godeps/_workspace/src/github.com/cryptix/mdns"
	ma "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
	manet "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net"

	"github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/host"
	"github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
)

var log = logging.Logger("mdns")

const ServiceTag = "discovery.ipfs.io"

type Service interface {
	io.Closer
	RegisterNotifee(Notifee)
	UnregisterNotifee(Notifee)
}

type Notifee interface {
	HandlePeerFound(peer.PeerInfo)
}

type mdnsService struct {
	server  *mdns.Server
Example #24
0
File: id.go Project: rht/ipget
	ggio "github.com/noffle/ipget/Godeps/_workspace/src/github.com/gogo/protobuf/io"
	ma "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
	context "github.com/noffle/ipget/Godeps/_workspace/src/golang.org/x/net/context"

	mstream "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/metrics/stream"
	host "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/host"
	inet "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/net"
	peer "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer"
	protocol "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/protocol"
	pb "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/protocol/identify/pb"
	config "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/repo/config"
	lgbl "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/util/eventlog/loggables"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
)

var log = logging.Logger("net/identify")

// ID is the protocol.ID of the Identify Service.
const ID protocol.ID = "/ipfs/identify"

// IpfsVersion holds the current protocol version for a client running this code
// TODO(jbenet): fix the versioning mess.
const IpfsVersion = "ipfs/0.1.0"
const ClientVersion = "go-ipfs/" + config.CurrentVersionNumber

// IDService is a structure that implements ProtocolIdentify.
// It is a trivial service that gives the other peer some
// useful information about the local peer. A sort of hello.
//
// The IDService sends:
//  * Our IPFS Protocol Version
Example #25
0
File: dht.go Project: rht/ipget
	peer "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer"
	protocol "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/protocol"
	routing "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing"
	pb "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing/dht/pb"
	kb "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing/kbucket"
	record "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/routing/record"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"

	proto "github.com/noffle/ipget/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
	ds "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-datastore"
	goprocess "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/goprocess"
	goprocessctx "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/goprocess/context"
	context "github.com/noffle/ipget/Godeps/_workspace/src/golang.org/x/net/context"
)

var log = logging.Logger("dht")

var ProtocolDHT protocol.ID = "/ipfs/dht"

// NumBootstrapQueries defines the number of random dht queries to do to
// collect members of the routing table.
const NumBootstrapQueries = 5

// TODO. SEE https://github.com/jbenet/node-ipfs/blob/master/submodules/ipfs-dht/index.js

// IpfsDHT is an implementation of Kademlia with Coral and S/Kademlia modifications.
// It is used to implement the base IpfsRouting module.
type IpfsDHT struct {
	host      host.Host      // the network services we need
	self      peer.ID        // Local peer (yourself)
	peerstore peer.Peerstore // Peer Registry
Example #26
0
package corehttp

import (
	"fmt"
	"net"
	"net/http"
	"time"

	core "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/core"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
	ma "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
	manet "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net"
	"github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/goprocess"
)

var log = logging.Logger("core/server")

// ServeOption registers any HTTP handlers it provides on the given mux.
// It returns the mux to expose to future options, which may be a new mux if it
// is interested in mediating requests to future options, or the same mux
// initially passed in if not.
type ServeOption func(*core.IpfsNode, net.Listener, *http.ServeMux) (*http.ServeMux, error)

// makeHandler turns a list of ServeOptions into a http.Handler that implements
// all of the given options, in order.
func makeHandler(n *core.IpfsNode, l net.Listener, options ...ServeOption) (http.Handler, error) {
	topMux := http.NewServeMux()
	mux := topMux
	for _, option := range options {
		var err error
		mux, err = option(n, l, mux)
Example #27
0
File: root.go Project: rht/ipget
package commands

import (
	"io"
	"strings"

	cmds "github.com/ipfs/go-ipfs/commands"
	unixfs "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/core/commands/unixfs"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
)

var log = logging.Logger("core/commands")

type TestOutput struct {
	Foo string
	Bar int
}

const (
	ApiOption = "api"
)

var Root = &cmds.Command{
	Helptext: cmds.HelpText{
		Tagline: "global p2p merkle-dag filesystem",
		Synopsis: `
ipfs [<flags>] <command> [<arg>] ...
`,
		ShortDescription: `
BASIC COMMANDS
Example #28
0
// package merkledag implements the ipfs Merkle DAG datastructures.
package merkledag

import (
	"fmt"
	"sync"

	blocks "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/blocks"
	key "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/blocks/key"
	bserv "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/blockservice"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
	"github.com/noffle/ipget/Godeps/_workspace/src/golang.org/x/net/context"
)

var log = logging.Logger("merkledag")
var ErrNotFound = fmt.Errorf("merkledag: not found")

// DAGService is an IPFS Merkle DAG service.
type DAGService interface {
	Add(*Node) (key.Key, error)
	AddRecursive(*Node) error
	Get(context.Context, key.Key) (*Node, error)
	Remove(*Node) error

	// GetDAG returns, in order, all the single leve child
	// nodes of the passed in node.
	GetDAG(context.Context, *Node) []NodeGetter
	GetNodes(context.Context, []key.Key) []NodeGetter

	Batch() *Batch
}
Example #29
0
	"errors"
	"fmt"
	"io"
	"sync"
	"time"

	ci "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/crypto"
	pb "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/crypto/secio/pb"
	peer "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/p2p/peer"
	u "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/util"
	logging "github.com/noffle/ipget/Godeps/_workspace/src/github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
	msgio "github.com/noffle/ipget/Godeps/_workspace/src/github.com/jbenet/go-msgio"
	context "github.com/noffle/ipget/Godeps/_workspace/src/golang.org/x/net/context"
)

var log = logging.Logger("secio")

// ErrUnsupportedKeyType is returned when a private key cast/type switch fails.
var ErrUnsupportedKeyType = errors.New("unsupported key type")

// ErrClosed signals the closing of a connection.
var ErrClosed = errors.New("connection closed")

// ErrEcho is returned when we're attempting to handshake with the same keys and nonces.
var ErrEcho = errors.New("same keys and nonces. one side talking to self.")

// HandshakeTimeout governs how long the handshake will be allowed to take place for.
// Making this number large means there could be many bogus connections waiting to
// timeout in flight. Typical handshakes take ~3RTTs, so it should be completed within
// seconds across a typical planet in the solar system.
var HandshakeTimeout = time.Second * 30
Example #30
0
File: engine.go Project: rht/ipget
// decision engine is given responsibility for all of the others, it can
// intelligently decide how to combine requests efficiently.
//
// Some examples of what would be possible:
//
// * when sending out the wantlists, include `cancel` requests
// * when handling `blockrequests`, include `sendwantlist` and `cancel` as appropriate
// * when handling `cancel`, if we recently received a wanted block from a
// 	 peer, include a partial wantlist that contains a few other high priority
//   blocks
//
// In a sense, if we treat the decision engine as a black box, it could do
// whatever it sees fit to produce desired outcomes (get wanted keys
// quickly, maintain good relationships with peers, etc).

var log = logging.Logger("engine")

const (
	// outboxChanBuffer must be 0 to prevent stale messages from being sent
	outboxChanBuffer = 0
)

// Envelope contains a message for a Peer
type Envelope struct {
	// Peer is the intended recipient
	Peer peer.ID

	// Block is the payload
	Block *blocks.Block

	// A callback to notify the decision queue that the task is complete