mirror of
				https://git.haproxy.org/git/haproxy.git/
				synced 2025-11-04 02:21:03 +01:00 
			
		
		
		
	Sin Yu's patch to permit to change the proxy from a regex was merged
with little changes :
  - req_cap/rsp_cap are not reassigned to the new proxy, they stay
    attached to the frontend
  - the actions have been renamed "reqsetbe" and "reqisetbe" for
    "set BackEnd".
  - the buffer is not reset after the switch, instead, the headers are
    parsed again by the backend
  - in Sin's patch, it was theorically possible to switch multiple times,
    but the switching track was lost, making it impossible to apply
    server responsesin the reverse order. Now switching is limited to
    1 action (separation between frontend and backend) but the filters
    remain.
Now it will be extremely easy to add other switching conditions, such
as host matching, URI matching, etc...
There's still a hard work to be done on the logs and stats.
		
	
			
		
			
				
	
	
		
			65 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			65 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/*
 | 
						|
  include/common/regex.h
 | 
						|
  This file defines everything related to regular expressions.
 | 
						|
 | 
						|
  Copyright (C) 2000-2006 Willy Tarreau - w@1wt.eu
 | 
						|
  
 | 
						|
  This library is free software; you can redistribute it and/or
 | 
						|
  modify it under the terms of the GNU Lesser General Public
 | 
						|
  License as published by the Free Software Foundation, version 2.1
 | 
						|
  exclusively.
 | 
						|
 | 
						|
  This library is distributed in the hope that it will be useful,
 | 
						|
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
						|
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
						|
  Lesser General Public License for more details.
 | 
						|
 | 
						|
  You should have received a copy of the GNU Lesser General Public
 | 
						|
  License along with this library; if not, write to the Free Software
 | 
						|
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 | 
						|
*/
 | 
						|
 | 
						|
#ifndef _COMMON_REGEX_H
 | 
						|
#define _COMMON_REGEX_H
 | 
						|
 | 
						|
#include <common/config.h>
 | 
						|
 | 
						|
#ifdef USE_PCRE
 | 
						|
#include <pcre.h>
 | 
						|
#include <pcreposix.h>
 | 
						|
#else
 | 
						|
#include <regex.h>
 | 
						|
#endif
 | 
						|
 | 
						|
/* what to do when a header matches a regex */
 | 
						|
#define ACT_ALLOW	0	/* allow the request */
 | 
						|
#define ACT_REPLACE	1	/* replace the matching header */
 | 
						|
#define ACT_REMOVE	2	/* remove the matching header */
 | 
						|
#define ACT_DENY	3	/* deny the request */
 | 
						|
#define ACT_PASS	4	/* pass this header without allowing or denying the request */
 | 
						|
#define ACT_TARPIT	5	/* tarpit the connection matching this request */
 | 
						|
#define ACT_SETBE	6	/* switch the backend */
 | 
						|
 | 
						|
struct hdr_exp {
 | 
						|
    struct hdr_exp *next;
 | 
						|
    const regex_t *preg;		/* expression to look for */
 | 
						|
    int action;				/* ACT_ALLOW, ACT_REPLACE, ACT_REMOVE, ACT_DENY */
 | 
						|
    const char *replace;		/* expression to set instead */
 | 
						|
};
 | 
						|
 | 
						|
extern regmatch_t pmatch[MAX_MATCH];
 | 
						|
 | 
						|
int exp_replace(char *dst, char *src, const char *str,	const regmatch_t *matches);
 | 
						|
const char *check_replace_string(const char *str);
 | 
						|
const char *chain_regex(struct hdr_exp **head, const regex_t *preg,
 | 
						|
			int action, const char *replace);
 | 
						|
 | 
						|
#endif /* _COMMON_REGEX_H */
 | 
						|
 | 
						|
/*
 | 
						|
 * Local variables:
 | 
						|
 *  c-indent-level: 8
 | 
						|
 *  c-basic-offset: 8
 | 
						|
 * End:
 | 
						|
 */
 |