@@ -24,12 +24,12 @@ namespace llarp::session
24
24
session_tag _t,
25
25
bool use_tun,
26
26
bool is_outbound,
27
- std::optional< shared_kx_data> kx_data)
27
+ shared_kx_data kx_data)
28
28
: _r{r},
29
29
_parent{parent},
30
30
_tag{std::move (_t)},
31
31
_remote{std::move (remote)},
32
- session_keys{std::move (kx_data)},
32
+ session_keys{std::make_unique<shared_kx_data>( std:: move (kx_data) )},
33
33
_remote_pivot_txid{std::move (remote_pivot_txid)},
34
34
_use_tun{use_tun},
35
35
_is_outbound{is_outbound},
@@ -69,8 +69,8 @@ namespace llarp::session
69
69
70
70
bool BaseSession::send_path_data_message (std::string data)
71
71
{
72
- if (session_keys. has_value ())
73
- session_keys->encrypt (data);
72
+ log ::debug (logcat, " {} called " , __PRETTY_FUNCTION__);
73
+ session_keys->encrypt (data);
74
74
75
75
auto inner_payload = PATH::DATA::serialize_inner (std::move (data), _tag);
76
76
auto intermediate_payload = PATH::DATA::serialize_intermediate (std::move (inner_payload), _remote_pivot_txid);
@@ -80,8 +80,7 @@ namespace llarp::session
80
80
81
81
void BaseSession::recv_path_data_message (std::vector<uint8_t > data)
82
82
{
83
- if (session_keys.has_value ())
84
- session_keys->decrypt (data);
83
+ session_keys->decrypt (data);
85
84
86
85
if (_recv_dgram)
87
86
_recv_dgram (std::move (data));
@@ -105,12 +104,7 @@ namespace llarp::session
105
104
106
105
void BaseSession::set_remote_pivot_tx (HopID new_remote_txid)
107
106
{
108
- log ::debug (
109
- logcat,
110
- " Setting new pivot txID for remote ({}) [ old:{} | new:{} ] " ,
111
- _remote,
112
- _remote_pivot_txid,
113
- new_remote_txid);
107
+ log ::debug (logcat, " Setting new pivot txID for remote ({}) [ new:{} ]" , _remote, new_remote_txid);
114
108
_remote_pivot_txid = std::move (new_remote_txid);
115
109
}
116
110
@@ -280,7 +274,7 @@ namespace llarp::session
280
274
281
275
std::shared_ptr<path::Path> OutboundRelaySession::current_path ()
282
276
{
283
- return std::static_pointer_cast <path::Path>(_current_path);
277
+ return std::dynamic_pointer_cast <path::Path>(_current_path);
284
278
}
285
279
286
280
std::shared_ptr<OutboundRelaySession> OutboundRelaySession::downcast (const std::shared_ptr<BaseSession>& b)
@@ -300,7 +294,17 @@ namespace llarp::session
300
294
301
295
bool OutboundRelaySession::send_path_data_message (std::string data)
302
296
{
303
- return _current_path->send_path_data_message (std::move (data));
297
+ log ::debug (logcat, " {} called" , __PRETTY_FUNCTION__);
298
+ // session_keys->encrypt(data);
299
+
300
+ // return BaseSession::send_path_data_message(std::move(data));
301
+ // return _current_path->send_path_data_message(std::move(data));
302
+ session_keys->encrypt (data);
303
+
304
+ auto inner_payload = PATH::DATA::serialize_inner (std::move (data), _tag);
305
+ auto intermediate_payload = PATH::DATA::serialize_intermediate (std::move (inner_payload), _remote_pivot_txid);
306
+
307
+ return _current_path->send_path_data_message (std::move (intermediate_payload));
304
308
}
305
309
306
310
void OutboundRelaySession::rotate_paths ()
@@ -456,9 +460,9 @@ namespace llarp::session
456
460
if (_is_exit_session and _is_snode_session)
457
461
throw std::runtime_error{" Cannot create OutboundSession for a remote exit and remote service node!" };
458
462
459
- _path_rotater = _router.loop ()->call_every (path::PATH_ROTATION_INTERVAL, [this ]() mutable { rotate_paths (); });
463
+ // _path_rotater = _router.loop()->call_every(path::PATH_ROTATION_INTERVAL, [this]() mutable { rotate_paths();
464
+ // }); add_path(current_path());
460
465
461
- add_path (current_path ());
462
466
populate_intro_map (std::move (_remote_intros));
463
467
464
468
log ::debug (
@@ -811,7 +815,7 @@ namespace llarp::session
811
815
HopID remote_pivot_txid,
812
816
session_tag _t,
813
817
bool use_tun,
814
- std::optional< shared_kx_data> kx_data)
818
+ shared_kx_data kx_data)
815
819
: BaseSession{
816
820
parent._router ,
817
821
std::move (_p),
@@ -848,7 +852,7 @@ namespace llarp::session
848
852
HopID remote_pivot_txid,
849
853
session_tag _t,
850
854
bool use_tun,
851
- std::optional< shared_kx_data> kx_data)
855
+ shared_kx_data kx_data)
852
856
: InboundClientSession{
853
857
std::move (remote),
854
858
std::move (_p),
@@ -870,13 +874,14 @@ namespace llarp::session
870
874
std::string method, std::string body, bt_control_response_hook func)
871
875
{
872
876
return _current_path->send_path_control_message (std::move (method), std::move (body), std::move (func));
873
- // auto payload = PATH::CONTROL::serialize(std::move(method), std::move(body));
874
- // return _current_path->send_path_control_message("path_control", std::move(payload), std::move(func));
875
877
}
876
878
877
879
bool InboundRelaySession::send_path_data_message (std::string data)
878
880
{
879
- return _current_path->send_path_data_message (std::move (data));
881
+ log ::trace (logcat, " {} called" , __PRETTY_FUNCTION__);
882
+ session_keys->encrypt (data);
883
+
884
+ return _current_path->send_path_data_message (PATH::DATA::serialize_inner (std::move (data), _tag));
880
885
}
881
886
882
887
} // namespace llarp::session
0 commit comments