Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ InternalIsValid()

static unsafe bool System.IPv6AddressHelper.InternalIsValid ( char * name,
int start,
ref int end,
bool validateStrictAddress )
inlinestaticprivate

Definition at line 81 of file IPv6AddressHelper.cs.

82 {
83 int num = 0;
84 int num2 = 0;
85 bool flag = false;
86 bool flag2 = false;
87 bool flag3 = false;
88 bool flag4 = true;
89 int start2 = 1;
90 if (name[start] == ':' && (start + 1 >= end || name[start + 1] != ':'))
91 {
92 return false;
93 }
94 int i;
95 for (i = start; i < end; i++)
96 {
97 bool num3;
98 if (!flag3)
99 {
100 num3 = Uri.IsHexDigit(name[i]);
101 }
102 else
103 {
104 if (name[i] < '0')
105 {
106 goto IL_0079;
107 }
108 num3 = name[i] <= '9';
109 }
110 if (num3)
111 {
112 num2++;
113 flag4 = false;
114 continue;
115 }
116 goto IL_0079;
117 IL_0079:
118 if (num2 > 4)
119 {
120 return false;
121 }
122 if (num2 != 0)
123 {
124 num++;
125 start2 = i - num2;
126 }
127 char c = name[i];
128 if ((uint)c <= 46u)
129 {
130 if (c == '%')
131 {
132 while (true)
133 {
134 if (++i == end)
135 {
136 return false;
137 }
138 if (name[i] == ']')
139 {
140 break;
141 }
142 if (name[i] != '/')
143 {
144 continue;
145 }
146 goto IL_011c;
147 }
148 goto IL_00ee;
149 }
150 if (c != '.')
151 {
152 goto IL_015c;
153 }
154 if (flag2)
155 {
156 return false;
157 }
158 i = end;
159 if (!IPv4AddressHelper.IsValid(name, start2, ref i, allowIPv6: true, notImplicitFile: false, unknownScheme: false))
160 {
161 return false;
162 }
163 num++;
164 flag2 = true;
165 i--;
166 }
167 else
168 {
169 if (c == '/')
170 {
171 goto IL_011c;
172 }
173 if (c != ':')
174 {
175 if (c == ']')
176 {
177 goto IL_00ee;
178 }
179 goto IL_015c;
180 }
181 if (i > 0 && name[i - 1] == ':')
182 {
183 if (flag)
184 {
185 return false;
186 }
187 flag = true;
188 flag4 = false;
189 }
190 else
191 {
192 flag4 = true;
193 }
194 }
195 goto IL_015e;
196 IL_015c:
197 return false;
198 IL_011c:
199 if (validateStrictAddress)
200 {
201 return false;
202 }
203 if (num == 0 || flag3)
204 {
205 return false;
206 }
207 flag3 = true;
208 flag4 = true;
209 goto IL_015e;
210 IL_015e:
211 num2 = 0;
212 continue;
213 IL_00ee:
214 start = i;
215 i = end;
216 }
217 if (flag3 && (num2 < 1 || num2 > 2))
218 {
219 return false;
220 }
221 int num4 = 8 + (flag3 ? 1 : 0);
222 if (!flag4 && num2 <= 4 && (flag ? (num < num4) : (num == num4)))
223 {
224 if (i == end + 1)
225 {
226 end = start + 1;
227 return true;
228 }
229 return false;
230 }
231 return false;
232 }

References System.Uri.IsHexDigit(), System.IPv4AddressHelper.IsValid(), and System.start.

Referenced by System.IPv6AddressHelper.IsValid().