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

move go-libp2p-core here #1683

Merged
merged 213 commits into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from 212 commits
Commits
Show all changes
213 commits
Select commit Hold shift + click to select a range
0a9354a
Absorb go-libp2p abstractions and core types into this module (#1)
raulk May 22, 2019
d090163
absorb {crypto,peer} test utils. (#8)
raulk May 23, 2019
717e15f
fix duplicated import.
raulk May 23, 2019
6d13581
chore: cleanup address parsing
Stebalien May 31, 2019
f914c75
fix: handle empty addrs case
Stebalien May 31, 2019
5a976ee
feat(peer): implement AddrInfosFromP2pAddrs and SplitAddr
Stebalien May 31, 2019
b9f641d
Merge pull request #15 from libp2p/feat/addrinfos
Stebalien May 31, 2019
ebfb757
peerstore/protobook: support removing protocols. (#20)
raulk Jun 19, 2019
d962316
eventbus abstraction + initial events (#17)
whyrusleeping Jun 20, 2019
464d1e2
Add OpenCensus metrics registration functionality to core
bigs Jun 19, 2019
a237360
Merge pull request #19 from libp2p/feat/metrics-redux
Jun 20, 2019
d3e5c0c
eventbus interface changes (#22)
magik6k Jun 21, 2019
8483b62
Add license files (#24)
Jun 24, 2019
7888bb0
Replace bytes.Equal -> subtle.ConstantTimeCompare
bigs Jul 10, 2019
3257399
Return error rather than panic in GenerateEKeyPair
bigs Jul 10, 2019
7fd5c86
Remove support for blowfish
bigs Jul 10, 2019
9b5e158
Raise minimum bits required for RSA key to 2048
bigs Jul 10, 2019
4ff4dbe
update insecure transport to plaintext/2.0.0 (#37)
yusefnapora Jul 12, 2019
cc9f17d
Add env flag for allowing unsafe rsa keys in tests
bigs Jul 12, 2019
d1866f8
Use short-circuiting comparisons for public keys
bigs Jul 12, 2019
243249c
Merge pull request #32 from libp2p/bug/key-equality
Jul 12, 2019
a9b8c56
Add test for unknown elliptic curves
bigs Jul 12, 2019
566bfe9
Merge pull request #33 from libp2p/bug/curve-name
Jul 12, 2019
cfafedb
Revert "update insecure transport to plaintext/2.0.0 (#37)" (#38)
raulk Jul 14, 2019
21142a6
Add defualt case with meaningful panic
bigs Jul 17, 2019
1df1ff7
avoid duplicate randomly generated keys/peer-ids
Stebalien Jul 22, 2019
34c4b5b
Add compat check (#40)
Kubuxu Jul 25, 2019
5dd7382
Merge pull request #44 from libp2p/fix/43
Stebalien Jul 25, 2019
8dbcc5a
bring back plaintext 2.0.0 with new constructor (#42)
yusefnapora Jul 30, 2019
3cfa7ee
UNSAFE -> WEAK in RSA key environment variable
bigs Aug 1, 2019
b07ce71
Rename constant for weak RSA key environment variable
bigs Aug 1, 2019
8dda665
Merge pull request #34 from libp2p/bug/weak-rsa-keys
Aug 1, 2019
5915b53
fix: do not allocate when comparing keys
dignifiedquire Jun 28, 2019
e64c956
fixup: openssl
dignifiedquire Jun 28, 2019
c79f0a0
use equal method from openssl
dignifiedquire Jun 28, 2019
c8185ac
use a fallback basicEquals function everywhere
Stebalien Jun 28, 2019
707efc9
remove non-constant-time private key comparison
Stebalien Jun 29, 2019
9e14101
nit: simplify equality check
Stebalien Aug 1, 2019
b7e4f2f
Merge pull request #46 from libp2p/feat/cherry-pick-stabalize
Stebalien Aug 2, 2019
13e58e6
fix: use fallback comparison for ed25519 keys
Stebalien Aug 2, 2019
1be6b00
Add note about panic to KeyStretcher comments
bigs Aug 6, 2019
876a0fc
Add test for panic on unknown cipher type
bigs Aug 6, 2019
20123ca
Merge pull request #31 from libp2p/bug/remove-blowfish-support
Aug 6, 2019
4527fe0
Return error in Emit
bigs Jul 30, 2019
9d9ab90
Merge pull request #45 from libp2p/feat/event-bus-signature
Aug 6, 2019
e0f4801
Compare multihash `Code` to `IDENTITY` when extracting public key
ralexstokes Aug 14, 2019
b4df7c4
Merge pull request #50 from ralexstokes/use-clearer-multihash-code
Stebalien Aug 14, 2019
fa4a3a0
Get `remoteID` from pb message
mhchia Aug 23, 2019
8c4b2e6
Ensure all tests pass without weak RSA key flag
bigs Aug 28, 2019
8a46880
Merge pull request #55 from libp2p/bug/rsa-key-test-failure
Stebalien Aug 28, 2019
0601ec2
The docs seem to lie
JorikSchellekens Sep 4, 2019
d5faed8
adds ability to create keys from crypto.PrivateKey types
adam-hanna Sep 19, 2019
9f0b201
incorporates code review from @Stebalien
adam-hanna Sep 19, 2019
4eb22d0
fixes typo
adam-hanna Sep 19, 2019
3082b65
incorporates code review comments from @raulk; changes KeyPairFromKey…
adam-hanna Sep 21, 2019
a7bc619
crypto: use constant time compare when decoding private keys
Stebalien Sep 24, 2019
b2f4537
crypto: make the ECDSA receiver consistent
Stebalien Sep 24, 2019
4f475ba
crypto: use basicEquals for ECDSA
Stebalien Sep 24, 2019
146eec1
Merge pull request #60 from libp2p/fix/constant-time-compare
Stebalien Sep 25, 2019
234a74e
Merge pull request #48 from libp2p/fix/fallback-cmp
Stebalien Sep 27, 2019
5bc6981
Merge pull request #59 from adam-hanna/master
Stebalien Sep 30, 2019
5e9fc8e
Comment that KeyStretcher is pre-deprecation
Sep 30, 2019
1536536
Merge pull request #62 from libp2p/mgoelzer-keystretcher-comment
Stebalien Sep 30, 2019
c285b8a
feat: support encoding/decoding peer IDs as CIDs _in text_
Stebalien Jul 15, 2019
eba1a6b
fix(key size): forbid small openssl RSA keys
Stebalien Oct 21, 2019
9a215c1
Merge pull request #67 from libp2p/fix/openssl-min-key-size
Stebalien Oct 22, 2019
29b5574
chore(dep): update protobuf
Stebalien Oct 28, 2019
217276c
Merge pull request #69 from libp2p/chore/update-protobuf
Stebalien Oct 28, 2019
d7abb91
Add API to reset bandwidth counters
kpp Nov 1, 2019
611f243
Add a test for BandwidthCounter::Reset
kpp Nov 1, 2019
6e18148
fix(metrics): update go-flow-metrics and fix tests for upstream changes
Stebalien Nov 1, 2019
2796c0e
Merge pull request #71 from kpp/clear_bwc
Stebalien Nov 1, 2019
3431976
use varints for delimiting plaintext 2.0 msgs (#74)
yusefnapora Nov 12, 2019
a47189b
feat(metrics): add function to trim idle meters
Stebalien Nov 16, 2019
6f9af47
Merge pull request #75 from libp2p/feat/trim-idle
Stebalien Nov 16, 2019
5956c76
fix(plaintext): regenerate protobuf code
Stebalien Dec 2, 2019
3139867
Merge pull request #77 from libp2p/fix/re-generate-plaintext-pb
Stebalien Dec 2, 2019
2b468e9
docs(routing/query): document public query event interfaces
Stebalien Dec 6, 2019
c2b81ae
Merge pull request #56 from JorikSchellekens/patch-1
Stebalien Dec 7, 2019
4fe7924
Use standard library "crypto/ed25519"
xaionaro Jul 2, 2019
9e4f261
Merge pull request #88 from libp2p/fix/document-query-notifications
Stebalien Dec 7, 2019
bdeb1bf
Merge pull request #94 from libp2p/feat/std-ed25519
Stebalien Dec 7, 2019
51cf61a
Merge branch 'master' into feat/parse-cid-as-pid
lidel Dec 10, 2019
fe9fc6f
feat: support encoding/decoding peer IDs as CIDs in text (#41)
lidel Dec 10, 2019
f18983a
typo fix
Mikerah Dec 13, 2019
1996269
Merge pull request #100 from Mikerah/patch-1
Stebalien Dec 14, 2019
ca6e701
Merge pull request #52 from mhchia/patch-1
Stebalien Jan 11, 2020
628240f
Introduce routability and protocol events; cache unmarshalled RSA key…
raulk Jan 16, 2020
d1feb90
Signed envelopes & routing records (#73)
yusefnapora Feb 10, 2020
c713c0c
Use `PeerRecord` value instead of pointer in `EvtLocalPeerRecordUpdat…
yusefnapora Feb 10, 2020
e4de206
enable network to emit events on a bus
aarshkshah1992 Sep 13, 2019
3e40e55
changes as per review
aarshkshah1992 Feb 28, 2020
70837b0
remove network from the events
aarshkshah1992 Feb 28, 2020
143622d
peer connectedness event
aarshkshah1992 Feb 29, 2020
4adb7a6
docs change
aarshkshah1992 Mar 3, 2020
648a5c5
docs: uniform comment sentences
vasco-santos Mar 3, 2020
a9fc470
Merge pull request #124 from vasco-santos/docs/uniform
Stebalien Mar 3, 2020
105e5f2
feat: switch to a single routability event
Stebalien Mar 4, 2020
b1eeefc
rename routability -> reachability
Stebalien Mar 4, 2020
532eb83
Merge pull request #126 from libp2p/feat/single-routability-event
Stebalien Mar 5, 2020
878b651
add functions for converting libp2p keys to stdlib variants (#125)
vibhavp Mar 6, 2020
57708de
changes as per review
aarshkshah1992 Mar 6, 2020
defb415
changes as per raul's review
aarshkshah1992 Mar 6, 2020
a26ad00
Merge pull request #120 from libp2p/feat/801
aarshkshah1992 Mar 6, 2020
9b5e987
remove the Protector interface, introduce a PSK type (#118)
marten-seemann Mar 7, 2020
650cf9f
doc(event): document network events (#129)
Stebalien Mar 7, 2020
af6b54b
deps: move tools to a sub-module (#130)
Stebalien Mar 10, 2020
73266e7
peer: Add (*PeerRecord).ToProtoBuf to get protobuf equivalent struct
Mar 25, 2020
e2dd6fd
(*PeerRecord.MarshalRecord): Use ToProtobuf() to get protobuf struct
Mar 25, 2020
c64258a
put signed peer record in address change event
aarshkshah1992 Mar 26, 2020
93bcd2c
Update event/addrs.go
aarshkshah1992 Mar 26, 2020
5d92d97
Update event/addrs.go
aarshkshah1992 Mar 26, 2020
0eec081
Merge pull request #136 from libp2p/feat/signed-record-addr-change-evt
aarshkshah1992 Mar 26, 2020
eaba2ef
peer: Add PeerRecordFromProtobuf.
Mar 27, 2020
29a922f
fix: don't drop bytes in the insecure transport
Stebalien Apr 3, 2020
695d2b8
Merge pull request #137 from libp2p/fix/insecure-transport
Stebalien Apr 3, 2020
03fa6d8
doc(routing): document count
Stebalien Apr 9, 2020
f8bdedb
Merge pull request #140 from libp2p/docs/routing
Stebalien Apr 9, 2020
e444262
Merge pull request #134 from edjx/feat/peer-records-pb-conv
Stebalien Apr 13, 2020
573c9c6
fix: use correct reachability type
Stebalien Apr 13, 2020
04cfc52
Merge pull request #141 from libp2p/fix/reachability-type
Stebalien Apr 13, 2020
984c8b6
fix: envelop contains a mutex and can't be copied.
Stebalien Apr 25, 2020
d511b7a
Merge pull request #145 from libp2p/fix/by-pointer
Stebalien Apr 25, 2020
6be155f
feat: add a function to tell if a context subscribes to query events
Stebalien Apr 29, 2020
7b406c1
Merge pull request #147 from libp2p/feat/subscribes-to-events
Stebalien Apr 29, 2020
8b984ac
check if peer supports a protocol without allocation
aarshkshah1992 May 8, 2020
1165597
non alloc version
aarshkshah1992 May 8, 2020
34f061a
changes as per review
aarshkshah1992 May 11, 2020
3faacbd
add connection gating interfaces and types. (#139)
aarshkshah1992 May 13, 2020
688f105
Merge pull request #148 from libp2p/feat/supports-alloc
aarshkshah1992 May 14, 2020
70a8c2c
connmgr: introduce abstractions and functions for decaying tags. (#104)
raulk May 14, 2020
4987edb
implement Stringer for network.{Direction,Connectedness,Reachability}…
raulk May 14, 2020
646e1c5
minor godoc fixes.
raulk May 14, 2020
280a70e
minor godoc fixes.
raulk May 14, 2020
e42eb47
decaying tags: support removal and closure. (#151)
raulk May 15, 2020
55f9d72
events: add a generic DHT event. (#154)
raulk May 20, 2020
994ccbf
eventbus: add wildcard subscription type; getter to enumerate known t…
raulk May 20, 2020
5f96bc7
connmgr: add IsProtected interface (#158)
vyzo Jun 3, 2020
509a30f
experimental introspection support (#159)
raulk Jun 5, 2020
1f8b03e
Fix typo in docs (#163)
tarunbhm Aug 8, 2020
ef2b995
add CloseRead/CloseWrite on streams (#166)
Stebalien Sep 2, 2020
a6022f5
sec/insecure/insecure.go: Fix typo (#167)
mxinden Sep 18, 2020
2d1ec57
add a context to OpenStream and NewStream (#172)
marten-seemann Dec 19, 2020
2fd8219
Secure Muxer Interface (#180)
aarshkshah1992 Feb 14, 2021
2614ce9
context to force direct dial (#181)
aarshkshah1992 Feb 15, 2021
1b9857d
fix stream docs (#182)
aarshkshah1992 Feb 15, 2021
b7eb622
refactor: use a helper type to decode AddrInfo from JSON (#178)
Stebalien Feb 16, 2021
2afa963
more docs for stream fncs (#183)
aarshkshah1992 Feb 16, 2021
03594dc
add support for transient connections
vyzo Feb 3, 2021
45f3a8f
add ErrTransientConn error
vyzo Feb 3, 2021
3498aa5
Update network/context.go
vyzo Feb 3, 2021
060d76d
abstract Conn Stat interface for threading
vyzo Feb 4, 2021
c8b8064
make UseTransient context option take a reason argument, for consiste…
vyzo Feb 17, 2021
2af4134
address aarshian nitpicks
vyzo Feb 17, 2021
dbc9b9d
Event for user's NAT Device Type: Tell user if the node is behind an …
aarshkshah1992 Feb 18, 2021
e038863
context option for simultaneous connect
vyzo Feb 19, 2021
d650279
mind the dot.
vyzo Feb 19, 2021
c617c51
add a helper function to go directly from a string to an AddrInfo (#184)
whyrusleeping Feb 22, 2021
6b076c8
doc: document Close on Transport (#188)
Stebalien Mar 29, 2021
dc031c6
fix staticcheck errors (#191)
marten-seemann Mar 30, 2021
56e735b
fix benchmark of key verifications (#190)
marten-seemann Mar 30, 2021
6714060
reduce default timeouts to 15s (#192)
vyzo Apr 5, 2021
9820fe1
remove flaky tests (#194)
Apr 15, 2021
cdacdad
sync: update CI config files (#189)
web3-bot Jul 13, 2021
7ecfd76
ci: use github-actions for compatibility testing (#200)
Stebalien Jul 13, 2021
def12fc
fix: make timestamps strictly increasing (#201)
Stebalien Jul 16, 2021
79536ec
feat: add helper functions for working with addr infos (#202)
Stebalien Jul 21, 2021
7268931
remove deprecated constructor for the insecure transport (#206)
marten-seemann Jul 22, 2021
0e10da7
remove deprecated functions in the peer package (#205)
marten-seemann Jul 22, 2021
ca28041
remove deprecated Bytes method from the Key interface (#204)
marten-seemann Jul 22, 2021
c612c8e
remove deprecated key stretching struct / function (#203)
marten-seemann Jul 22, 2021
c282179
feat: keep addresses for longer (#207)
Stebalien Jul 22, 2021
12d4ba0
feat: remove unused metrics (#208)
Stebalien Jul 23, 2021
a9c4104
sync: update CI config files (#209)
web3-bot Aug 22, 2021
1d5963f
save the role (client, server) in the simultaneous connect context (#…
marten-seemann Aug 24, 2021
52f593e
pass the peer ID to SecureInbound in the SecureTransport and SecureMu…
marten-seemann Sep 8, 2021
bfef630
remove the Process from the Network interface (#212)
marten-seemann Sep 8, 2021
b9e22b2
remove the ConnHandler (#214)
marten-seemann Oct 18, 2021
e467196
add RemovePeer method to PeerMetadata, Metrics, ProtoBook and Keybook…
marten-seemann Oct 24, 2021
73e57d3
generate ecdsa public key from an input public key (#219)
richard-ramos Dec 2, 2021
862d7eb
rename network.Stat to Stats, introduce ConnStats (#226)
marten-seemann Dec 12, 2021
1e2c841
remove duplicate io.Closer on Network interface (#228)
YRXING Dec 16, 2021
9b85293
remove the DialTimeout (#230)
marten-seemann Dec 20, 2021
9ba98bd
remove the transport.AcceptTimeout (#231)
marten-seemann Dec 21, 2021
ecd8d78
introduce a transport.Upgrader interface (#232)
marten-seemann Jan 4, 2022
feb4853
Network Resource Manager interface (#229)
vyzo Jan 17, 2022
0b87f23
chore: add `String()` method to `IDSlice` type (#238)
EclesioMeloJunior Mar 21, 2022
a5df506
fix: switch to go-multicodec mappings (#240)
lidel Mar 31, 2022
af7b869
sync: update CI config files (#241)
web3-bot Apr 10, 2022
9d6f93a
feat: harden encoding/decoding functions against panics (#243)
Stebalien Apr 18, 2022
c8ec461
update btcec dependency (#247)
brianathere Apr 20, 2022
4e29e40
deprecate Negotiator.NegotiateLazy (#249)
marten-seemann Apr 22, 2022
48ba07f
remove OpenedStream and ClosedStream from Notifiee interface (#250)
marten-seemann May 24, 2022
10ad673
force usage of github.com/btcsuite/btcd v0.22.1 or newer (#254)
marten-seemann May 25, 2022
406600f
Add canonical log for misbehaving peers (#258)
MarcoPolo Jun 17, 2022
5fa701a
remove the peer.Set (#261)
marten-seemann Jun 22, 2022
6ead11f
remove deprecated mux package (#265)
marten-seemann Jun 24, 2022
0e250bb
Only log once if we failed to convert from netAddr (#264)
MarcoPolo Jun 24, 2022
4c4f229
canonicallog: reduce log level to warning (#268)
marten-seemann Jun 26, 2022
c2e77cf
Add canonical peer status logging with sampling (#269)
MarcoPolo Jun 30, 2022
0edd2a2
Add endpoint parameter to the OpenConnection method for ResourceManag…
MarcoPolo Jun 30, 2022
8f80ad3
Remove btcsuite/btcd dep (#272)
MarcoPolo Jul 5, 2022
c436912
deprecate peer.ID.Pretty (#273)
marten-seemann Jul 7, 2022
00c0f11
deprecate peer.Encode in favor of peer.ID.String (#275)
marten-seemann Jul 7, 2022
c21356e
remove peer.IDFromString (#274)
marten-seemann Jul 9, 2022
d14ac01
remove unused MultistreamSemverMatcher (#277)
marten-seemann Jul 12, 2022
0b79495
use a mock clock in bandwidth tests (#276)
marten-seemann Aug 16, 2022
dba78d0
stop using the deprecated io/ioutil package (#279)
marten-seemann Aug 17, 2022
ba15ef6
move go-libp2p-core to core
marten-seemann Aug 17, 2022
4623690
switch from github.com/libp2p/go-libp2p-core to core
marten-seemann Aug 17, 2022
f401380
move the resource manager mocks to this repo
marten-seemann Aug 17, 2022
d4e64c7
stop using go-libp2p-testing peer ID generation functions
marten-seemann Aug 17, 2022
98f098e
remove leftover license files in core/
marten-seemann Aug 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
23 changes: 11 additions & 12 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@ import (
"fmt"
"time"

"github.com/libp2p/go-libp2p-core/connmgr"
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/metrics"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/peerstore"
"github.com/libp2p/go-libp2p-core/pnet"
"github.com/libp2p/go-libp2p-core/routing"
"github.com/libp2p/go-libp2p-core/sec"
"github.com/libp2p/go-libp2p-core/transport"

"github.com/libp2p/go-libp2p/core/connmgr"
"github.com/libp2p/go-libp2p/core/crypto"
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/metrics"
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/core/peerstore"
"github.com/libp2p/go-libp2p/core/pnet"
"github.com/libp2p/go-libp2p/core/routing"
"github.com/libp2p/go-libp2p/core/sec"
"github.com/libp2p/go-libp2p/core/transport"
"github.com/libp2p/go-libp2p/p2p/host/autonat"
"github.com/libp2p/go-libp2p/p2p/host/autorelay"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
Expand Down
18 changes: 9 additions & 9 deletions config/constructor_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import (
"fmt"
"reflect"

"github.com/libp2p/go-libp2p-core/connmgr"
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/peerstore"
"github.com/libp2p/go-libp2p-core/pnet"
"github.com/libp2p/go-libp2p-core/sec"
"github.com/libp2p/go-libp2p-core/transport"
"github.com/libp2p/go-libp2p/core/connmgr"
"github.com/libp2p/go-libp2p/core/crypto"
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/core/peerstore"
"github.com/libp2p/go-libp2p/core/pnet"
"github.com/libp2p/go-libp2p/core/sec"
"github.com/libp2p/go-libp2p/core/transport"
)

var (
Expand Down
6 changes: 2 additions & 4 deletions config/muxer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ package config
import (
"fmt"

"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/network"
msmux "github.com/libp2p/go-libp2p/p2p/muxer/muxer-multistream"

"github.com/libp2p/go-libp2p-core/network"

"github.com/libp2p/go-libp2p-core/host"
)

// MuxC is a stream multiplex transport constructor.
Expand Down
7 changes: 3 additions & 4 deletions config/muxer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ package config
import (
"testing"

"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
"github.com/libp2p/go-libp2p/p2p/muxer/yamux"
swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"

"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
)

func TestMuxerSimple(t *testing.T) {
Expand Down
12 changes: 5 additions & 7 deletions config/reflection_magic.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ import (
"reflect"
"runtime"

"github.com/libp2p/go-libp2p-core/network"

"github.com/libp2p/go-libp2p-core/pnet"

"github.com/libp2p/go-libp2p-core/connmgr"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/transport"
"github.com/libp2p/go-libp2p/core/connmgr"
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/pnet"
"github.com/libp2p/go-libp2p/core/transport"
)

var errorType = reflect.TypeOf((*error)(nil)).Elem()
Expand Down
11 changes: 5 additions & 6 deletions config/security.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ package config
import (
"fmt"

"github.com/libp2p/go-libp2p/core/crypto"
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/core/sec"
"github.com/libp2p/go-libp2p/core/sec/insecure"
csms "github.com/libp2p/go-libp2p/p2p/net/conn-security-multistream"

"github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/sec"
"github.com/libp2p/go-libp2p-core/sec/insecure"
)

// SecC is a security transport constructor.
Expand Down
10 changes: 5 additions & 5 deletions config/transport.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package config

import (
"github.com/libp2p/go-libp2p-core/connmgr"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/pnet"
"github.com/libp2p/go-libp2p-core/transport"
"github.com/libp2p/go-libp2p/core/connmgr"
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/pnet"
"github.com/libp2p/go-libp2p/core/transport"
)

// TptC is the type for libp2p transport constructors. You probably won't ever
Expand Down
5 changes: 2 additions & 3 deletions config/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ package config
import (
"testing"

"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/core/transport"
"github.com/libp2p/go-libp2p/p2p/transport/tcp"

"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/transport"

"github.com/stretchr/testify/require"
)

Expand Down
13 changes: 13 additions & 0 deletions core/LICENSE-APACHE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2019. Protocol Labs, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
19 changes: 19 additions & 0 deletions core/LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright 2019. Protocol Labs, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
51 changes: 51 additions & 0 deletions core/alias.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Package core provides convenient access to foundational, central go-libp2p primitives via type aliases.
package core

import (
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/core/protocol"

"github.com/multiformats/go-multiaddr"
)

// Multiaddr aliases the Multiaddr type from github.com/multiformats/go-multiaddr.
//
// Refer to the docs on that type for more info.
type Multiaddr = multiaddr.Multiaddr

// PeerID aliases peer.ID.
//
// Refer to the docs on that type for more info.
type PeerID = peer.ID

// ProtocolID aliases protocol.ID.
//
// Refer to the docs on that type for more info.
type ProtocolID = protocol.ID

// PeerAddrInfo aliases peer.AddrInfo.
//
// Refer to the docs on that type for more info.
type PeerAddrInfo = peer.AddrInfo

// Host aliases host.Host.
//
// Refer to the docs on that type for more info.
type Host = host.Host

// Network aliases network.Network.
//
// Refer to the docs on that type for more info.
type Network = network.Network

// Conn aliases network.Conn.
//
// Refer to the docs on that type for more info.
type Conn = network.Conn

// Stream aliases network.Stream.
//
// Refer to the docs on that type for more info.
type Stream = network.Stream
57 changes: 57 additions & 0 deletions core/canonicallog/canonicallog.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package canonicallog

import (
"fmt"
"math/rand"
"net"
"strings"

"github.com/libp2p/go-libp2p/core/peer"

logging "github.com/ipfs/go-log/v2"
"github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr/net"
)

var log = logging.WithSkip(logging.Logger("canonical-log"), 1)

// LogMisbehavingPeer is the canonical way to log a misbehaving peer.
// Protocols should use this to identify a misbehaving peer to allow the end
// user to easily identify these nodes across protocols and libp2p.
func LogMisbehavingPeer(p peer.ID, peerAddr multiaddr.Multiaddr, component string, err error, msg string) {
log.Warnf("CANONICAL_MISBEHAVING_PEER: peer=%s addr=%s component=%s err=%q msg=%q", p, peerAddr.String(), component, err, msg)
}

// LogMisbehavingPeerNetAddr is the canonical way to log a misbehaving peer.
// Protocols should use this to identify a misbehaving peer to allow the end
// user to easily identify these nodes across protocols and libp2p.
func LogMisbehavingPeerNetAddr(p peer.ID, peerAddr net.Addr, component string, originalErr error, msg string) {
ma, err := manet.FromNetAddr(peerAddr)
if err != nil {
log.Warnf("CANONICAL_MISBEHAVING_PEER: peer=%s net_addr=%s component=%s err=%q msg=%q", p, peerAddr.String(), component, originalErr, msg)
return
}

LogMisbehavingPeer(p, ma, component, originalErr, msg)
}

// LogPeerStatus logs any useful information about a peer. It takes in a sample
// rate and will only log one in every sampleRate messages (randomly). This is
// useful in surfacing events that are normal in isolation, but may be abnormal
// in large quantities. For example, a successful connection from an IP address
// is normal. 10,000 connections from that same IP address is not normal. libp2p
// itself does nothing besides emitting this log. Hook this up to another tool
// like fail2ban to action on the log.
func LogPeerStatus(sampleRate int, p peer.ID, peerAddr multiaddr.Multiaddr, keyVals ...string) {
if rand.Intn(sampleRate) == 0 {
keyValsStr := strings.Builder{}
for i, kOrV := range keyVals {
if i%2 == 0 {
fmt.Fprintf(&keyValsStr, " %v=", kOrV)
} else {
fmt.Fprintf(&keyValsStr, "%q", kOrV)
}
}
log.Infof("CANONICAL_PEER_STATUS: peer=%s addr=%s sample_rate=%v%s", p, peerAddr.String(), sampleRate, keyValsStr.String())
}
}
26 changes: 26 additions & 0 deletions core/canonicallog/canonicallog_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package canonicallog

import (
"fmt"
"net"
"testing"

"github.com/libp2p/go-libp2p/core/test"

logging "github.com/ipfs/go-log/v2"
"github.com/multiformats/go-multiaddr"
)

func TestLogs(t *testing.T) {
err := logging.SetLogLevel("canonical-log", "info")
if err != nil {
t.Fatal(err)
}

LogMisbehavingPeer(test.RandPeerIDFatal(t), multiaddr.StringCast("/ip4/1.2.3.4"), "somecomponent", fmt.Errorf("something"), "hi")

netAddr := &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 80}
LogMisbehavingPeerNetAddr(test.RandPeerIDFatal(t), netAddr, "somecomponent", fmt.Errorf("something"), "hello \"world\"")

LogPeerStatus(1, test.RandPeerIDFatal(t), multiaddr.StringCast("/ip4/1.2.3.4"), "extra", "info")
}
Loading