| 444 | } |
| 445 | |
| 446 | void BOBCommandSession::StartCommandHandler (const char * operand, size_t len) |
| 447 | { |
| 448 | LogPrint (eLogDebug, "BOB: start ", m_Nickname); |
| 449 | if (m_IsActive) |
| 450 | { |
| 451 | SendReplyError ("tunnel is active"); |
| 452 | return; |
| 453 | } |
| 454 | if (!m_Keys.GetPublic ()) // keys are set ? |
| 455 | { |
| 456 | SendReplyError("Keys must be set."); |
| 457 | return; |
| 458 | } |
| 459 | if (m_InPort == 0 |
| 460 | && m_OutHost.empty() && m_OutPort == 0) |
| 461 | { |
| 462 | SendReplyError("(inhost):inport or outhost:outport must be set."); |
| 463 | return; |
| 464 | } |
| 465 | if(!m_InHost.empty()) |
| 466 | { |
| 467 | // TODO: FIXME: temporary validation, until hostname support is added |
| 468 | boost::system::error_code ec; |
| 469 | boost::asio::ip::make_address(m_InHost, ec); |
| 470 | if (ec) |
| 471 | { |
| 472 | SendReplyError("inhost must be a valid IPv4 address."); |
| 473 | return; |
| 474 | } |
| 475 | } |
| 476 | if(!m_OutHost.empty()) |
| 477 | { |
| 478 | // TODO: FIXME: temporary validation, until hostname support is added |
| 479 | boost::system::error_code ec; |
| 480 | boost::asio::ip::make_address(m_OutHost, ec); |
| 481 | if (ec) |
| 482 | { |
| 483 | SendReplyError("outhost must be a IPv4 address."); |
| 484 | return; |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | if (!m_CurrentDestination) |
| 489 | { |
| 490 | m_CurrentDestination = std::make_shared<BOBDestination> (i2p::client::context.CreateNewLocalDestination (m_Keys, true, &m_Options), // deleted in clear command |
| 491 | m_Nickname, m_InHost, m_OutHost, m_InPort, m_OutPort, m_IsQuiet); |
| 492 | m_Owner.AddDestination (m_Nickname, m_CurrentDestination); |
| 493 | } |
| 494 | if (!m_tunnelType.has_value()) |
| 495 | { |
| 496 | if (m_InPort) |
| 497 | m_CurrentDestination->CreateInboundTunnel (m_InPort, m_InHost); |
| 498 | if (m_OutPort && !m_OutHost.empty ()) |
| 499 | m_CurrentDestination->CreateOutboundTunnel (m_OutHost, m_OutPort, m_IsQuiet); |
| 500 | m_CurrentDestination->Start (); |
| 501 | } |
| 502 | else |
| 503 | { |
nothing calls this directly
no test coverage detected