Skip to content

Commit

Permalink
change constant names
Browse files Browse the repository at this point in the history
  • Loading branch information
julian88110 committed Oct 12, 2022
1 parent 2793f3b commit 848d27b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions p2p/security/noise/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (

// ID is the protocol ID for noise
const (
ID = "/noise"
MAX_EXTENSION_SIZE = 2048
MAX_PROTO_NUM = 100
ID = "/noise"
MaxExtensionSize = 2048
MaxProtoNum = 100
)

var _ sec.SecureTransport = &Transport{}
Expand All @@ -31,6 +31,8 @@ type Transport struct {
muxers []string
}

// New creates a new Noise transport using the given private key as its
// libp2p identity key.
func New(privkey crypto.PrivKey, muxers []protocol.ID) (*Transport, error) {
localID, err := peer.IDFromPrivateKey(privkey)
if err != nil {
Expand Down Expand Up @@ -117,7 +119,7 @@ func (i *transportEarlyDataHandler) Send(context.Context, net.Conn, peer.ID) *pb

func (i *transportEarlyDataHandler) Received(_ context.Context, _ net.Conn, extension *pb.NoiseExtensions) error {
// Discard messages with size or the number of protocols exceeding extension limit for security.
if extension != nil && extension.XXX_Size() <= MAX_EXTENSION_SIZE && len(extension.StreamMuxers) <= MAX_PROTO_NUM {
if extension != nil && extension.XXX_Size() <= MaxExtensionSize && len(extension.StreamMuxers) <= MaxProtoNum {
i.receivedMuxers = extension.GetStreamMuxers()
}
return nil
Expand Down

0 comments on commit 848d27b

Please sign in to comment.