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

Function h_ace

src/conf.c:1065–1237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1063
1064
1065static int h_ace(int argc, unsigned char **argv){
1066 int res = 0;
1067 int offset = 0;
1068 struct ace *acl = NULL;
1069 struct bandlim * nbl;
1070 struct trafcount * tl;
1071
1072 if(!strcmp((char *)argv[0], "allow")){
1073 res = ALLOW;
1074 }
1075 else if(!strcmp((char *)argv[0], "deny")){
1076 res = DENY;
1077 }
1078 else if(!strcmp((char *)argv[0], "redirect")){
1079 res = REDIRECT;
1080 offset = 2;
1081 }
1082 else if(!strcmp((char *)argv[0], "bandlimin")||!strcmp((char *)argv[0], "bandlimout")){
1083 res = BANDLIM;
1084 offset = 1;
1085 }
1086 else if(!strcmp((char *)argv[0], "nobandlimin")||!strcmp((char *)argv[0], "nobandlimout")){
1087 res = NOBANDLIM;
1088 }
1089 else if(!strcmp((char *)argv[0], "countin")){
1090 res = COUNTIN;
1091 offset = 3;
1092 }
1093 else if(!strcmp((char *)argv[0], "nocountin")){
1094 res = NOCOUNTIN;
1095 }
1096 else if(!strcmp((char *)argv[0], "countout")){
1097 res = COUNTOUT;
1098 offset = 3;
1099 }
1100 else if(!strcmp((char *)argv[0], "nocountout")){
1101 res = NOCOUNTOUT;
1102 }
1103 acl = make_ace(argc - (offset+1), argv + (offset + 1));
1104 if(!acl) {
1105 fprintf(stderr, "Unable to parse ACL entry, line %d\n", linenum);
1106 return(1);
1107 }
1108 acl->action = res;
1109 switch(acl->action){
1110 case REDIRECT:
1111 acl->chains = myalloc(sizeof(struct chain));
1112 memset(acl->chains, 0, sizeof(struct chain));
1113 if(!acl->chains) {
1114 fprintf(stderr, "No memory for ACL entry, line %d\n", linenum);
1115 return(2);
1116 }
1117 acl->chains->type = R_HTTP;
1118 if(!getip46(46, argv[1], (struct sockaddr *)&acl->chains->addr)) return 5;
1119 *SAPORT(&acl->chains->addr) = htons((unsigned short)atoi((char *)argv[2]));
1120 acl->chains->weight = 1000;
1121 acl->chains->extuser = NULL;
1122 acl->chains->extpass = NULL;

Callers

nothing calls this directly

Calls 4

make_aceFunction · 0.85
myallocFunction · 0.85
mystrdupFunction · 0.85
getrotateFunction · 0.85

Tested by

no test coverage detected