NTCP2: Fix padding calculation for small frames

This commit is contained in:
zzz
2018-08-02 21:08:20 +00:00
parent 8d629de23d
commit 526aadb559
2 changed files with 6 additions and 1 deletions

View File

@@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 20;
public final static long BUILD = 21;
/** for example "-test" */
public final static String EXTRA = "";

View File

@@ -915,6 +915,11 @@ public class NTCPConnection implements Closeable {
* @since 0.9.36
*/
private int getPaddingSize(int dataSize, int availForPad) {
// since we're calculating with percentages, get at least a
// 0-16 range with the default 0% min 6% max,
// even for small dataSize.
if (dataSize < 256)
dataSize = 256;
// what we want to send, calculated in proportion to data size
int minSend = (int) (dataSize * _paddingConfig.getSendMin());
int maxSend = (int) (dataSize * _paddingConfig.getSendMax());