@@ -43,7 +43,6 @@ namespace llarp::controller
43
43
44
44
nlohmann::json req;
45
45
req[" pk" ] = remote;
46
- req[" x" ] = false ;
47
46
48
47
if (auto it = _binds.find (src); it != _binds.end ())
49
48
_omq->request (
@@ -110,6 +109,26 @@ namespace llarp::controller
110
109
logcat, " Could not find connection ID to RPC bind {} for `session_close` command" , src.full_address ());
111
110
}
112
111
112
+ void rpc_controller::_halt (omq::address src)
113
+ {
114
+ log ::info (logcat, " Instructing lokinet instance (bind:{}) to halt" , src.full_address ());
115
+
116
+ if (auto it = _binds.find (src); it != _binds.end ())
117
+ {
118
+ _omq->request (it->second .cid , " llarp.halt" , [&](bool success, std::vector<std::string> data) {
119
+ if (success)
120
+ {
121
+ auto res = nlohmann::json::parse (data[0 ]);
122
+ log ::info (logcat, " RPC call to halt instance succeeded: {}" , res.dump ());
123
+ }
124
+ else
125
+ log ::critical (logcat, " RPC call to halt instance failed!" );
126
+ });
127
+ }
128
+ else
129
+ log ::critical (logcat, " Could not find connection ID to RPC bind {} for `halt` command" , src.full_address ());
130
+ }
131
+
113
132
bool rpc_controller::_omq_connect (const std::vector<std::string>& bind_addrs)
114
133
{
115
134
int i = 0 ;
@@ -197,4 +216,14 @@ namespace llarp::controller
197
216
else
198
217
log ::warning (logcat, " Could not find instance with given index: {}" , idx);
199
218
}
219
+
220
+ void rpc_controller::halt (omq::address src) { return _halt (std::move (src)); }
221
+
222
+ void rpc_controller::halt (size_t idx)
223
+ {
224
+ if (auto it = _indexes.find (idx); it != _indexes.end ())
225
+ _halt (it->second );
226
+ else
227
+ log ::warning (logcat, " Could not find instance with given index: {}" , idx);
228
+ }
200
229
} // namespace llarp::controller
0 commit comments