mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-02 11:04:00 +01:00
handle signature type for SAM 3.1
This commit is contained in:
parent
54cffb583f
commit
9606883b78
18
SAM.cpp
18
SAM.cpp
|
@ -3,6 +3,7 @@
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <boost/lexical_cast.hpp>
|
||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
#include "Identity.h"
|
#include "Identity.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
@ -238,13 +239,15 @@ namespace client
|
||||||
std::string& style = params[SAM_PARAM_STYLE];
|
std::string& style = params[SAM_PARAM_STYLE];
|
||||||
std::string& id = params[SAM_PARAM_ID];
|
std::string& id = params[SAM_PARAM_ID];
|
||||||
std::string& destination = params[SAM_PARAM_DESTINATION];
|
std::string& destination = params[SAM_PARAM_DESTINATION];
|
||||||
m_ID = id;
|
m_ID = id;
|
||||||
if (m_Owner.FindSession (id))
|
if (m_Owner.FindSession (id))
|
||||||
{
|
{
|
||||||
// session exists
|
// session exists
|
||||||
SendMessageReply (SAM_SESSION_CREATE_DUPLICATED_ID, strlen(SAM_SESSION_CREATE_DUPLICATED_ID), true);
|
SendMessageReply (SAM_SESSION_CREATE_DUPLICATED_ID, strlen(SAM_SESSION_CREATE_DUPLICATED_ID), true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create destination
|
||||||
m_Session = m_Owner.CreateSession (id, destination == SAM_VALUE_TRANSIENT ? "" : destination, ¶ms);
|
m_Session = m_Owner.CreateSession (id, destination == SAM_VALUE_TRANSIENT ? "" : destination, ¶ms);
|
||||||
if (m_Session)
|
if (m_Session)
|
||||||
{
|
{
|
||||||
|
@ -642,7 +645,18 @@ namespace client
|
||||||
localDestination = i2p::client::context.CreateNewLocalDestination (keys, true, params);
|
localDestination = i2p::client::context.CreateNewLocalDestination (keys, true, params);
|
||||||
}
|
}
|
||||||
else // transient
|
else // transient
|
||||||
localDestination = i2p::client::context.CreateNewLocalDestination (false, i2p::data::SIGNING_KEY_TYPE_DSA_SHA1, params);
|
{
|
||||||
|
// extract signature type
|
||||||
|
i2p::data::SigningKeyType signatureType = i2p::data::SIGNING_KEY_TYPE_DSA_SHA1;
|
||||||
|
if (params)
|
||||||
|
{
|
||||||
|
auto it = params->find (SAM_PARAM_SIGNATURE_TYPE);
|
||||||
|
if (it != params->end ())
|
||||||
|
// TODO: extract string values
|
||||||
|
signatureType = boost::lexical_cast<int> (it->second);
|
||||||
|
}
|
||||||
|
localDestination = i2p::client::context.CreateNewLocalDestination (false, signatureType, params);
|
||||||
|
}
|
||||||
if (localDestination)
|
if (localDestination)
|
||||||
{
|
{
|
||||||
SAMSession session;
|
SAMSession session;
|
||||||
|
|
7
SAM.h
7
SAM.h
|
@ -50,7 +50,8 @@ namespace client
|
||||||
const char SAM_PARAM_ID[] = "ID";
|
const char SAM_PARAM_ID[] = "ID";
|
||||||
const char SAM_PARAM_SILENT[] = "SILENT";
|
const char SAM_PARAM_SILENT[] = "SILENT";
|
||||||
const char SAM_PARAM_DESTINATION[] = "DESTINATION";
|
const char SAM_PARAM_DESTINATION[] = "DESTINATION";
|
||||||
const char SAM_PARAM_NAME[] = "NAME";
|
const char SAM_PARAM_NAME[] = "NAME";
|
||||||
|
const char SAM_PARAM_SIGNATURE_TYPE[] = "SIGNATURE_TYPE";
|
||||||
const char SAM_VALUE_TRANSIENT[] = "TRANSIENT";
|
const char SAM_VALUE_TRANSIENT[] = "TRANSIENT";
|
||||||
const char SAM_VALUE_STREAM[] = "STREAM";
|
const char SAM_VALUE_STREAM[] = "STREAM";
|
||||||
const char SAM_VALUE_DATAGRAM[] = "DATAGRAM";
|
const char SAM_VALUE_DATAGRAM[] = "DATAGRAM";
|
||||||
|
@ -149,8 +150,8 @@ namespace client
|
||||||
void Stop ();
|
void Stop ();
|
||||||
|
|
||||||
boost::asio::io_service& GetService () { return m_Service; };
|
boost::asio::io_service& GetService () { return m_Service; };
|
||||||
SAMSession * CreateSession (const std::string& id, const std::string& destination = "", // empty string means transient
|
SAMSession * CreateSession (const std::string& id, const std::string& destination, // empty string means transient
|
||||||
const std::map<std::string, std::string> * params = nullptr);
|
const std::map<std::string, std::string> * params);
|
||||||
void CloseSession (const std::string& id);
|
void CloseSession (const std::string& id);
|
||||||
SAMSession * FindSession (const std::string& id);
|
SAMSession * FindSession (const std::string& id);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue