mirror of
https://github.com/status-im/status-go.git
synced 2025-01-23 05:00:35 +00:00
40359f9c1b
* Adding wakunode module * Adding wakuv2 fleet files * Add waku fleets to update-fleet-config script * Adding config items for waku v2 * Conditionally start waku v2 node depending on config * Adapting common code to use go-waku * Setting log level to info * update dependencies * update fleet config to use WakuNodes instead of BootNodes * send and receive messages * use hash returned when publishing a message * add waku store protocol * trigger signal after receiving store messages * exclude linting rule SA1019 to check deprecated packages
41 lines
1003 B
Go
41 lines
1003 B
Go
package autonat
|
|
|
|
import (
|
|
pb "github.com/libp2p/go-libp2p-autonat/pb"
|
|
|
|
"github.com/libp2p/go-libp2p-core/peer"
|
|
|
|
ma "github.com/multiformats/go-multiaddr"
|
|
)
|
|
|
|
// AutoNATProto identifies the autonat service protocol
|
|
const AutoNATProto = "/libp2p/autonat/1.0.0"
|
|
|
|
func newDialMessage(pi peer.AddrInfo) *pb.Message {
|
|
msg := new(pb.Message)
|
|
msg.Type = pb.Message_DIAL.Enum()
|
|
msg.Dial = new(pb.Message_Dial)
|
|
msg.Dial.Peer = new(pb.Message_PeerInfo)
|
|
msg.Dial.Peer.Id = []byte(pi.ID)
|
|
msg.Dial.Peer.Addrs = make([][]byte, len(pi.Addrs))
|
|
for i, addr := range pi.Addrs {
|
|
msg.Dial.Peer.Addrs[i] = addr.Bytes()
|
|
}
|
|
|
|
return msg
|
|
}
|
|
|
|
func newDialResponseOK(addr ma.Multiaddr) *pb.Message_DialResponse {
|
|
dr := new(pb.Message_DialResponse)
|
|
dr.Status = pb.Message_OK.Enum()
|
|
dr.Addr = addr.Bytes()
|
|
return dr
|
|
}
|
|
|
|
func newDialResponseError(status pb.Message_ResponseStatus, text string) *pb.Message_DialResponse {
|
|
dr := new(pb.Message_DialResponse)
|
|
dr.Status = status.Enum()
|
|
dr.StatusText = &text
|
|
return dr
|
|
}
|