OSDN Git Service

Ver.1.4.5: Add function to indicate disable clients for http/java watch.
authorwatanaby <>
Thu, 26 Oct 2006 04:48:20 +0000 (04:48 +0000)
committerwatanaby <>
Thu, 26 Oct 2006 04:48:20 +0000 (04:48 +0000)
opengate/conf/opengatesrv.conf.sample
opengate/doc/Changes.html
opengate/opengatesrv/comm-cgi.c
opengate/opengatesrv/get-param.c
opengate/opengatesrv/opengatesrv.h
opengate/opengatesrv/watch-client.c

index aa8033a..740efa2 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>\r
-<Opengate version="1.4.3">\r
+<Opengate version="1.4.5">\r
 \r
 <!-- ################################################# \r
 #    ####### NEED TO MODIFY FOLLOWING PARAMETERS #####  -->\r
                <NoPacketInterval>5400</NoPacketInterval>\r
        </ActiveCheck>\r
 \r
-       <!-- HTTP 'HELLO' request interval(sec) to Keep-Alive -->\r
-       <!--  this must be smaller than the keep-alive time of browsers -->\r
-       <HttpHelloInterval>50</HttpHelloInterval>\r
+       <!-- Watch client with Http Keep-Alive -->\r
+       <HttpWatch>\r
+               <!-- HTTP 'HELLO' request interval(sec) to Keep-Alive -->\r
+               <!--  must be smaller than keep-alive time of browsers -->\r
+               <HelloInterval>50</HelloInterval>\r
+\r
+               <!-- HTTP_USER_AGENT ignoring http watch mode -->\r
+               <!-- defined by "POSIX Extended Regular Expression" -->\r
+               <SkipAgentPattern>Safari/4</SkipAgentPattern>\r
+       </HttpWatch>\r
+\r
+       <!-- Watch client with Java Applet -->\r
+       <JavaWatch>\r
+               <!-- HTTP_USER_AGENT ignoring java watch mode -->\r
+               <!-- defined by "POSIX Extended Regular Expression" -->\r
+               <SkipAgentPattern></SkipAgentPattern>\r
+       </JavaWatch>\r
 \r
        <!-- IPFW rule number range used by opengate -->\r
        <IpfwRule>\r
index ed17ac1..b230285 100644 (file)
@@ -503,6 +503,11 @@ Ver.1.4.4 at 2006.10.25</DT>
 <DD>\r
 Add automatic start of java applet at failing http keep-alive. Modify http-get format. Add session-id. Fix read bug.\r
 </DD>\r
+<DT>\r
+Ver.1.4.5 at 2006.10.26</DT>\r
+<DD>\r
+Add function to indicate disable clients for http/java watch. \r
+</DD>\r
 \r
 </DL>\r
 <b>Please see CVS in SourceForge.net to check the file difference between versions.</b>\r
index 4dbfb90..000867b 100644 (file)
@@ -32,6 +32,8 @@ Modified by Katsuhiko Eguchi
 /* convert two-char-hex "aa" to one-number 0Xaa */ 
 #define hex2num(x)  ((x)>='A' ? ((x) & 0XDF) - 'A' +10 : ((x) - '0'))
 
+int isHttpWatchEnableClient(void);
+int isJavaWatchEnableClient(void);
 void split(char content[], char *name[], char *value[], char *next[]);
 void decode(char *string);
 
@@ -276,17 +278,24 @@ void putClientAccept(char *userid, char *sessionId, int port, int pid, char *cli
 
     /* HTTP watch mode */
   case 'H':
-    /* HTTP Keep-Alive is not standard in http/1.0 */
-    if(strcmp(getenv("SERVER_PROTOCOL"),"HTTP/1.0")!=0){
+    if(isHttpWatchEnableClient()){
       acceptDoc=GetConfValue("AcceptDocHttp");
-    } else {
+    }else if(isJavaWatchEnableClient()){
       acceptDoc=GetConfValue("AcceptDocJava");
+    }else{
+      acceptDoc=GetConfValue("AcceptDocTime");
     }
     break;
 
     /* JAVA watch mode */
   case 'J':
-    acceptDoc=GetConfValue("AcceptDocJava");
+    if(isJavaWatchEnableClient()){
+      acceptDoc=GetConfValue("AcceptDocJava");
+    }else if(isHttpWatchEnableClient()){
+      acceptDoc=GetConfValue("AcceptDocHttp");
+    }else{
+      acceptDoc=GetConfValue("AcceptDocTime");
+    }
     break;
 
     /* TIMEOUT watch mode */
@@ -359,6 +368,33 @@ void putClientAccept(char *userid, char *sessionId, int port, int pid, char *cli
   return;
 }
 
+/*****************************************************/
+/* is the client enable to keep long http connection */
+/*****************************************************/
+int isHttpWatchEnableClient(void)
+{
+  /* HTTP Keep-Alive is not standard in http/1.0 */
+  if(strcmp(getenv("SERVER_PROTOCOL"),"HTTP/1.0")==0) return FALSE;
+
+  /* some user agent does not support long HTTP Keep-Alive */
+  if(RegExMatch(getenv("HTTP_USER_AGENT"),
+                GetConfValue("HttpWatch/SkipAgentPattern"))) return FALSE;
+
+  return TRUE;
+}
+
+/********************************************/
+/* is the client enable to load Java Applet */
+/********************************************/
+int isJavaWatchEnableClient(void)
+{
+  /* some user agent does not support Java Applet */
+  if(RegExMatch(getenv("HTTP_USER_AGENT"),
+                GetConfValue("JavaWatch/SkipAgentPattern"))) return FALSE;
+
+  return TRUE;
+}
+
 /************************************/
 /* split value for indicated name   */
 /* in content  "name=value&..."     */
index 2d7a453..4ba0f80 100644 (file)
@@ -28,7 +28,7 @@ Programmed by Yoshiaki WATANABE
 #include "opengatesrv.h"
 #include "../ezxml/ezxml.h"
 
-#define CONFFILE_VERSION "1.4.3"
+#define CONFFILE_VERSION "1.4.5"
 #define SEPARATOR "/"
 
 int debug=0;
@@ -38,7 +38,6 @@ static ezxml_t xmlExtraSet=NULL;
 char *getConfValueExtra(char *name);
 char *getConfValue(char *name);
 char *convertToFacilityRaw(char *pValue);
-int RegExMatch(const char *inStr, const char *regEx);
 
 /**************************************************/
 /* Prepare Conf file to use                       */
index 2153ae2..1989dcf 100644 (file)
@@ -212,6 +212,7 @@ void CloseConfFile(void);
 void SetupConfExtra(char *userId, char *extraId);
 char *GetConfValue(char *name);
 void  InitConf();
+int RegExMatch(const char *inStr, const char *regEx);
 
 int AddAlarm(char *name, int timeout, int preceding, Sigfunc *func);
 int RemoveAlarm(char *name);
index 3fdfa18..dcca335 100644 (file)
@@ -702,7 +702,7 @@ void sendHttpKeepPage(char *userid, char *sessionId, char *language, int port)
          GetConfValue("OpengateServerName"), port);
 
   /* create httphello interval [50] */
-  snprintf(httpHelloInterval, WORDMAXLN, "%s", GetConfValue("HttpHelloInterval"));
+  snprintf(httpHelloInterval, WORDMAXLN, "%s", GetConfValue("HttpWatch/HelloInterval"));
 
   /* create httpkeep.js url[http://<serveraddr>/opengate/httpkeep.js] */
   snprintf(httpkeepJsUrl, BUFFMAXLN, "http://%s%s/%s",