protected virtual int GetRecvRandLen(int datalength, xorshift128plus rd, byte[] last_hash) { if (datalength + Server.overhead > recv_tcp_mss) { rd.init_from_bin(last_hash, datalength); return((int)(rd.next() % 521)); } if (datalength >= 1440 || datalength + Server.overhead == recv_tcp_mss) { return(0); } rd.init_from_bin(last_hash, datalength); if (datalength > 1300) { return((int)(rd.next() % 31)); } if (datalength > 900) { return((int)(rd.next() % 127)); } if (datalength > 400) { return((int)(rd.next() % 521)); } return((int)(rd.next() % (ulong)(recv_tcp_mss - datalength - Server.overhead))); //return (int)(random.next() % 1021); }
protected override int GetRandLen(int datalength, xorshift128plus random, byte[] last_hash) { int other_data_size = datalength + Server.overhead; // 一定要在random使用前初始化,以保证服务器与客户端同步,保证包大小验证结果正确 random.init_from_bin(last_hash, datalength); if (other_data_size >= data_size_list0[data_size_list0.Length - 1]) { if (datalength >= 1440) { return(0); } if (datalength > 1300) { return((int)(random.next() % 31)); } if (datalength > 900) { return((int)(random.next() % 127)); } if (datalength > 400) { return((int)(random.next() % 521)); } return((int)(random.next() % 1021)); } int pos = FindPos(data_size_list0, other_data_size); int final_pos = pos + (int)(random.next() % (ulong)(data_size_list0.Length - pos)); return(data_size_list0[final_pos] - other_data_size); }
protected override void InitDataSizeList() { xorshift128plus random = new xorshift128plus(); byte[] newKey = new byte[Server.key.Length]; Server.key.CopyTo(newKey, 0); for (int i = 0; i < 8; i++) { newKey[i] ^= key_change_datetime_key_bytes[i]; } random.init_from_bin(newKey); int len = (int)(random.next() % (8 + 16) + (4 + 8)); List <int> data_list = new List <int>(); for (int i = 0; i < len; ++i) { data_list.Add((int)(random.next() % 2340 % 2040 % 1440)); } data_list.Sort(); int old_len = data_list.Count; CheckAndPatchDataSize(data_list, random); if (old_len != data_list.Count) { data_list.Sort(); } data_size_list0 = data_list.ToArray(); }
protected int GetRandStartPos(int rand_len, xorshift128plus rd) { if (rand_len > 0) { return((int)(rd.next() % 8589934609 % (ulong)rand_len)); } return(0); }
protected void CheckAndPatchDataSize(List <int> data_list, xorshift128plus random) { if (data_list[data_list.Count - 1] < 1300 && data_list.Count < 64) { data_list.Add((int)(random.next() % 2340 % 2040 % 1440)); CheckAndPatchDataSize(data_list, random); } }
protected override int GetRandLen(int datalength, xorshift128plus random, byte[] last_hash) { int other_data_size = datalength + Server.overhead; if (other_data_size >= data_size_list0[data_size_list0.Length - 1]) { return(0); } int pos = FindPos(data_size_list0, other_data_size); return(data_size_list0[pos] - other_data_size); }
protected override int GetRandLen(int datalength, xorshift128plus rd, byte[] last_hash) { rd.init_from_bin(last_hash, datalength); var other_data_size = datalength + Server.overhead; if (other_data_size >= data_size_list0[data_size_list0.Length - 1]) { return(0); } var pos = FindPos(data_size_list0, other_data_size); return(data_size_list0[pos] - other_data_size); }
protected override void InitDataSizeList() { xorshift128plus random = new xorshift128plus(); random.init_from_bin(Server.key); int len = (int)(random.next() % (8 + 16) + (4 + 8)); List <int> data_list = new List <int>(); for (int i = 0; i < len; ++i) { data_list.Add((int)(random.next() % 2340 % 2040 % 1440)); } data_list.Sort(); data_size_list0 = data_list.ToArray(); }
protected override int GetRandLen(int datalength, xorshift128plus random, byte[] last_hash) { int other_data_size = datalength + Server.overhead; if (other_data_size >= data_size_list0[data_size_list0.Length - 1]) { return(0); } random.init_from_bin(last_hash, datalength); int pos = FindPos(data_size_list0, other_data_size); int final_pos = pos + (int)(random.next() % (ulong)(data_size_list0.Length - pos)); return(data_size_list0[final_pos] - other_data_size); }
protected override int GetSendRandLen(int datalength, xorshift128plus rd, byte[] last_hash) { if (datalength + Server.overhead > send_tcp_mss) { rd.init_from_bin(last_hash, datalength); return((int)(rd.next() % 521)); } if (datalength >= 1440 || datalength + Server.overhead == recv_tcp_mss) { return(0); } rd.init_from_bin(last_hash, datalength); var pos = FindPos(data_size_list, datalength + Server.overhead); var final_pos = pos + (int)(rd.next() % (ulong)data_size_list.Length); if (final_pos < data_size_list.Length) { return(data_size_list[final_pos] - datalength - Server.overhead); } pos = FindPos(data_size_list2, datalength + Server.overhead); final_pos = pos + (int)(rd.next() % (ulong)data_size_list2.Length); if (final_pos < data_size_list2.Length) { return(data_size_list2[final_pos] - datalength - Server.overhead); } if (final_pos < pos + data_size_list2.Length - 1) { return(0); } if (datalength > 1300) { return((int)(rd.next() % 31)); } if (datalength > 900) { return((int)(rd.next() % 127)); } if (datalength > 400) { return((int)(rd.next() % 521)); } return((int)(rd.next() % 1021)); }
protected virtual int GetRandLen(int datalength, xorshift128plus rd, byte[] last_hash) { if (datalength > 1440) { return(0); } rd.init_from_bin(last_hash, datalength); if (datalength > 1300) { return((int)(rd.next() % 31)); } if (datalength > 900) { return((int)(rd.next() % 127)); } if (datalength > 400) { return((int)(rd.next() % 521)); } return((int)(rd.next() % 1021)); }
protected override int GetRandLen(int datalength, xorshift128plus random, byte[] last_hash) { if (datalength >= 1440) { return(0); } random.init_from_bin(last_hash, datalength); int pos = FindPos(data_size_list, datalength + Server.overhead); int final_pos = pos + (int)(random.next() % (ulong)(data_size_list.Length)); if (final_pos < data_size_list.Length) { return(data_size_list[final_pos] - datalength - Server.overhead); } pos = FindPos(data_size_list2, datalength + Server.overhead); final_pos = pos + (int)(random.next() % (ulong)(data_size_list2.Length)); if (final_pos < data_size_list2.Length) { return(data_size_list2[final_pos] - datalength - Server.overhead); } if (final_pos < pos + data_size_list2.Length - 1) { return(0); } if (datalength > 1300) { return((int)(random.next() % 31)); } if (datalength > 900) { return((int)(random.next() % 127)); } if (datalength > 400) { return((int)(random.next() % 521)); } return((int)(random.next() % 1021)); }
protected override void InitDataSizeList() { var rd = new xorshift128plus(); rd.init_from_bin(Server.key); var len = (int)(rd.next() % (8 + 16) + (4 + 8)); var data_list = new List <int>(); for (var i = 0; i < len; ++i) { data_list.Add((int)(rd.next() % 2340 % 2040 % 1440)); } data_list.Sort(); var old_len = data_list.Count; CheckAndPatchDataSize(data_list, rd); if (old_len != data_list.Count) { data_list.Sort(); } data_size_list0 = data_list.ToArray(); }
protected new void InitDataSizeList() { xorshift128plus random = new xorshift128plus(); random.init_from_bin(Server.key); int len = (int)(random.next() % (8 + 16) + (4 + 8)); List <int> data_list = new List <int>(); for (int i = 0; i < len; ++i) { data_list.Add((int)(random.next() % 2340 % 2040 % 1440)); } data_list.Sort(); int old_len = data_list.Count; CheckAndPatchDataSize(data_list, random); if (old_len != data_list.Count) { data_list.Sort(); } data_size_list0 = data_list.ToArray(); }
protected void InitDataSizeList() { var rd = new xorshift128plus(0); rd.init_from_bin(Server.key); var len = (int)(rd.next() % 8 + 4); var data_list = new List <int>(); for (var i = 0; i < len; ++i) { data_list.Add((int)(rd.next() % 2340 % 2040 % 1440)); } data_list.Sort(); data_size_list = data_list.ToArray(); len = (int)(rd.next() % 16 + 8); data_list.Clear(); for (var i = 0; i < len; ++i) { data_list.Add((int)(rd.next() % 2340 % 2040 % 1440)); } data_list.Sort(); data_size_list2 = data_list.ToArray(); }
protected virtual void InitDataSizeList() { xorshift128plus random = new xorshift128plus(); random.init_from_bin(Server.key); int len = (int)(random.next() % 8 + 4); List <int> data_list = new List <int>(); for (int i = 0; i < len; ++i) { data_list.Add((int)(random.next() % 2340 % 2040 % 1440)); } data_list.Sort(); data_size_list = data_list.ToArray(); len = (int)(random.next() % 16 + 8); data_list.Clear(); for (int i = 0; i < len; ++i) { data_list.Add((int)(random.next() % 2340 % 2040 % 1440)); } data_list.Sort(); data_size_list2 = data_list.ToArray(); }
protected int UdpGetRandLen(xorshift128plus rd, byte[] last_hash) { rd.init_from_bin(last_hash); return((int)(rd.next() % 127)); }