Skip to content
This repository has been archived by the owner on Dec 10, 2019. It is now read-only.

Commit

Permalink
Merge pull request #152 from w1ndy/master
Browse files Browse the repository at this point in the history
Fix two bugs
  • Loading branch information
librehat authored Jan 4, 2018
2 parents a30296a + b06abb1 commit 30ecfdf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/cipher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Cipher::Cipher(const std::string& method,
}
#ifndef USE_BOTAN2
else if (method.find("chacha20") != std::string::npos) {
chacha.reset(new ChaCha(key, iv));
chacha.reset(new ChaCha(m_key, m_iv));
return;
}
#endif
Expand Down Expand Up @@ -184,7 +184,7 @@ std::string Cipher::randomIv(const std::string &method)
CipherInfo cipherInfo = cipherInfoMap.at(method);
if (cipherInfo.type == AEAD) {
return std::string(cipherInfo.ivLen, static_cast<char>(0));
}
}
return randomIv(cipherInfo.ivLen);
}

Expand Down
7 changes: 5 additions & 2 deletions lib/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,14 @@ bool Controller::start()

if (isLocal) {
qInfo("Running in local mode.");
QHostAddress localAddress = profile.httpProxy()
? QHostAddress::LocalHost
: getLocalAddr();
listen_ret = tcpServer->listen(
getLocalAddr(),
localAddress,
profile.httpProxy() ? 0 : profile.localPort());
if (listen_ret) {
listen_ret = udpRelay->listen(getLocalAddr(), profile.localPort());
listen_ret = udpRelay->listen(localAddress, profile.localPort());
if (profile.httpProxy() && listen_ret) {
QDebug(QtMsgType::QtInfoMsg) << "SOCKS5 port is"
<< tcpServer->serverPort();
Expand Down
6 changes: 3 additions & 3 deletions lib/encryptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void Encryptor::reset()

void Encryptor::initEncipher(std::string *header)
{
const std::string iv = Cipher::randomIv(m_method);
std::string iv = Cipher::randomIv(m_method);
std::string key;
#ifdef USE_BOTAN2
if (cipherInfo.type == Cipher::CipherType::AEAD) {
Expand All @@ -89,7 +89,7 @@ void Encryptor::initEncipher(std::string *header)
#ifdef USE_BOTAN2
}
#endif
enCipher = std::make_unique<QSS::Cipher>(m_method, key, iv, true);
enCipher = std::make_unique<QSS::Cipher>(m_method, std::move(key), std::move(iv), true);
}

void Encryptor::initDecipher(const char *data, size_t length, size_t *offset)
Expand All @@ -114,7 +114,7 @@ void Encryptor::initDecipher(const char *data, size_t length, size_t *offset)
#ifdef USE_BOTAN2
}
#endif
deCipher = std::make_unique<QSS::Cipher>(m_method, key, iv, false);
deCipher = std::make_unique<QSS::Cipher>(m_method, std::move(key), std::move(iv), false);
}

std::string Encryptor::encrypt(const std::string &in)
Expand Down

0 comments on commit 30ecfdf

Please sign in to comment.