MCPcopy Create free account
hub / github.com/3proxy/3proxy / handleredirect

Function handleredirect

src/auth.c:219–332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217
218
219int handleredirect(struct clientparam * param, struct ace * acentry){
220 int connected = 0;
221 int weight = 1000;
222 int res;
223 int done = 0;
224 struct chain * cur;
225 struct chain * redir = NULL;
226 int r2;
227
228 if(param->remsock != INVALID_SOCKET) {
229 return 0;
230 }
231 if(SAISNULL(&param->req) || !*SAPORT(&param->req)) {
232 return 100;
233 }
234
235 r2 = (myrand(param, sizeof(struct clientparam))%1000);
236
237 for(cur = acentry->chains; cur; cur=cur->next){
238 if(((weight = weight - cur->weight) > r2)|| done) {
239 if(weight <= 0) {
240 weight += 1000;
241 done = 0;
242 r2 = (myrand(param, sizeof(struct clientparam))%1000);
243 }
244 continue;
245 }
246 param->redirected++;
247 done = 1;
248 if(weight <= 0) {
249 weight += 1000;
250 done = 0;
251 r2 = (myrand(param, sizeof(struct clientparam))%1000);
252 }
253 if(!connected){
254 if(cur->type == R_EXTIP){
255 param->sinsl = cur->addr;
256 if(cur->next)continue;
257 return 0;
258 }
259 else if(SAISNULL(&cur->addr) && !*SAPORT(&cur->addr)){
260 if(cur->extuser){
261 if(param->extusername)
262 myfree(param->extusername);
263 param->extusername = (unsigned char *)mystrdup((char *)((*cur->extuser == '*' && param->username)? param->username : cur->extuser));
264 if(cur->extpass){
265 if(param->extpassword)
266 myfree(param->extpassword);
267 param->extpassword = (unsigned char *)mystrdup((char *)((*cur->extuser == '*' && param->password)?param->password : cur->extpass));
268 }
269 if(*cur->extuser == '*' && !param->username) return 4;
270 }
271 switch(cur->type){
272 case R_POP3:
273 param->redirectfunc = pop3pchild;
274 break;
275 case R_FTP:
276 param->redirectfunc = ftpprchild;

Callers 1

checkACLFunction · 0.85

Calls 5

myrandFunction · 0.85
myfreeFunction · 0.85
mystrdupFunction · 0.85
alwaysauthFunction · 0.85
clientnegotiateFunction · 0.85

Tested by

no test coverage detected