Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion make.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

#from __future__ import print_function
import os
Expand Down
22 changes: 22 additions & 0 deletions src/core/peer_core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,28 @@ namespace p2psp {

// }}}
}


std::string Peer_core::RESTSplitter(std::string channel_url) {
boost::system::error_code ec;
io_service svc;
ip::tcp::socket rest(svc);
rest.connect({ {}, 3000 });
std::string request("GET /channel/"+channel_url+" HTTP/1.1\r\n\r\n");
rest.send(buffer(request));
std::string data;

do {
char buf[1024];
size_t bytes_transferred = rest.receive(buffer(buf), {}, ec);
if (!ec) data.append(buf, buf + bytes_transferred);
} while (!ec);

int split=data.find("\"splitterAddress\":\"")+19;
int next_split=data.find("\"",split);
data=data.substr(split,next_split-split);
return data;
}

uint16_t Peer_core::GetSplitterPort() {
// {{{
Expand Down
1 change: 1 addition & 0 deletions src/core/peer_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ namespace p2psp {

virtual void Init();

virtual std::string RESTSplitter(std::string channel_url);
virtual void SetSplitterAddr(ip::address splitter_addr);
virtual ip::address GetSplitterAddr();
static ip::address GetDefaultSplitterAddr();
Expand Down