@ -101,7 +101,7 @@ namespace client
@@ -101,7 +101,7 @@ namespace client
{
if ( ecode )
{
LogPrint ( eLogError , " SAM: h andshake read error: " , ecode . message ( ) ) ;
LogPrint ( eLogError , " SAM: H andshake read error: " , ecode . message ( ) ) ;
if ( ecode ! = boost : : asio : : error : : operation_aborted )
Terminate ( " SAM: handshake read error " ) ;
}
@ -111,7 +111,7 @@ namespace client
@@ -111,7 +111,7 @@ namespace client
char * eol = ( char * ) memchr ( m_Buffer , ' \n ' , bytes_transferred ) ;
if ( eol )
* eol = 0 ;
LogPrint ( eLogDebug , " SAM: h andshake " , m_Buffer ) ;
LogPrint ( eLogDebug , " SAM: H andshake " , m_Buffer ) ;
char * separator = strchr ( m_Buffer , ' ' ) ;
if ( separator )
{
@ -168,7 +168,7 @@ namespace client
@@ -168,7 +168,7 @@ namespace client
}
else
{
LogPrint ( eLogError , " SAM: h andshake mismatch " ) ;
LogPrint ( eLogError , " SAM: H andshake mismatch " ) ;
Terminate ( " SAM: handshake mismatch " ) ;
}
}
@ -183,7 +183,7 @@ namespace client
@@ -183,7 +183,7 @@ namespace client
{
if ( ecode )
{
LogPrint ( eLogError , " SAM: h andshake reply send error: " , ecode . message ( ) ) ;
LogPrint ( eLogError , " SAM: H andshake reply send error: " , ecode . message ( ) ) ;
if ( ecode ! = boost : : asio : : error : : operation_aborted )
Terminate ( " SAM: handshake reply send error " ) ;
}
@ -216,7 +216,7 @@ namespace client
@@ -216,7 +216,7 @@ namespace client
{
if ( ecode )
{
LogPrint ( eLogError , " SAM: r eply send error: " , ecode . message ( ) ) ;
LogPrint ( eLogError , " SAM: R eply send error: " , ecode . message ( ) ) ;
if ( ecode ! = boost : : asio : : error : : operation_aborted )
Terminate ( " SAM: reply send error " ) ;
}
@ -233,7 +233,7 @@ namespace client
@@ -233,7 +233,7 @@ namespace client
{
if ( ecode )
{
LogPrint ( eLogError , " SAM: r ead error: " , ecode . message ( ) ) ;
LogPrint ( eLogError , " SAM: R ead error: " , ecode . message ( ) ) ;
if ( ecode ! = boost : : asio : : error : : operation_aborted )
Terminate ( " SAM: read error " ) ;
}
@ -295,20 +295,20 @@ namespace client
@@ -295,20 +295,20 @@ namespace client
}
else
{
LogPrint ( eLogError , " SAM: u nexpected message " , m_Buffer ) ;
LogPrint ( eLogError , " SAM: U nexpected message " , m_Buffer ) ;
Terminate ( " SAM: unexpected message " ) ;
}
}
else
{
LogPrint ( eLogError , " SAM: m alformed message " , m_Buffer ) ;
LogPrint ( eLogError , " SAM: M alformed message " , m_Buffer ) ;
Terminate ( " malformed message " ) ;
}
}
else
{
LogPrint ( eLogWarning , " SAM: i ncomplete message " , bytes_transferred ) ;
LogPrint ( eLogWarning , " SAM: I ncomplete message " , bytes_transferred ) ;
m_BufferOffset = bytes_transferred ;
// try to receive remaining message
Receive ( ) ;
@ -331,7 +331,7 @@ namespace client
@@ -331,7 +331,7 @@ namespace client
void SAMSocket : : ProcessSessionCreate ( char * buf , size_t len )
{
LogPrint ( eLogDebug , " SAM: s ession create: " , buf ) ;
LogPrint ( eLogDebug , " SAM: S ession create: " , buf ) ;
std : : map < std : : string , std : : string > params ;
ExtractParams ( buf , params ) ;
std : : string & style = params [ SAM_PARAM_STYLE ] ;
@ -476,7 +476,7 @@ namespace client
@@ -476,7 +476,7 @@ namespace client
void SAMSocket : : ProcessStreamConnect ( char * buf , size_t len , size_t rem )
{
LogPrint ( eLogDebug , " SAM: s tream connect: " , buf ) ;
LogPrint ( eLogDebug , " SAM: S tream connect: " , buf ) ;
if ( m_SocketType ! = eSAMSocketTypeUnknown )
{
SendI2PError ( " Socket already in use " ) ;
@ -567,14 +567,14 @@ namespace client
@@ -567,14 +567,14 @@ namespace client
Connect ( leaseSet ) ;
else
{
LogPrint ( eLogError , " SAM: d estination to connect not found " ) ;
LogPrint ( eLogError , " SAM: D estination to connect not found " ) ;
SendMessageReply ( SAM_STREAM_STATUS_CANT_REACH_PEER , strlen ( SAM_STREAM_STATUS_CANT_REACH_PEER ) , true ) ;
}
}
void SAMSocket : : ProcessStreamAccept ( char * buf , size_t len )
{
LogPrint ( eLogDebug , " SAM: s tream accept: " , buf ) ;
LogPrint ( eLogDebug , " SAM: S tream accept: " , buf ) ;
if ( m_SocketType ! = eSAMSocketTypeUnknown )
{
SendI2PError ( " Socket already in use " ) ;
@ -603,7 +603,7 @@ namespace client
@@ -603,7 +603,7 @@ namespace client
void SAMSocket : : ProcessStreamForward ( char * buf , size_t len )
{
LogPrint ( eLogDebug , " SAM: s tream forward: " , buf ) ;
LogPrint ( eLogDebug , " SAM: S tream forward: " , buf ) ;
std : : map < std : : string , std : : string > params ;
ExtractParams ( buf , params ) ;
std : : string & id = params [ SAM_PARAM_ID ] ;
@ -650,7 +650,7 @@ namespace client
@@ -650,7 +650,7 @@ namespace client
size_t SAMSocket : : ProcessDatagramSend ( char * buf , size_t len , const char * data )
{
LogPrint ( eLogDebug , " SAM: d atagram send: " , buf , " " , len ) ;
LogPrint ( eLogDebug , " SAM: D atagram send: " , buf , " " , len ) ;
std : : map < std : : string , std : : string > params ;
ExtractParams ( buf , params ) ;
size_t size = std : : stoi ( params [ SAM_PARAM_SIZE ] ) , offset = data - buf ;
@ -670,14 +670,14 @@ namespace client
@@ -670,14 +670,14 @@ namespace client
d - > SendRawDatagramTo ( ( const uint8_t * ) data , size , dest . GetIdentHash ( ) ) ;
}
else
LogPrint ( eLogError , " SAM: m issing datagram destination " ) ;
LogPrint ( eLogError , " SAM: M issing datagram destination " ) ;
}
else
LogPrint ( eLogError , " SAM: s ession is not created from DATAGRAM SEND " ) ;
LogPrint ( eLogError , " SAM: S ession is not created from DATAGRAM SEND " ) ;
}
else
{
LogPrint ( eLogWarning , " SAM: s ent datagram size " , size , " exceeds buffer " , len - offset ) ;
LogPrint ( eLogWarning , " SAM: S ent datagram size " , size , " exceeds buffer " , len - offset ) ;
return 0 ; // try to receive more
}
return offset + size ;
@ -685,7 +685,7 @@ namespace client
@@ -685,7 +685,7 @@ namespace client
void SAMSocket : : ProcessDestGenerate ( char * buf , size_t len )
{
LogPrint ( eLogDebug , " SAM: d est generate " ) ;
LogPrint ( eLogDebug , " SAM: D est generate " ) ;
std : : map < std : : string , std : : string > params ;
ExtractParams ( buf , params ) ;
// extract signature type
@ -722,7 +722,7 @@ namespace client
@@ -722,7 +722,7 @@ namespace client
void SAMSocket : : ProcessNamingLookup ( char * buf , size_t len )
{
LogPrint ( eLogDebug , " SAM: n aming lookup: " , buf ) ;
LogPrint ( eLogDebug , " SAM: N aming lookup: " , buf ) ;
std : : map < std : : string , std : : string > params ;
ExtractParams ( buf , params ) ;
std : : string & name = params [ SAM_PARAM_NAME ] ;
@ -753,7 +753,7 @@ namespace client
@@ -753,7 +753,7 @@ namespace client
}
else
{
LogPrint ( eLogError , " SAM: n aming failed, unknown address " , name ) ;
LogPrint ( eLogError , " SAM: N aming failed, unknown address " , name ) ;
# ifdef _MSC_VER
size_t len = sprintf_s ( m_Buffer , SAM_SOCKET_BUFFER_SIZE , SAM_NAMING_REPLY_INVALID_KEY , name . c_str ( ) ) ;
# else
@ -768,7 +768,7 @@ namespace client
@@ -768,7 +768,7 @@ namespace client
auto session = m_Owner . FindSession ( m_ID ) ;
if ( session & & session - > Type = = eSAMSessionTypeMaster )
{
LogPrint ( eLogDebug , " SAM: s ubsession add: " , buf ) ;
LogPrint ( eLogDebug , " SAM: S ubsession add: " , buf ) ;
auto masterSession = std : : static_pointer_cast < SAMMasterSession > ( session ) ;
std : : map < std : : string , std : : string > params ;
ExtractParams ( buf , params ) ;
@ -813,7 +813,7 @@ namespace client
@@ -813,7 +813,7 @@ namespace client
auto session = m_Owner . FindSession ( m_ID ) ;
if ( session & & session - > Type = = eSAMSessionTypeMaster )
{
LogPrint ( eLogDebug , " SAM: s ubsession remove: " , buf ) ;
LogPrint ( eLogDebug , " SAM: S ubsession remove: " , buf ) ;
auto masterSession = std : : static_pointer_cast < SAMMasterSession > ( session ) ;
std : : map < std : : string , std : : string > params ;
ExtractParams ( buf , params ) ;
@ -832,7 +832,7 @@ namespace client
@@ -832,7 +832,7 @@ namespace client
void SAMSocket : : SendI2PError ( const std : : string & msg )
{
LogPrint ( eLogError , " SAM: i2p error " , msg ) ;
LogPrint ( eLogError , " SAM: I2P error: " , msg ) ;
# ifdef _MSC_VER
size_t len = sprintf_s ( m_Buffer , SAM_SOCKET_BUFFER_SIZE , SAM_SESSION_STATUS_I2P_ERROR , msg . c_str ( ) ) ;
# else
@ -850,7 +850,7 @@ namespace client
@@ -850,7 +850,7 @@ namespace client
}
else
{
LogPrint ( eLogError , " SAM: n aming lookup failed. LeaseSet for " , name , " not found " ) ;
LogPrint ( eLogError , " SAM: N aming lookup failed. LeaseSet for " , name , " not found " ) ;
# ifdef _MSC_VER
size_t len = sprintf_s ( m_Buffer , SAM_SOCKET_BUFFER_SIZE , SAM_NAMING_REPLY_INVALID_KEY , name . c_str ( ) ) ;
# else
@ -901,7 +901,7 @@ namespace client
@@ -901,7 +901,7 @@ namespace client
{
if ( ecode )
{
LogPrint ( eLogError , " SAM: r ead error: " , ecode . message ( ) ) ;
LogPrint ( eLogError , " SAM: R ead error: " , ecode . message ( ) ) ;
if ( ecode ! = boost : : asio : : error : : operation_aborted )
Terminate ( " read error " ) ;
}
@ -978,7 +978,7 @@ namespace client
@@ -978,7 +978,7 @@ namespace client
{
if ( ecode )
{
LogPrint ( eLogError , " SAM: s tream read error: " , ecode . message ( ) ) ;
LogPrint ( eLogError , " SAM: S tream read error: " , ecode . message ( ) ) ;
if ( ecode ! = boost : : asio : : error : : operation_aborted )
{
if ( bytes_transferred > 0 )
@ -1015,7 +1015,7 @@ namespace client
@@ -1015,7 +1015,7 @@ namespace client
{
if ( ecode )
{
LogPrint ( eLogError , " SAM: s ocket write error: " , ecode . message ( ) ) ;
LogPrint ( eLogError , " SAM: S ocket write error: " , ecode . message ( ) ) ;
if ( ecode ! = boost : : asio : : error : : operation_aborted )
Terminate ( " socket write error at HandleWriteI2PData " ) ;
}
@ -1029,7 +1029,7 @@ namespace client
@@ -1029,7 +1029,7 @@ namespace client
{
if ( stream )
{
LogPrint ( eLogDebug , " SAM: i ncoming I2P connection for session " , m_ID ) ;
LogPrint ( eLogDebug , " SAM: I ncoming I2P connection for session " , m_ID ) ;
m_SocketType = eSAMSocketTypeStream ;
m_IsAccepting = false ;
m_Stream = stream ;
@ -1072,7 +1072,7 @@ namespace client
@@ -1072,7 +1072,7 @@ namespace client
{
if ( stream )
{
LogPrint ( eLogDebug , " SAM: i ncoming forward I2P connection for session " , m_ID ) ;
LogPrint ( eLogDebug , " SAM: I ncoming forward I2P connection for session " , m_ID ) ;
auto newSocket = std : : make_shared < SAMSocket > ( m_Owner ) ;
newSocket - > SetSocketType ( eSAMSocketTypeStream ) ;
auto s = shared_from_this ( ) ;
@ -1106,7 +1106,7 @@ namespace client
@@ -1106,7 +1106,7 @@ namespace client
void SAMSocket : : HandleI2PDatagramReceive ( const i2p : : data : : IdentityEx & from , uint16_t fromPort , uint16_t toPort , const uint8_t * buf , size_t len )
{
LogPrint ( eLogDebug , " SAM: d atagram received " , len ) ;
LogPrint ( eLogDebug , " SAM: D atagram received " , len ) ;
auto base64 = from . ToBase64 ( ) ;
auto session = m_Owner . FindSession ( m_ID ) ;
if ( session )
@ -1142,14 +1142,14 @@ namespace client
@@ -1142,14 +1142,14 @@ namespace client
WriteI2PData ( len + l ) ;
}
else
LogPrint ( eLogWarning , " SAM: r eceived datagram size " , len , " exceeds buffer " ) ;
LogPrint ( eLogWarning , " SAM: R eceived datagram size " , len , " exceeds buffer " ) ;
}
}
}
void SAMSocket : : HandleI2PRawDatagramReceive ( uint16_t fromPort , uint16_t toPort , const uint8_t * buf , size_t len )
{
LogPrint ( eLogDebug , " SAM: r aw datagram received " , len ) ;
LogPrint ( eLogDebug , " SAM: R aw datagram received " , len ) ;
auto session = m_Owner . FindSession ( m_ID ) ;
if ( session )
{
@ -1170,7 +1170,7 @@ namespace client
@@ -1170,7 +1170,7 @@ namespace client
WriteI2PData ( len + l ) ;
}
else
LogPrint ( eLogWarning , " SAM: r eceived raw datagram size " , len , " exceeds buffer " ) ;
LogPrint ( eLogWarning , " SAM: R eceived raw datagram size " , len , " exceeds buffer " ) ;
}
}
}
@ -1288,7 +1288,7 @@ namespace client
@@ -1288,7 +1288,7 @@ namespace client
}
catch ( const std : : exception & ex )
{
LogPrint ( eLogError , " SAM: r untime exception: " , ex . what ( ) ) ;
LogPrint ( eLogError , " SAM: R untime exception: " , ex . what ( ) ) ;
}
{
@ -1327,15 +1327,15 @@ namespace client
@@ -1327,15 +1327,15 @@ namespace client
auto ep = socket - > GetSocket ( ) . remote_endpoint ( ec ) ;
if ( ! ec )
{
LogPrint ( eLogDebug , " SAM: n ew connection from " , ep ) ;
LogPrint ( eLogDebug , " SAM: N ew connection from " , ep ) ;
AddSocket ( socket ) ;
socket - > ReceiveHandshake ( ) ;
}
else
LogPrint ( eLogError , " SAM: incoming connection error " , ec . message ( ) ) ;
LogPrint ( eLogError , " SAM: Incoming connection error: " , ec . message ( ) ) ;
}
else
LogPrint ( eLogError , " SAM: a ccept error: " , ecode . message ( ) ) ;
LogPrint ( eLogError , " SAM: A ccept error: " , ecode . message ( ) ) ;
if ( ecode ! = boost : : asio : : error : : operation_aborted )
Accept ( ) ;
@ -1479,7 +1479,7 @@ namespace client
@@ -1479,7 +1479,7 @@ namespace client
{
* eol = 0 ; eol + + ;
size_t payloadLen = bytes_transferred - ( ( uint8_t * ) eol - m_DatagramReceiveBuffer ) ;
LogPrint ( eLogDebug , " SAM: d atagram received " , m_DatagramReceiveBuffer , " size= " , payloadLen ) ;
LogPrint ( eLogDebug , " SAM: D atagram received " , m_DatagramReceiveBuffer , " size= " , payloadLen ) ;
char * sessionID = strchr ( ( char * ) m_DatagramReceiveBuffer , ' ' ) ;
if ( sessionID )
{
@ -1510,11 +1510,11 @@ namespace client
@@ -1510,11 +1510,11 @@ namespace client
LogPrint ( eLogError , " SAM: Missing sessionID " ) ;
}
else
LogPrint ( eLogError , " SAM: i nvalid datagram " ) ;
LogPrint ( eLogError , " SAM: I nvalid datagram " ) ;
ReceiveDatagram ( ) ;
}
else
LogPrint ( eLogError , " SAM: d atagram receive error: " , ecode . message ( ) ) ;
LogPrint ( eLogError , " SAM: D atagram receive error: " , ecode . message ( ) ) ;
}
bool SAMBridge : : ResolveSignatureType ( const std : : string & name , i2p : : data : : SigningKeyType & type ) const