Thread: [Netadm-devel] gwc/sample Makefile,NONE,1.1 confilter.c,NONE,1.1 test.html,NONE,1.1
Status: Beta
Brought to you by:
linuxpark
From: linuxpark <lin...@us...> - 2006-04-06 15:14:39
|
Update of /cvsroot/netadm/gwc/sample In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12305 Added Files: Makefile confilter.c test.html Log Message: Initial Check-in of the library for contents filtering. ported C library of dansgardian's oop. --- NEW FILE: test.html --- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><title>Gray Watson's Multimedia Files</title><!--skipfrom--> <meta http-equiv="pics-label" content="(PICS-1.1 "http://www.icra.org/ratingsv02.html" labels for "http://mm.256.com/" generic true ratings (cz 1 lb 1 lc 1 nf 1 ng 1 og 1 oh 1 vb 1 vc 1 vf 1) "http://www.rsac.org/ratingsv01.html" labels for "http://mm.256.com/" generic true ratings (n0 s4 v4 l2) "http://www.classify.org/safesurf/" labels for "http://mm.256.com/" generic true ratings (SS~~000 5 SS~~001 6 SS~~004 6 SS~~005 6 SS~~009 6) "http://www.weburbia.com/safe/ratings.htm" labels for "http://mm.256.com/" generic true ratings (s 2) )"></head> <body alink="#ff3300" bgcolor="#ffffff" link="#aa0000" text="#000000" vlink="#005522"> <!-- header.html starts at the top of the document ^^ --> <!-- NOTE: it doesn't work well to put the H1 and the warning in here because other html files use this not just the 200X.html files. --> <!-- end of header --> <!--skipto--> <h1> <a href="http://256.com/gray/">Gray Watson's</a> <br> Multimedia Files <br> Has Been Shutdown </h1> <p> Sorry. I've decided to take this site down. Using up too much bandwidth. Sorry. </p> <!-- start of footer --> <!--skipfrom--> <p> <font size="-1"> Brought to you by <a href="http://256.com/gray/">Gray Watson</a> <br> This page should be <a href="http://validator.w3.org/check/referer">W3C Valid XHTML</a> and should work with most browsers. <br> http://mm.256.com/ </font> </p> <!-- plugs --> <p> <a href="http://mailnull.com/">Free Spam Protection</a> <a href="http://geekleft.org/">My Political T-Shirts</a> <a href="http://dmalloc.com/">Memory Debug Library</a> <a href="http://256.com/gray/shareware_registration_module/integrated_selling_library.html">Shareware Help Wanted</a> </p> <!-- end of footer including /BODY and /HTML --> <!--skipto--> </body></html> --- NEW FILE: confilter.c --- /* Title : confilter.c Author : Jeho-Park <lin...@gm...> Created date : 2006. 04. 06. (thu) 23:54:35 KST Description : sample code */ #ident "@(#) $Header: /cvsroot/netadm/gwc/sample/confilter.c,v 1.1 2006/04/06 15:14:32 linuxpark Exp $" #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include "global.h" #include "naufilter.h" #include "sysutil.h" confilter_conf_t config; static void usage () { printf ("[usage] html\n"); } static void loadconf () { config.pics_rsac_violence = 2; config.pics_rsac_sex = 2 ; config.pics_rsac_nudity = 2; config.pics_rsac_language = 2; config.pics_icra_chat = 0; config.pics_icra_moderatedchat = 1; config.pics_icra_languagesexual = 0; config.pics_icra_languageprofanity = 0; config.pics_icra_languagemildexpletives = 1; config.pics_icra_nuditygraphic = 0; config.pics_icra_nuditymalegraphic = 0; config.pics_icra_nudityfemalegraphic = 0; config.pics_icra_nuditytopless = 0; config.pics_icra_nuditybottoms = 0; config.pics_icra_nuditysexualacts = 0; config.pics_icra_nudityobscuredsexualacts = 0; config.pics_icra_nuditysexualtouching = 0; config.pics_icra_nuditykissing = 0; config.pics_icra_nudityartistic = 1; config.pics_icra_nudityeducational = 1; config.pics_icra_nuditymedical = 1; config.pics_icra_drugstobacco = 0; config.pics_icra_drugsalcohol = 0; config.pics_icra_drugsuse = 0; config.pics_icra_gambling = 0; config.pics_icra_weaponuse = 0; config.pics_icra_intolerance = 0; config.pics_icra_badexample = 0; config.pics_icra_pgmaterial = 0; config.pics_icra_violencerape = 0; config.pics_icra_violencetohumans = 0; config.pics_icra_violencetoanimals = 0; config.pics_icra_violencetofantasy = 0; config.pics_icra_violencekillinghumans = 0; config.pics_icra_violencekillinganimals = 0; config.pics_icra_violencekillingfantasy = 0; config.pics_icra_violenceinjuryhumans = 0; config.pics_icra_violenceinjuryanimals = 0; config.pics_icra_violenceinjuryfantasy = 0; config.pics_icra_violenceartisitic = 0; config.pics_icra_violenceeducational = 0; config.pics_icra_violencemedical = 0; config.pics_icra_violencesports = 0; config.pics_icra_violenceobjects = 0; config.pics_evaluweb_rating = 1; config.pics_cybernot_sex = 3; config.pics_cybernot_other = 3; config.pics_safesurf_agerange = 3; config.pics_safesurf_profanity = 3; config.pics_safesurf_heterosexualthemes = 3; config.pics_safesurf_homosexualthemes = 3; config.pics_safesurf_nudity = 3; config.pics_safesurf_violence = 3; config.pics_safesurf_sexviolenceandprofanity = 3; config.pics_safesurf_intolerance = 3; config.pics_safesurf_druguse = 3; config.pics_safesurf_otheradultthemes = 3; config.pics_safesurf_gambling = 3; config.pics_weburbia_rating = 1; config.pics_vancouver_multiculturalism = 0; config.pics_vancouver_educationalcontent = 0; config.pics_vancouver_environmentalawareness = 0; config.pics_vancouver_tolerance = 0; config.pics_vancouver_violence = 0; config.pics_vancouver_sex = 0; config.pics_vancouver_profanity = 0; config.pics_vancouver_safety = 0; config.pics_vancouver_canadiancontent = 0; config.pics_vancouver_commercialcontent = 0; config.pics_vancouver_gambling = 0; } static int init_regx (confilter_session_t *sess ) { memset (sess, 0, sizeof (confilter_session_t)); if (init_precompileregexps (sess) != TRUE) return FALSE; sess->conf = &config; return TRUE; } static int free_regx (confilter_session_t *sess ) { if (free_precompileregexps (sess) != TRUE) return FALSE; return TRUE; } int main (int argc, char **argv) { confilter_session_t sess; char *buf; int len; int ret = 1; int sid; if (argc != 2) { usage (); _exit(0); } if (access (argv[1], R_OK) < 0 ) { printf ("Can't access file (%s)\n", argv[1]); usage (); _exit(0); } /* * 1. D A E M O N I N I T I A L I Z A T I O N T I M E */ /* 1-1. TODO: load PIC parameter during daemon initializing time */ loadconf (); /* 1-2. TODO: initialize hash table based on URL(http://xxx/page.html) */ #ifndef DEBUG_MLEAK for (sid = 0; sid < SZMAXSESS; sid ++) { #else while (1) { #endif if (init_regx (&sess) != TRUE ) { printf ("failed to init regx \n"); ret = -1; goto EXIT; } /* * 2. R U N T I M E, P R O X Y S E V I C E T I M E */ /* 2.1. TODO: searching hash table then * if daemon can't find key, * start checking from 2.2 ~ * if daemon find this URL key, drop this http request */ /* 2.2. get HTTP body from server */ buf = loadfile (argv[1], &len); if (!buf || !len) { printf ("session(%d) failed to load file \n", sid); ret = -1; goto EXIT1; } /* 2.3. checking * sid must be managed by main proxy * and * must be thread safe, counted by slot */ if ( checkPICS (&sess, buf, len) != TRUE) { printf ("session(%d) checkPICS met some error\n", sid); ret = -1; goto EXIT2; } /* 2.4. apply policy. * if this page is naughty, insert to hash table above. * so this page will continue to be droped without checking again. */ if (sess.isnaughty ) { printf ("session(%d) naughty page\n", sid); } else { printf ("session(%d) nomal page\n", sid); } /* 2.5. free request resource whenever exit checking. */ EXIT2: free (buf); EXIT1: if (free_regx (&sess) != TRUE ) { printf ("session(%d):failed to destory regx in session\n", sid); _exit (ret); } EXIT: continue; } return 1; } --- NEW FILE: Makefile --- # # # Title : Makefile # Author : Jeho-Park <lin...@gm...> # Created date : 2006. 04. 06. (thu) 23:54:35 KST # Description : # #ident "@(#) $Header: /cvsroot/netadm/gwc/sample/Makefile,v 1.1 2006/04/06 15:14:32 linuxpark Exp $" include ../Makefile.tmpl TARGET = confilter OBJS = confilter.o all : $(TARGET) $(TARGET): $(OBJS) $(CC) -o $@ $(OBJS) $(LIBSYS) .c.o: $(CC) $(CFLAGS) $(INCLUDE) -c $< tags: ctags *.c *.h clean: rm -f *.o core tags *.bak $(TARGET) depend: $(MAKEDEPEND) -- $(CFLAGS) -- *.c rm -f Makefile.bak # DO NOT DELETE THIS LINE -- make depend depends on it. |