summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2023-05-07 22:28:12 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2023-05-17 20:34:24 +0200
commit8386482fb9ee76bcfa79ba11915a9bcdf9745948 (patch)
tree675a88d31eabd7a6bf3a4c04912d7dbf7d85c0b7 /src/main.cpp
parent2d5508898e90c01680cab60295b9c1e8164d65da (diff)
Server function to manually add peer
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 63b78dd..f33bcc4 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -328,6 +328,16 @@ void stopServer(const vector<string> &)
server.reset();
}
+void peerAdd(const vector<string> & args)
+{
+ if (args.size() == 1)
+ server->addPeer(args.at(0));
+ else if (args.size() == 2)
+ server->addPeer(args.at(0), args.at(1));
+ else
+ throw invalid_argument("usage: peer-add <node> [<port>]");
+}
+
void sharedStateGet(const vector<string> &)
{
ostringstream ss;
@@ -530,6 +540,7 @@ vector<Command> commands = {
{ "create-identity", createIdentity },
{ "start-server", startServer },
{ "stop-server", stopServer },
+ { "peer-add", peerAdd },
{ "shared-state-get", sharedStateGet },
{ "shared-state-wait", sharedStateWait },
{ "watch-local-identity", watchLocalIdentity },