Updated to use fixed ports (in PORTS file)

This commit is contained in:
Mike Goelzer 2018-09-14 11:08:26 -07:00
parent d88a293383
commit de366fdd4c
No known key found for this signature in database
GPG Key ID: EDAC46A37751AD6D
4 changed files with 29 additions and 23 deletions

10
PORTS Normal file
View File

@ -0,0 +1,10 @@
|--------------|--------------|
|Program | Listens On |
|--------------+--------------|
|bootstrapper | :5555 |
|--------------|--------------|
|go-peer | :6000 |
|js-peer | :6001 |
|rust-peer | :6002 |
|--------------+--------------+

View File

@ -35,7 +35,7 @@ function createNode(callback) {
waterfall([
(cb) => PeerInfo.create(cb),
(peerInfo, cb) => {
peerInfo.multiaddrs.add('/ip4/0.0.0.0/tcp/0')
peerInfo.multiaddrs.add('/ip4/0.0.0.0/tcp/0') //TODO: 0 -> 6001 ?
node = new MyBundle({
peerInfo
})

View File

@ -58,9 +58,9 @@ func main() {
bBootstrap, privKeyFilePath := parseArgs()
fmt.Printf("Starting up in ")
if bBootstrap {
fmt.Printf("bootstrapper mode")
fmt.Printf("bootstrapper mode (port 5555)")
} else {
fmt.Printf("peer mode")
fmt.Printf("peer mode (port 6000)")
}
fmt.Printf(" with private key '%s'\n", privKeyFilePath)
@ -87,11 +87,12 @@ func main() {
var host host.Host
if bBootstrap {
host, err = libp2p.New(ctx,
libp2p.ListenAddrStrings("/ip4/0.0.0.0/tcp/9876"),
libp2p.ListenAddrStrings("/ip4/0.0.0.0/tcp/5555"),
libp2p.Identity(priv),
)
} else {
host, err = libp2p.New(ctx,
libp2p.ListenAddrStrings("/ip4/0.0.0.0/tcp/6000"),
libp2p.Identity(priv),
)
}
@ -121,7 +122,7 @@ func main() {
if !bBootstrap {
var bootstrapMultiAddr ma.Multiaddr
var pinfo *peerstore.PeerInfo
bootstrapMultiAddrStr := fmt.Sprintf("/ip4/%s/tcp/9876/ipfs/QmehVYruznbyDZuHBV4vEHESpDevMoAovET6aJ9oRuEzWa", bootstrapAddrIP4Str)
bootstrapMultiAddrStr := fmt.Sprintf("/ip4/%s/tcp/5555/ipfs/QmehVYruznbyDZuHBV4vEHESpDevMoAovET6aJ9oRuEzWa", bootstrapAddrIP4Str)
fmt.Printf("bootstrapping to '%s'...\n", bootstrapMultiAddrStr)
bootstrapMultiAddr, err := ma.NewMultiaddr(bootstrapMultiAddrStr)
if err != nil {

View File

@ -39,10 +39,8 @@ use libp2p::websocket::WsConfig;
fn main() {
env_logger::init();
// Determine which address to listen to.
let listen_addr = env::args()
.nth(1)
.unwrap_or("/ip4/0.0.0.0/tcp/10050".to_owned());
// Address to listen on
let listen_addr:String = "/ip4/0.0.0.0/tcp/6002".to_owned();
// We start by creating a `TcpConfig` that indicates that we want TCP/IP.
let transport = TcpConfig::new()
@ -120,6 +118,16 @@ fn main() {
Ok(())
});
let m:String = "/ip4/127.0.0.1/tcp/5555".to_owned();
let target: Multiaddr = m.parse().unwrap();
println!("Dialing bootstrap peer {}", target);
swarm_controller
.dial(
target,
transport.clone().with_upgrade(floodsub_upgrade.clone()),
)
.unwrap();
let stdin = {
let mut buffer = Vec::new();
tokio_stdin::spawn_stdin_stream_unbounded().for_each(move |msg| {
@ -129,21 +137,8 @@ fn main() {
} else if buffer.is_empty() {
return Ok(());
}
let msg = String::from_utf8(mem::replace(&mut buffer, Vec::new())).unwrap();
if msg.starts_with("/dial ") {
let target: Multiaddr = msg[6..].parse().unwrap();
println!("*Dialing {}*", target);
swarm_controller
.dial(
target,
transport.clone().with_upgrade(floodsub_upgrade.clone()),
)
.unwrap();
} else {
floodsub_ctl.publish(&topic, msg.into_bytes());
}
floodsub_ctl.publish(&topic, msg.into_bytes());
Ok(())
})
};