Browse Source

Tweak debug message out levels

tags/4.1.10.0
Student Main celeron533 5 years ago
parent
commit
23ce58aa34
5 changed files with 31 additions and 24 deletions
  1. +4
    -4
      shadowsocks-csharp/Controller/Service/TCPRelay.cs
  2. +3
    -3
      shadowsocks-csharp/Controller/Service/UpdateChecker.cs
  3. +14
    -14
      shadowsocks-csharp/Encryption/AEAD/AEADEncryptor.cs
  4. +9
    -2
      shadowsocks-csharp/Model/Configuration.cs
  5. +1
    -1
      shadowsocks-csharp/Proxy/HttpProxy.cs

+ 4
- 4
shadowsocks-csharp/Controller/Service/TCPRelay.cs View File

@@ -221,7 +221,7 @@ namespace Shadowsocks.Controller
this._server = server; this._server = server;
/* prepare address buffer length for AEAD */ /* prepare address buffer length for AEAD */
Logger.Debug($"_addrBufLength={_addrBufLength}");
Logger.Trace($"_addrBufLength={_addrBufLength}");
_encryptor.AddrBufLength = _addrBufLength; _encryptor.AddrBufLength = _addrBufLength;
} }
@@ -798,7 +798,7 @@ namespace Shadowsocks.Controller
PipeRemoteReceiveCallback, session); PipeRemoteReceiveCallback, session);
TryReadAvailableData(); TryReadAvailableData();
Logger.Debug($"_firstPacketLength = {_firstPacketLength}");
Logger.Trace($"_firstPacketLength = {_firstPacketLength}");
SendToServer(_firstPacketLength, session); SendToServer(_firstPacketLength, session);
} }
catch (Exception e) catch (Exception e)
@@ -837,12 +837,12 @@ namespace Shadowsocks.Controller
if (bytesToSend == 0) if (bytesToSend == 0)
{ {
// need more to decrypt // need more to decrypt
Logger.Debug("Need more to decrypt");
Logger.Trace("Need more to decrypt");
session.Remote.BeginReceive(_remoteRecvBuffer, 0, RecvSize, SocketFlags.None, session.Remote.BeginReceive(_remoteRecvBuffer, 0, RecvSize, SocketFlags.None,
PipeRemoteReceiveCallback, session); PipeRemoteReceiveCallback, session);
return; return;
} }
Logger.Debug($"start sending {bytesToSend}");
Logger.Trace($"start sending {bytesToSend}");
_connection.BeginSend(_remoteSendBuffer, 0, bytesToSend, SocketFlags.None, _connection.BeginSend(_remoteSendBuffer, 0, bytesToSend, SocketFlags.None,
PipeConnectionSendCallback, new object[] { session, bytesToSend }); PipeConnectionSendCallback, new object[] { session, bytesToSend });
IStrategy strategy = _controller.GetCurrentStrategy(); IStrategy strategy = _controller.GetCurrentStrategy();


+ 3
- 3
shadowsocks-csharp/Controller/Service/UpdateChecker.cs View File

@@ -62,7 +62,7 @@ namespace Shadowsocks.Controller
try try
{ {
logger.Debug("Checking updates...");
logger.Info("Checking updates...");
WebClient http = CreateWebClient(); WebClient http = CreateWebClient();
http.DownloadStringCompleted += http_DownloadStringCompleted; http.DownloadStringCompleted += http_DownloadStringCompleted;
http.DownloadStringAsync(new Uri(UpdateURL)); http.DownloadStringAsync(new Uri(UpdateURL));
@@ -119,7 +119,7 @@ namespace Shadowsocks.Controller
} }
else else
{ {
logger.Debug("No update is available");
logger.Info("No update is available");
if (CheckUpdateCompleted != null) if (CheckUpdateCompleted != null)
{ {
CheckUpdateCompleted(this, new EventArgs()); CheckUpdateCompleted(this, new EventArgs());
@@ -156,7 +156,7 @@ namespace Shadowsocks.Controller
logger.LogUsefulException(e.Error); logger.LogUsefulException(e.Error);
return; return;
} }
logger.Debug($"New version {LatestVersionNumber}{LatestVersionSuffix} found: {LatestVersionLocalName}");
logger.Info($"New version {LatestVersionNumber}{LatestVersionSuffix} found: {LatestVersionLocalName}");
if (CheckUpdateCompleted != null) if (CheckUpdateCompleted != null)
{ {
CheckUpdateCompleted(this, new EventArgs()); CheckUpdateCompleted(this, new EventArgs());


+ 14
- 14
shadowsocks-csharp/Encryption/AEAD/AEADEncryptor.cs View File

@@ -141,7 +141,7 @@ namespace Shadowsocks.Encryption.AEAD
_encCircularBuffer.Put(buf, 0, length); _encCircularBuffer.Put(buf, 0, length);
outlength = 0; outlength = 0;
logger.Debug("---Start Encryption");
logger.Trace("---Start Encryption");
if (! _encryptSaltSent) { if (! _encryptSaltSent) {
_encryptSaltSent = true; _encryptSaltSent = true;
// Generate salt // Generate salt
@@ -150,7 +150,7 @@ namespace Shadowsocks.Encryption.AEAD
InitCipher(saltBytes, true, false); InitCipher(saltBytes, true, false);
Array.Copy(saltBytes, 0, outbuf, 0, saltLen); Array.Copy(saltBytes, 0, outbuf, 0, saltLen);
outlength = saltLen; outlength = saltLen;
logger.Debug($"_encryptSaltSent outlength {outlength}");
logger.Trace($"_encryptSaltSent outlength {outlength}");
} }
if (! _tcpRequestSent) { if (! _tcpRequestSent) {
@@ -163,7 +163,7 @@ namespace Shadowsocks.Encryption.AEAD
Debug.Assert(encAddrBufLength == AddrBufLength + tagLen * 2 + CHUNK_LEN_BYTES); Debug.Assert(encAddrBufLength == AddrBufLength + tagLen * 2 + CHUNK_LEN_BYTES);
Array.Copy(encAddrBufBytes, 0, outbuf, outlength, encAddrBufLength); Array.Copy(encAddrBufBytes, 0, outbuf, outlength, encAddrBufLength);
outlength += encAddrBufLength; outlength += encAddrBufLength;
logger.Debug($"_tcpRequestSent outlength {outlength}");
logger.Trace($"_tcpRequestSent outlength {outlength}");
} }
// handle other chunks // handle other chunks
@@ -178,15 +178,15 @@ namespace Shadowsocks.Encryption.AEAD
Debug.Assert(encChunkLength == chunklength + tagLen * 2 + CHUNK_LEN_BYTES); Debug.Assert(encChunkLength == chunklength + tagLen * 2 + CHUNK_LEN_BYTES);
Buffer.BlockCopy(encChunkBytes, 0, outbuf, outlength, encChunkLength); Buffer.BlockCopy(encChunkBytes, 0, outbuf, outlength, encChunkLength);
outlength += encChunkLength; outlength += encChunkLength;
logger.Debug("chunks enc outlength " + outlength);
logger.Trace("chunks enc outlength " + outlength);
// check if we have enough space for outbuf // check if we have enough space for outbuf
if (outlength + TCPHandler.ChunkOverheadSize > TCPHandler.BufferSize) { if (outlength + TCPHandler.ChunkOverheadSize > TCPHandler.BufferSize) {
logger.Debug("enc outbuf almost full, giving up");
logger.Trace("enc outbuf almost full, giving up");
return; return;
} }
bufSize = (uint)_encCircularBuffer.Size; bufSize = (uint)_encCircularBuffer.Size;
if (bufSize <= 0) { if (bufSize <= 0) {
logger.Debug("No more data to encrypt, leaving");
logger.Trace("No more data to encrypt, leaving");
return; return;
} }
} }
@@ -201,7 +201,7 @@ namespace Shadowsocks.Encryption.AEAD
// drop all into buffer // drop all into buffer
_decCircularBuffer.Put(buf, 0, length); _decCircularBuffer.Put(buf, 0, length);
logger.Debug("---Start Decryption");
logger.Trace("---Start Decryption");
if (! _decryptSaltReceived) { if (! _decryptSaltReceived) {
bufSize = _decCircularBuffer.Size; bufSize = _decCircularBuffer.Size;
// check if we get the leading salt // check if we get the leading salt
@@ -212,7 +212,7 @@ namespace Shadowsocks.Encryption.AEAD
_decryptSaltReceived = true; _decryptSaltReceived = true;
byte[] salt = _decCircularBuffer.Get(saltLen); byte[] salt = _decCircularBuffer.Get(saltLen);
InitCipher(salt, false, false); InitCipher(salt, false, false);
logger.Debug("get salt len " + saltLen);
logger.Trace("get salt len " + saltLen);
} }
// handle chunks // handle chunks
@@ -220,7 +220,7 @@ namespace Shadowsocks.Encryption.AEAD
bufSize = _decCircularBuffer.Size; bufSize = _decCircularBuffer.Size;
// check if we have any data // check if we have any data
if (bufSize <= 0) { if (bufSize <= 0) {
logger.Debug("No data in _decCircularBuffer");
logger.Trace("No data in _decCircularBuffer");
return; return;
} }
@@ -246,10 +246,10 @@ namespace Shadowsocks.Encryption.AEAD
logger.Error($"Invalid chunk length: {chunkLen}"); logger.Error($"Invalid chunk length: {chunkLen}");
throw new CryptoErrorException(); throw new CryptoErrorException();
} }
logger.Debug("Get the real chunk len:" + chunkLen);
logger.Trace("Get the real chunk len:" + chunkLen);
bufSize = _decCircularBuffer.Size; bufSize = _decCircularBuffer.Size;
if (bufSize < CHUNK_LEN_BYTES + tagLen /* we haven't remove them */+ chunkLen + tagLen) { if (bufSize < CHUNK_LEN_BYTES + tagLen /* we haven't remove them */+ chunkLen + tagLen) {
logger.Debug("No more data to decrypt one chunk");
logger.Trace("No more data to decrypt one chunk");
return; return;
} }
IncrementNonce(false); IncrementNonce(false);
@@ -269,16 +269,16 @@ namespace Shadowsocks.Encryption.AEAD
// output to outbuf // output to outbuf
Buffer.BlockCopy(decChunkBytes, 0, outbuf, outlength, (int) decChunkLen); Buffer.BlockCopy(decChunkBytes, 0, outbuf, outlength, (int) decChunkLen);
outlength += (int)decChunkLen; outlength += (int)decChunkLen;
logger.Debug("aead dec outlength " + outlength);
logger.Trace("aead dec outlength " + outlength);
if (outlength + 100 > TCPHandler.BufferSize) if (outlength + 100 > TCPHandler.BufferSize)
{ {
logger.Debug("dec outbuf almost full, giving up");
logger.Trace("dec outbuf almost full, giving up");
return; return;
} }
bufSize = _decCircularBuffer.Size; bufSize = _decCircularBuffer.Size;
// check if we already done all of them // check if we already done all of them
if (bufSize <= 0) { if (bufSize <= 0) {
logger.Debug("No data in _decCircularBuffer, already all done");
logger.Trace("No data in _decCircularBuffer, already all done");
return; return;
} }
} }


+ 9
- 2
shadowsocks-csharp/Model/Configuration.cs View File

@@ -45,6 +45,13 @@ namespace Shadowsocks.Model
NLogConfig nLogConfig; NLogConfig nLogConfig;
private static readonly string CONFIG_FILE = "gui-config.json"; private static readonly string CONFIG_FILE = "gui-config.json";
private static readonly NLogConfig.LogLevel verboseLogLevel =
#if DEBUG
NLogConfig.LogLevel.Trace;
#else
NLogConfig.LogLevel.Debug;
#endif
[JsonIgnore] [JsonIgnore]
public bool updated = false; public bool updated = false;
@@ -185,10 +192,10 @@ namespace Shadowsocks.Model
try try
{ {
// apply changs to NLog.config // apply changs to NLog.config
config.nLogConfig.SetLogLevel(config.isVerboseLogging? NLogConfig.LogLevel.Trace: NLogConfig.LogLevel.Info);
config.nLogConfig.SetLogLevel(config.isVerboseLogging? verboseLogLevel : NLogConfig.LogLevel.Info);
NLogConfig.SaveXML(config.nLogConfig); NLogConfig.SaveXML(config.nLogConfig);
} }
catch(Exception e)
catch (Exception e)
{ {
logger.Error(e, "Cannot set the log level to NLog config file. Please check if the nlog config file exists with corresponding XML nodes."); logger.Error(e, "Cannot set the log level to NLog config file. Please check if the nlog config file exists with corresponding XML nodes.");
} }


+ 1
- 1
shadowsocks-csharp/Proxy/HttpProxy.cs View File

@@ -182,7 +182,7 @@ namespace Shadowsocks.Proxy


private bool OnLineRead(string line, object state) private bool OnLineRead(string line, object state)
{ {
logger.Debug(line);
logger.Trace(line);


if (_respondLineCount == 0) if (_respondLineCount == 0)
{ {


Loading…
Cancel
Save