зеркало из https://github.com/microsoft/msquic.git
Fix clog sidecar printing out port in reverse order (#2051)
This commit is contained in:
Родитель
24cd2257d5
Коммит
6e15a09150
|
@ -10443,7 +10443,7 @@
|
|||
},
|
||||
"Version": 1,
|
||||
"CustomTypeClogCSharpFile": "msquic.clog.cs",
|
||||
"CustomTypeClogCSharpFileContents": "/*++\n\n Copyright (c) Microsoft Corporation.\n Licensed under the MIT License.\n\n--*/\n\nusing System;\nusing System.Text;\nusing System.Net;\nusing System.Runtime.InteropServices;\n\nnamespace msquic.clog_config\n{\n public class Types\n {\n public static string ADDR(byte[] value)\n {\n if (value.Length == 0)\n {\n return \"None\";\n }\n\n int si_family = value[0] | ((ushort)value[1] << 8);\n int sin_port = value[2] | ((ushort)value[3] << 8);\n\n byte[] sa2;\n\n string msg = \"\";\n\n switch (si_family)\n {\n case 0: //<--unspecified\n msg += $\"*:{sin_port}\";\n break;\n case 2: //< --v4\n sa2 = new byte[4];\n Array.Copy(value, 4, sa2, 0, 4);\n msg += $\"{new IPAddress(sa2).ToString()}:{sin_port}\";\n break;\n case 10: //<--v6 (linux)\n case 23: //<--v6\n sa2 = new byte[16];\n Array.Copy(value, 8, sa2, 0, 16);\n msg += $\"[{new IPAddress(sa2).ToString()}]:{sin_port}\";\n break;\n default:\n throw new NotSupportedException(\"Invalid SI_FAMILY : \" + si_family);\n }\n\n return msg;\n }\n\n public static string CID(byte [] value)\n {\n StringBuilder hex = new StringBuilder(value.Length * 2);\n foreach (byte v in value)\n {\n hex.AppendFormat(v.ToString(\"X2\"));\n }\n return hex.ToString();\n }\n\n public static string VNL(byte [] value)\n {\n if (value.Length == 0) {\n return \"Empty\";\n }\n if (value.Length < 4)\n {\n return \"Invalid\";\n }\n StringBuilder hex = new StringBuilder(\n (value.Length * 2) + // Hex length for all characters\n ((value.Length / sizeof(int)) - 1)); // Space for commas, if list is long enough.\n\n for (int i = 0; value.Length - i >= sizeof(int); i += sizeof(int))\n {\n int Version = (int)(value[i] << 24) | (int)(value[i + 1] << 16) | (int)(value[i + 2] << 8) | (int)(value[i + 3]);\n hex.Append(Version.ToString(\"X8\"));\n if (value.Length - (i + sizeof(int)) >= sizeof(int)) {\n hex.Append(\",\");\n }\n }\n return hex.ToString();\n }\n\n public static string ALPN(byte [] value)\n {\n if (value.Length == 0) {\n return \"Empty\";\n }\n UTF8Encoding utf8 = new UTF8Encoding(false, true);\n StringBuilder AlpnList = new StringBuilder(value.Length);\n uint i = 0;\n while (i < value.Length)\n {\n uint AlpnLength = value[i];\n i++;\n if (AlpnLength > value.Length - i)\n {\n // Alpn longer than remaining buffer, print to the end.\n AlpnLength = (uint)value.Length - i;\n }\n try {\n String CurrentAlpn = utf8.GetString(value, (int)i, (int)AlpnLength);\n AlpnList.Append(CurrentAlpn);\n i += AlpnLength;\n } catch {\n // Fall back to printing hex\n for (; AlpnLength > 0; AlpnLength--, i++)\n {\n AlpnList.Append(value[i].ToString(\"x2\"));\n if (AlpnLength > 1) {\n AlpnList.Append(\",\");\n }\n }\n }\n if (i < value.Length)\n {\n AlpnList.Append(';');\n }\n }\n return AlpnList.ToString();\n }\n }\n}\n",
|
||||
"CustomTypeClogCSharpFileContents": "/*++\n\n Copyright (c) Microsoft Corporation.\n Licensed under the MIT License.\n\n--*/\n\nusing System;\nusing System.Text;\nusing System.Net;\nusing System.Runtime.InteropServices;\n\nnamespace msquic.clog_config\n{\n public class Types\n {\n public static string ADDR(byte[] value)\n {\n if (value.Length == 0)\n {\n return \"None\";\n }\n\n int si_family = value[0] | ((ushort)value[1] << 8);\n int sin_port = value[3] | ((ushort)value[2] << 8);\n\n byte[] sa2;\n\n string msg = \"\";\n\n switch (si_family)\n {\n case 0: //<--unspecified\n msg += $\"*:{sin_port}\";\n break;\n case 2: //< --v4\n sa2 = new byte[4];\n Array.Copy(value, 4, sa2, 0, 4);\n msg += $\"{new IPAddress(sa2).ToString()}:{sin_port}\";\n break;\n case 10: //<--v6 (linux)\n case 23: //<--v6\n sa2 = new byte[16];\n Array.Copy(value, 8, sa2, 0, 16);\n msg += $\"[{new IPAddress(sa2).ToString()}]:{sin_port}\";\n break;\n default:\n throw new NotSupportedException(\"Invalid SI_FAMILY : \" + si_family);\n }\n\n return msg;\n }\n\n public static string CID(byte [] value)\n {\n StringBuilder hex = new StringBuilder(value.Length * 2);\n foreach (byte v in value)\n {\n hex.AppendFormat(v.ToString(\"X2\"));\n }\n return hex.ToString();\n }\n\n public static string VNL(byte [] value)\n {\n if (value.Length == 0) {\n return \"Empty\";\n }\n if (value.Length < 4)\n {\n return \"Invalid\";\n }\n StringBuilder hex = new StringBuilder(\n (value.Length * 2) + // Hex length for all characters\n ((value.Length / sizeof(int)) - 1)); // Space for commas, if list is long enough.\n\n for (int i = 0; value.Length - i >= sizeof(int); i += sizeof(int))\n {\n int Version = (int)(value[i] << 24) | (int)(value[i + 1] << 16) | (int)(value[i + 2] << 8) | (int)(value[i + 3]);\n hex.Append(Version.ToString(\"X8\"));\n if (value.Length - (i + sizeof(int)) >= sizeof(int)) {\n hex.Append(\",\");\n }\n }\n return hex.ToString();\n }\n\n public static string ALPN(byte [] value)\n {\n if (value.Length == 0) {\n return \"Empty\";\n }\n UTF8Encoding utf8 = new UTF8Encoding(false, true);\n StringBuilder AlpnList = new StringBuilder(value.Length);\n uint i = 0;\n while (i < value.Length)\n {\n uint AlpnLength = value[i];\n i++;\n if (AlpnLength > value.Length - i)\n {\n // Alpn longer than remaining buffer, print to the end.\n AlpnLength = (uint)value.Length - i;\n }\n try {\n String CurrentAlpn = utf8.GetString(value, (int)i, (int)AlpnLength);\n AlpnList.Append(CurrentAlpn);\n i += AlpnLength;\n } catch {\n // Fall back to printing hex\n for (; AlpnLength > 0; AlpnLength--, i++)\n {\n AlpnList.Append(value[i].ToString(\"x2\"));\n if (AlpnLength > 1) {\n AlpnList.Append(\",\");\n }\n }\n }\n if (i < value.Length)\n {\n AlpnList.Append(';');\n }\n }\n return AlpnList.ToString();\n }\n }\n}\n",
|
||||
"TypeEncoders": {
|
||||
"Version": 0,
|
||||
"TypeEncoder": [
|
||||
|
@ -13458,4 +13458,4 @@
|
|||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace msquic.clog_config
|
|||
}
|
||||
|
||||
int si_family = value[0] | ((ushort)value[1] << 8);
|
||||
int sin_port = value[2] | ((ushort)value[3] << 8);
|
||||
int sin_port = value[3] | ((ushort)value[2] << 8);
|
||||
|
||||
byte[] sa2;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче