From 3392f84f718db44776943983cd070a328dee0603 Mon Sep 17 00:00:00 2001 From: Shivanjan Chakravorty Date: Sun, 27 May 2018 16:02:54 +0530 Subject: [PATCH 1/5] Added channel_url option to set splitter address and port from channel url --- src/peer.cc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/peer.cc b/src/peer.cc index 27e2580..7871a03 100644 --- a/src/peer.cc +++ b/src/peer.cc @@ -412,6 +412,7 @@ namespace p2psp { uint16_t player_port = Console::GetDefaultPlayerPort(); std::string splitter_addr = p2psp::Peer_core::GetDefaultSplitterAddr().to_string(); uint16_t splitter_port = p2psp::Peer_core::GetDefaultSplitterPort(); + std::string channel_url="RSET url"; #if not defined __IMS__ int max_chunk_debt = p2psp::Peer_DBS::GetDefaultMaxChunkDebt(); uint16_t team_port = p2psp::Peer_core::GetDefaultTeamPort(); @@ -423,6 +424,7 @@ namespace p2psp { // TODO: strpe option should expect a list of arguments, not bool desc.add_options() ("help,h", "Produce this help message and exits.") + ("channel_url",boost::program_options::value()->default_value(channel_url),"Channel url to get splitter address from crossroads engine") #if not defined __IMS__ ("max_chunk_debt", boost::program_options::value()->default_value(max_chunk_debt), "Maximum number of times that other peer can not send a chunk to this peer.") #endif @@ -501,6 +503,7 @@ namespace p2psp { class Console* peer = new Console(); // }}} + if (vm.count("smart_source_client")) { // {{{ @@ -518,11 +521,27 @@ namespace p2psp { // }}} } - + if (vm.count("channel_url") || true) { + + TRACE("Channel URL = " + << vm["channel_url"].as()); + std::string splitter_source = peer->RESTSplitter(vm["channel_url"].as()); + int delimeter=splitter_source.find(":"); + std::string splitter_addr = splitter_source.substr(0,delimeter); + std::string splitter_port=splitter_source.substr(delimeter+1); + peer->SetSplitterAddr(ip::address::from_string("127.0.0.1")); + TRACE("Splitter address = " + << peer->GetSplitterAddr()); + peer->SetSplitterPort(std::stoi(splitter_port)); + TRACE("Splitter port = " + << peer->GetSplitterPort()); + } + peer->WaitForThePlayer(); std::cout << "Player connected" << std::endl; + if (vm.count("splitter_addr")) { // {{{ From 09531bd8ba20ff62953ff453dcc7f1eb4556a195 Mon Sep 17 00:00:00 2001 From: Shivanjan Chakravorty Date: Sun, 3 Jun 2018 23:55:25 +0530 Subject: [PATCH 2/5] Minor fix a boolean true was removed that was mistakenly added in the staging area --- src/peer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/peer.cc b/src/peer.cc index 7871a03..33bee26 100644 --- a/src/peer.cc +++ b/src/peer.cc @@ -521,7 +521,7 @@ namespace p2psp { // }}} } - if (vm.count("channel_url") || true) { + if (vm.count("channel_url")) { TRACE("Channel URL = " << vm["channel_url"].as()); From 8a5287310f9a545f350b75b19553cf5f33714621 Mon Sep 17 00:00:00 2001 From: Shivanjan Chakravorty Date: Mon, 4 Jun 2018 18:23:28 +0530 Subject: [PATCH 3/5] Monitor exit fix channel_url default value problem resolved --- src/peer.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/peer.cc b/src/peer.cc index 33bee26..df240b9 100644 --- a/src/peer.cc +++ b/src/peer.cc @@ -412,7 +412,7 @@ namespace p2psp { uint16_t player_port = Console::GetDefaultPlayerPort(); std::string splitter_addr = p2psp::Peer_core::GetDefaultSplitterAddr().to_string(); uint16_t splitter_port = p2psp::Peer_core::GetDefaultSplitterPort(); - std::string channel_url="RSET url"; + std::string channel_url; #if not defined __IMS__ int max_chunk_debt = p2psp::Peer_DBS::GetDefaultMaxChunkDebt(); uint16_t team_port = p2psp::Peer_core::GetDefaultTeamPort(); @@ -424,7 +424,7 @@ namespace p2psp { // TODO: strpe option should expect a list of arguments, not bool desc.add_options() ("help,h", "Produce this help message and exits.") - ("channel_url",boost::program_options::value()->default_value(channel_url),"Channel url to get splitter address from crossroads engine") + ("channel_url","Channel url to get splitter address from crossroads engine") #if not defined __IMS__ ("max_chunk_debt", boost::program_options::value()->default_value(max_chunk_debt), "Maximum number of times that other peer can not send a chunk to this peer.") #endif From a364c071b0cb87fa8230ad624e4ae0861fc3a05f Mon Sep 17 00:00:00 2001 From: Shivanjan Chakravorty Date: Wed, 6 Jun 2018 14:28:14 +0530 Subject: [PATCH 4/5] FIXED: Deleted program option value Accidentally deleted line caused peer and monitor binaries to crash --- src/peer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/peer.cc b/src/peer.cc index df240b9..8701705 100644 --- a/src/peer.cc +++ b/src/peer.cc @@ -424,7 +424,7 @@ namespace p2psp { // TODO: strpe option should expect a list of arguments, not bool desc.add_options() ("help,h", "Produce this help message and exits.") - ("channel_url","Channel url to get splitter address from crossroads engine") + ("channel_url", boost::program_options::value(), "Channel url to get splitter address from crossroads engine") #if not defined __IMS__ ("max_chunk_debt", boost::program_options::value()->default_value(max_chunk_debt), "Maximum number of times that other peer can not send a chunk to this peer.") #endif From 3d8ef5fe3aab0289c578a05326c7d7dcd60506ca Mon Sep 17 00:00:00 2001 From: Shivanjan Chakravorty Date: Thu, 7 Jun 2018 13:29:08 +0530 Subject: [PATCH 5/5] FIXED: Default Splitter address and port The splitter address and port should not be assigned default value when channel_url is used. --- src/peer.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/peer.cc b/src/peer.cc index 8701705..6503904 100644 --- a/src/peer.cc +++ b/src/peer.cc @@ -543,7 +543,7 @@ namespace p2psp { << std::endl; - if (vm.count("splitter_addr")) { + if (vm.count("splitter_addr") && !(vm.count("channel_url"))) { // {{{ peer->SetSplitterAddr(ip::address::from_string(vm["splitter_addr"].as())); @@ -553,7 +553,7 @@ namespace p2psp { // }}} } - if (vm.count("splitter_port")) { + if (vm.count("splitter_port") && !(vm.count("channel_url"))) { // {{{ peer->SetSplitterPort(vm["splitter_port"].as());