OSDN Git Service

Ver.1.4.4: Add auto-start of applet at failing http watch. Modify http-get form....
authorwatanaby <>
Wed, 25 Oct 2006 09:22:08 +0000 (09:22 +0000)
committerwatanaby <>
Wed, 25 Oct 2006 09:22:08 +0000 (09:22 +0000)
50 files changed:
opengate/conf/opengatesrv.conf.sample
opengate/doc/Changes.html
opengate/javahtml/Opengate.class
opengate/javahtml/Opengate.jar
opengate/javahtml/Opengate.java
opengate/javahtml/OpengateClient.class
opengate/javahtml/en/accept-http.html
opengate/javahtml/en/accept-java.html
opengate/javahtml/en/accept-time.html
opengate/javahtml/en/deny-ssl.html
opengate/javahtml/en/deny.html
opengate/javahtml/en/httpkeep.html
opengate/javahtml/en/index-ssl.html
opengate/javahtml/en/index.html
opengate/javahtml/en/topindex.html
opengate/javahtml/httpkeep.js
opengate/javahtml/ja/accept-http.html
opengate/javahtml/ja/accept-java.html
opengate/javahtml/ja/accept-time.html
opengate/javahtml/ja/deny-ssl.html
opengate/javahtml/ja/deny.html
opengate/javahtml/ja/httpkeep.html
opengate/javahtml/ja/index-ssl.html
opengate/javahtml/ja/index.html
opengate/javahtml/ja/topindex.html
opengate/opengatesrv/Makefile
opengate/opengatesrv/addr-convert.c
opengate/opengatesrv/auth-ftps.c
opengate/opengatesrv/auth-pam.c
opengate/opengatesrv/auth-pop3s.c
opengate/opengatesrv/auth-rad.c
opengate/opengatesrv/comm-arp.c
opengate/opengatesrv/comm-auth.c
opengate/opengatesrv/comm-cgi.c
opengate/opengatesrv/comm-ip6fw.c
opengate/opengatesrv/comm-ipfw.c
opengate/opengatesrv/comm-ndp.c
opengate/opengatesrv/comm-userdb.c
opengate/opengatesrv/ctrl-alarms.c
opengate/opengatesrv/ctrl-firewall.c
opengate/opengatesrv/get-mac.c
opengate/opengatesrv/get-param.c
opengate/opengatesrv/htmltemplate.c
opengate/opengatesrv/main.c
opengate/opengatesrv/opengateauth.c
opengate/opengatesrv/opengatefwd.c
opengate/opengatesrv/opengatesrv.h
opengate/opengatesrv/test-watch-client.c
opengate/opengatesrv/utilities.c
opengate/opengatesrv/watch-client.c

index 916e996..aa8033a 100644 (file)
 #      see the information of ExtraSet at the end of this file.\r
 #    ###################################################  --> \r
 \r
-       <!-- Set 1 to write many information to syslog -->\r
        <!-- Set 0 to write only open/close and error messages to syslog -->\r
-       <Debug>0</Debug>\r
+       <!-- Set 1 to write some information adding to 0 -->\r
+       <!-- Set 2 to write many information to syslog -->\r
+       <Debug>1</Debug>\r
 \r
        <!-- client usage watch mode in default('Java', 'Http', or 'Time') -->\r
        <WatchMode>Http</WatchMode>\r
index efb380a..ed17ac1 100644 (file)
@@ -498,6 +498,11 @@ Ver.1.4.3 at 2006.10.20</DT>
 <DD>\r
 Move JavaScript from html-file to external js-file. Modify some message.\r
 </DD>\r
+<DT>\r
+Ver.1.4.4 at 2006.10.25</DT>\r
+<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
 \r
 </DL>\r
 <b>Please see CVS in SourceForge.net to check the file difference between versions.</b>\r
index 16d6347..83df863 100644 (file)
Binary files a/opengate/javahtml/Opengate.class and b/opengate/javahtml/Opengate.class differ
index 0f1f0f0..64b7a6d 100644 (file)
Binary files a/opengate/javahtml/Opengate.jar and b/opengate/javahtml/Opengate.jar differ
index d841096..13154a2 100644 (file)
@@ -37,6 +37,7 @@ public class Opengate extends Applet{
   String hostname;\r
   int port;\r
   String userid;\r
+  String sessionId;\r
   String language;\r
   int intlang=0;/* if language is japanese, set 1*/\r
   OpengateClient client;\r
@@ -50,6 +51,7 @@ public class Opengate extends Applet{
      /* Get Applet Parameters */\r
     port=Integer.parseInt(getParameter("port"));\r
     userid=getParameter("user");\r
+    sessionId=getParameter("sessionid");\r
     hostname =getCodeBase().getHost();\r
     language = getParameter("lang");\r
     if(language.equals("ja")) intlang=1;\r
@@ -71,7 +73,7 @@ public class Opengate extends Applet{
     }\r
 \r
      /* Connect to Server */\r
-    client=new OpengateClient(hostname, port, userid, intlang, this);\r
+    client=new OpengateClient(hostname, port, userid, sessionId, intlang, this);\r
     client.start();\r
   }\r
   public void msgout(String msg){\r
@@ -98,6 +100,7 @@ class OpengateClient extends Thread{
   String hostname;           /* java download host name */\r
   Socket socket;             /* Socket for server */\r
   String userid;\r
+  String sessionId;\r
   PrintStream outStream;     /* output stream to server */\r
   BufferedReader inStream;   /* input stream from server */\r
   String currentReply;       /* reserve last reply from server */\r
@@ -107,10 +110,11 @@ class OpengateClient extends Thread{
 \r
   /* Instance Creater */\r
   public OpengateClient(String hostname, int port, \r
-                       String userid, int intlang, Opengate main){\r
+                       String userid, String sessionId, int intlang, Opengate main){\r
     this.hostname=hostname;\r
     this.port=port;\r
     this.userid=userid;\r
+    this.sessionId=sessionId;\r
     this.main=main;\r
     this.intlang=intlang;\r
     onLine=false;\r
@@ -191,7 +195,7 @@ class OpengateClient extends Thread{
       disconnect();\r
       return;\r
     }\r
-    putLine(userid);\r
+    putLine(userid+"-"+sessionId);\r
     if(getLine().indexOf("accept")==-1){\r
       if(intlang==1)\r
        main.msgout("\83T\81[\83o\82©\82çAccept\82ª\91\97\82ç\82ê\82Ä\97\88\82Ü\82¹\82ñ");\r
index 65dcade..0ab932d 100644 (file)
Binary files a/opengate/javahtml/OpengateClient.class and b/opengate/javahtml/OpengateClient.class differ
index 3960129..05f5122 100644 (file)
@@ -1,18 +1,60 @@
 <html>
 <head>
 <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
-<meta http-equiv="Pragma" content="no-cache">
-<meta http-equiv="Refresh" content="0; URL=%%HTTPKEEPURL%%">
-
 <title>Opengatemain</title>
 </head>
 <body>
 
 <p>You can use the network. 
-If you cannot move to a new page automatically, 
-click <a href="%%HTTPKEEPURL%%">Jump</a>.
-</p>
 
-</body>
-</html>
+<p>When you finish to use the network, stop your WEB browser. 
+You will be disconnected from the network automatically.</p>
+
+<script language="JavaScript">
+<!--
+// usually the page is jumped to httpkeep.html
+location.replace(%%HTTPKEEPURL%%);
+
+// if not jumped, process following 
+if(!navigator.javaEnabled()){
+    document.write("<p><b>Java is disabled. Change it.</b></p>");
+}
+//-->
+</script>
+<noscript>
+<p><b>JavaScript is disabled. Change it.</b></p>
+</noscript>
+
+<hr />
+<div align="center">
+   <applet code="Opengate.class" archive="Opengate.jar"
+    codebase="%%OPENGATEDIR%%" width="600" height="30" >
+    <param name=port value="%%OPENGATEPORT%%">
+    <param name=user value="%%USERID%%">
+    <param name=sessionid value="%%SESSIONID%%">
+    <param name=lang value="%%LANGUAGE%%">
+   </applet>
+</div>
+
+<hr />
+
+<p>If yellow bar is not displayed between above two lines, please click <a href="%%TERMINATEURL%%"><b>TERMINATE</b></a> 
+and close your browser. 
+
+<SCRIPT LANGUAGE="JavaScript">
+<!--
+  window.open("%%STARTURL%%","window1");
+//-->
+</SCRIPT>
+
+<table bgcolor="lightyellow" border="1">
+<tr><td>
+Please leave this window as it is (or minimized), and work on another window. 
+If another working window is not popped up, 
+click <a href="%%STARTURL%%" target="_blank"><h3>[Start Page]</h3></a>
+ to open.
+</td></tr>
+</table>
 
+</BODY>
+</HTML>
index 7dca300..c730615 100644 (file)
@@ -13,7 +13,7 @@ You will be disconnected from the network automatically.</p>
 <script language="JavaScript">
 <!--
 if(!navigator.javaEnabled()){
-    document.write("<p><b>Java is disabled.</b></p>");
+    document.write("<p><b>Java is disabled. Change it.</b></p>");
 }
 //-->
 </script>
@@ -27,6 +27,7 @@ if(!navigator.javaEnabled()){
     codebase="%%OPENGATEDIR%%" width="600" height="30" >
     <param name=port value="%%OPENGATEPORT%%">
     <param name=user value="%%USERID%%">
+    <param name=sessionid value="%%SESSIONID%%">
     <param name=lang value="%%LANGUAGE%%">
    </applet>
 </div>
@@ -35,15 +36,15 @@ if(!navigator.javaEnabled()){
 
 <p>If yellow bar is not displayed between above two lines, Java does not run. 
 In this case, please click <a href="%%TERMINATEURL%%"><b>TERMINATE</b></a>, 
- close your browser, and try to select HTTP in authentication page. 
-Java will run, if you download JavaPlugIn from <a href=http://java.com/ja/index.jsp><b>java.com</b></a>.</p>
+ close your browser, and try to select other watch mode in authentication page. 
+Or you can run Java, if you download JavaPlugIn from <a href=http://java.com/ja/index.jsp><b>java.com</b></a>.</p>
 
 
-<SCRIPT LANGUAGE="JavaScript">
+<script language="JavaScript">
 <!--
   window.open("%%STARTURL%%","window1");
 //-->
-</SCRIPT>
+</script>
 
 <table bgcolor="lightyellow" border="1">
 <tr><td>
@@ -54,6 +55,6 @@ click <a href="%%STARTURL%%" target="_blank"><h3>[Start Page]</h3></a>
 </td></tr>
 </table>
 
-</BODY>
-</HTML>
+</body>
+</html>
 
index f83f182..5bb727d 100644 (file)
@@ -5,10 +5,10 @@
 </head>
 <body>
 
-<p>You can use the network. Network will be closed after duration entered.</p>
+<p>You can use the network. Network will be closed at the timeout of entered duration.</p>
 <p>When you finish to use the network, click the link:
 <a href="%%TERMINATEURL%%"></a> for security.</p>
-<p>Please use this method only when other methods are failed.</p>
+<p>Please use this method only when other watch modes cannot be used.</p>
 
 <script language="JavaScript">
 <!--
index 07b4a07..576b934 100644 (file)
@@ -7,6 +7,6 @@
 <P>
 Network authentication failed. Please retry again.
 </P>
-<A HREF=https://%%AUTHCGIURL%%?%%ADDR4%%&en><h3>BACK</h3></A>
+<A HREF="https://%%AUTHCGIURL%%?addr=%%ADDR4%%&lang=en"><h3>BACK</h3></A>
 </BODY>
 </HTML>
index b0346cd..ec1e92c 100644 (file)
@@ -7,6 +7,6 @@
 <P>
 Network authentication failed. Please retry again.
 </P>
-<A HREF=http://%%AUTHCGIURL%%?%%ADDR4%%&en><h3>BACK</h3></A>
+<A HREF="http://%%AUTHCGIURL%%?addr=%%ADDR4%%&lang=en"><h3>BACK</h3></A>
 </BODY>
 </HTML>
index d347ab8..4a2c4af 100644 (file)
@@ -9,18 +9,18 @@
 
 <body>
 
-</script>
-<noscript>
-<p><b>JavaScript is disabled. Change it.</b></p>
-</noscript>
 
 <p>You can use the network.</p>
 <p>When you finish to use the network, stop your WEB browser. 
 You will be disconnected from the network automatically.</p>
 
+<noscript>
+<p><b>JavaScript is disabled. Change it.</b></p>
+</noscript>
+
 <hr />
 <p>
-<div align="center">
+<div id="watchdog" align="center">
 <table width="60%" bgcolor="yellow" >
 <tr>
 <td align='center'>Authenticated for networt use </td>
@@ -34,9 +34,11 @@ You will be disconnected from the network automatically.</p>
 <hr />
 
 
-<p>Normally, the clock at the rightside of above bar is updated. If not, 
+<p>If yellow bar is not displayed between above two lines 
+or other malfunction is occured, 
 click <a href="%%TERMINATEURL%%"><b>TERMINATE</b></a>, 
- close your browser, and try to select JAVA in authentication page.</p>
+ close your browser, and try to select other watch mode
+ in authentication page.</p>
 
 <table bgcolor="lightyellow" border="1">
 <tr><td>
@@ -47,10 +49,19 @@ click <a href="%%STARTURL%%" target="_blank"><h3>[Start Page]</h3></a>
 </td></tr>
 </table>
 
-<script>
+<script type="text/JavaScript">
 //<!--
   window.open("%%STARTURL%%","window1");
- initHttpkeep(%%HTTPHELLOINTERVAL%%,"%%HTTPHELLOURL%%");
+
+  applet  =' <applet code="Opengate.class" archive="Opengate.jar" ';
+  applet +='  codebase="%%OPENGATEDIR%%" width="600" height="30" > ';
+  applet +='  <param name=port value="%%OPENGATEPORT%%"> ';
+  applet +='  <param name=user value="%%USERID%%"> ';
+  applet +='  <param name=sessionid value="%%SESSIONID%%"> ';
+  applet +='  <param name=lang value="%%LANGUAGE%%"> ';
+  applet +=' </applet> ';
+
+  initHttpkeep(%%HTTPHELLOINTERVAL%%,"%%HTTPHELLOURL%%",applet);
 //-->
 </script>
 
index be3fb38..3327335 100644 (file)
@@ -10,7 +10,7 @@
 
 <H2>Network User Authentication</H2>
 <hr>
-[<a href="https://%%AUTHCGIURL%%?%%ADDR4%%&ja">Japanese version</a>]
+[<a href="https://%%AUTHCGIURL%%?addr=%%ADDR4%%&lang=ja">Japanese version</a>]
 <hr SIZE=4 WIDTH="100%">
 
 <P><font size=+1>You are requested to be authenticated before using network.
@@ -43,7 +43,7 @@ SEND.
 
 
 <hr>
-Watch dog (Only change when default is mulfunctioned)<br />
+Watch dog (Only change when default is malfunctioned)<br />
 <input type="radio" name="watchmode" value="H" %%CHECKHTTP%% >HTTP &nbsp; 
 <input type="radio" name="watchmode" value="J" %%CHECKJAVA%% >JAVA &nbsp; 
 <input type="radio" name="watchmode" value="T" %%CHECKTIME%% >
index 614c3b3..fd9478a 100644 (file)
@@ -11,7 +11,7 @@
 <H2 align=center>Network User Authentication</H2>
 
 <hr>
-[<a href="http://%%AUTHCGIURL%%?%%ADDR4%%&ja">Japanese version</a>]
+[<a href="http://%%AUTHCGIURL%%?addr=%%ADDR4%%&lang=ja">Japanese version</a>]
 <hr>
 <div align=center>
 <P><font size=+1>You are requested to be authenticated before using network.
@@ -26,7 +26,7 @@ not know your user ID and/or password, please consult CNC.
 Please enter your user ID and password in the box below, then press SEND.
 Please use SSL Authentication as far as possible to prevent wiretapping. 
 </P>
-<P><A HREF="https://%%AUTHCGIURL%%?%%ADDR4%%&en">SSL Authentication</A></P>
+<P><A HREF="https://%%AUTHCGIURL%%?addr=%%ADDR4%%&lang=en">SSL Authentication</A></P>
 
 <P>
 <FORM METHOD="POST" ACTION="http://%%CGIURL%%">
@@ -44,7 +44,7 @@ Please use SSL Authentication as far as possible to prevent wiretapping.
 </TABLE>
 
 <hr>
-Watch dog (Only change when the system is mulfunctioned)<br />
+Watch dog (Only change when the system is malfunctioned)<br />
 <input type="radio" name="watchmode" value="H" %%CHECKHTTP%% >HTTP &nbsp; 
 <input type="radio" name="watchmode" value="J" %%CHECKJAVA%% >JAVA &nbsp; 
 <input type="radio" name="watchmode" value="T" %%CHECKTIME%% >
index b21432d..260bf9c 100644 (file)
@@ -3,7 +3,7 @@
 
 <META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=iso-8859-1">
 <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
-<META HTTP-EQUIV="Refresh" CONTENT="1; URL=https://%%AUTHCGIURL%%?%%ADDR4%%&en">
+<META HTTP-EQUIV="Refresh" CONTENT="1; URL=https://%%AUTHCGIURL%%?addr=%%ADDR4%%&lang=en">
 <TITLE>OpengateStart</TITLE>
 </HEAD>
 <BODY>
@@ -12,8 +12,8 @@ by Opengate.
 <P>
 If you cannot move to the page automatically, click the following.
 <P>
-<a href="https://%%AUTHCGIURL%%?%%ADDR4%%&en">Network Authentication</a><br>
-<a href="http://%%AUTHCGIURL%%?%%ADDR4%%&en">Network Authentication(Unuse SSL)</a>
+<a href="https://%%AUTHCGIURL%%?addr=%%ADDR4%%&lang=en">Network Authentication</a><br>
+<a href="http://%%AUTHCGIURL%%?addr=%%ADDR4%%&lang=en">Network Authentication(Unuse SSL)</a>
 <hr>
 Saga University
 </BODY>
index b663fdc..2b04834 100644 (file)
@@ -1,66 +1,75 @@
 //<!--
-var connect;
-var timeInterval;
+var checkInterval;
 var httpkeepUrl;
+var appletDescription;
 var httpObj;
 
 function createXMLHttpRequest() {
   try { return new ActiveXObject("Msxml2.XMLHTTP");    } catch(e) {}
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
   try { return new XMLHttpRequest();                   } catch(e) {}
-  document.getElementById("dispmsg").innerHTML = 'ERROR-noAJAX';
   return null;
 }
 
 function onTimeout()
 {
-  if(httpObj.readyState!=4){
-    document.getElementById("dispmsg").innerHTML = 'ERROR-noREPLY';
-    connect=0;
-  }
-
-  if(connect==1){
+  if(httpObj.readyState==4&&httpObj.status==200){
     sendHello();
-    setTimeout('onTimeout()', timeInterval);
+    setTimeout('onTimeout()', checkInterval*1000);
+  }
+  else{
+      document.getElementById("dispmsg").innerHTML = 'Error!';
   }
 }
 
 function sendHello(){
 
-  // http communication object
-  httpObj=createXMLHttpRequest();
-  httpObj.onreadystatechange = displayResponse;
+  // http communication
+  if((httpObj=createXMLHttpRequest())!=null){
+    httpObj.onreadystatechange = displayResponse;
 
-  try{  
-    httpObj.open("GET",httpkeepUrl+Math.random(),true);
-  }catch(e){
-    document.getElementById("dispmsg").innerHTML = "ERROR-noOPEN";
-    connect=0;
-  }
+    try{  
+      httpObj.open("GET",httpkeepUrl+Math.random(),true);
+       httpObj.send(null);
+    }catch(e){
+      document.getElementById("watchdog").innerHTML = appletDescription;
+      setTimeout('', 0);
+    }
 
-  httpObj.send(null);
+  }
+  // java communication
+  else{
+    document.getElementById("watchdog").innerHTML = appletDescription;
+    setTimeout('', 0);
+  }
 }
 
 function displayResponse()
 {
-  if(httpObj.readyState==4){
-    today=new Date; 
-    hh=today.getHours();  mm=today.getMinutes();
-    if(hh<10)hh='0'+hh;   if(mm<10)mm='0'+mm;
-    document.getElementById("dispmsg").innerHTML = hh+':'+mm;
+  try{
+    if(httpObj.readyState==4&&httpObj.status==200){
+      today=new Date; 
+      hh=today.getHours();  mm=today.getMinutes();
+      if(hh<10)hh='0'+hh;   if(mm<10)mm='0'+mm;
+      document.getElementById("dispmsg").innerHTML = hh+':'+mm;
+    }else{
+      document.getElementById("dispmsg").innerHTML = 'Waiting...';
+    }
+  }catch(e){
+    document.getElementById("watchdog").innerHTML = appletDescription;
+    setTimeout('onTimeout()', 0);
   }
 }
 
-function initHttpkeep(interval, url)
+function initHttpkeep(intervalArg, urlArg, appletArg)
 {
-  connect=1;
-  sendHello();
+  // save arguments
+  checkInterval = intervalArg;
+  httpkeepUrl=urlArg;
+  appletDescription=appletArg;
 
-  // http request after timeInterval(ms)
-  timeInterval = interval*1000;
-  httpkeepUrl=url;
-
-  // get next text after some delay
-  setTimeout('onTimeout()', timeInterval);
+  // set timeout and send hello 
+  setTimeout('onTimeout()', checkInterval*1000);
+  sendHello();
 }
-//-->
\ No newline at end of file
+//-->
index 9802e4d..44c46c0 100644 (file)
@@ -1,16 +1,57 @@
 <html>
 <head>
 <meta http-equiv="Content-Type" content="text/html;charset=iso-2022-jp">
-<meta http-equiv="Pragma" content="no-cache">
-<meta http-equiv="Refresh" content="0; URL=%%HTTPKEEPURL%%">
-
 <title>Opengatemain</title>
 </head>
 <body>
 <p>
-\e$B%M%C%H%o!<%/$rMxMQ$G$-$^$9!#$3$N%Z!<%8$+$i<+F00\F0$7$J$$J}$O\e(B
-<a href="%%HTTPKEEPURL%%">\e$B<!$X\e(B</a>\e$B$r%/%j%C%/$7$F2<$5$$!#\e(B
+<p>\e$B%M%C%H%o!<%/$rMxMQ$G$-$^$9!#\e(B</p>
+<p>\e$BMxMQ$,=*$C$?$iI,$:\e(BWeb\e$B%V%i%&%6$r=*N;$7$F$/$@$5$$!#%M%C%H%o!<%/MxMQ5v2D$b<+F0E*$K<h$j>C$5$l$^$9!#\e(B
 </p>
 
+<script language="JavaScript">
+<!--
+// usually the page is jumped to httpkeep.html
+location.replace(%%HTTPKEEPURL%%);
+
+// if not jumped, process following 
+if(!navigator.javaEnabled()){
+    document.write("<p><b>Java\e$B$,L58z$K@_Dj$5$l$F$$$^$9!#@_Dj$rJQ99$7$F2<$5$$!#\e(B</b></p>");
+}
+//-->
+</script>
+<noscript>
+<p><b>JavaScript\e$B$,L58z$K@_Dj$5$l$F$$$^$9!#@_Dj$rJQ99$7$F2<$5$$!#\e(B</b></p>
+</noscript>
+
+<hr />
+<div align="center">
+   <applet code="Opengate.class" archive="Opengate.jar"
+    codebase="%%OPENGATEDIR%%" width="600" height="30" >
+    <param name=port value="%%OPENGATEPORT%%">
+    <param name=user value="%%USERID%%">
+    <param name=sessionid value="%%SESSIONID%%">
+    <param name=lang value="%%LANGUAGE%%">
+   </applet>
+</div>
+<hr />
+
+<p>\e$B>e$N\e(B2\e$BK\$N@~$N4V$K2+?'$N%P!<$,I=<($5$l$J$$>l9g!"\e(B<a href="%%TERMINATEURL%%"><b>\e$BMxMQCfCG\e(B</b></a>\e$B$r%/%j%C%/$7$F$+$i\e(B
+\e$B%V%i%&%6$r=*N;$7$F$/$@$5$$!#\e(B
+
+<script language="JavaScript">
+<!--
+  window.open("%%STARTURL%%","window1");
+//-->
+</script>
+
+<table bgcolor="lightyellow" border="1">
+<tr><td>
+<b>\e$B$3$N%Z!<%8$O$3$N$^$^$K!JKt$O:G>/2=!K$7$F!"JL$N%&%$%s%I%&$G:n6H$7$F$/$@$5$$!#\e(B</b>
+\e$B:n6HMQ%&%#%s%I%&$,3+$+$J$$>l9g$K$O!"\e(B<a href="%%STARTURL%%" target="_blank"><h3>[\e$B%9%?!<%H%Z!<%8\e(B]</h3></a>\e$B$r%/%j%C%/$7$F$/$@$5$$!#\e(B
+
+</td></tr>
+</table>
+
 </body>
 </html>
index 5793eec..a07c935 100644 (file)
 <script language="JavaScript">
 <!--
 if(!navigator.javaEnabled()){
-    document.write("<p><b>Java\e$B$,L58z$K@_Dj$5$l$F$$$^$9!#JQ992<$5$$!#\e(B</b></p>");
+    document.write("<p><b>Java\e$B$,L58z$K@_Dj$5$l$F$$$^$9!#JQ99$7$F2<$5$$!#\e(B</b></p>");
 }
 //-->
 </script>
 <noscript>
-<p><b>JavaScript\e$B$,L58z$K@_Dj$5$l$F$$$^$9!#JQ992<$5$$!#\e(B</b></p>
+<p><b>JavaScript\e$B$,L58z$K@_Dj$5$l$F$$$^$9!#JQ99$7$F2<$5$$!#\e(B</b></p>
 </noscript>
 
 <hr />
@@ -26,6 +26,7 @@ if(!navigator.javaEnabled()){
     codebase="%%OPENGATEDIR%%" width="600" height="30" >
     <param name=port value="%%OPENGATEPORT%%">
     <param name=user value="%%USERID%%">
+    <param name=sessionid value="%%SESSIONID%%">
     <param name=lang value="%%LANGUAGE%%">
    </applet>
 </div>
@@ -33,7 +34,7 @@ if(!navigator.javaEnabled()){
 
 <p>\e$B>e$N\e(B2\e$BK\$N@~$N4V$K2+?'$N%P!<$,I=<($5$l$J$$>l9g!"\e(BJava\e$B$,F0$$$F$$$^$;$s!#\e(B
 <a href="%%TERMINATEURL%%"><b>\e$BMxMQCfCG\e(B</b></a>\e$B$r%/%j%C%/$7$F\e(B
-\e$B%V%i%&%6$r=*N;$7$?8e!"G'>Z%Z!<%8$K$*$$$F\e(BHTTP\e$BJ}<0$rA*Br$7$F$/$@$5$$!#\e(B
+\e$B%V%i%&%6$r=*N;$7$?8e!"G'>Z%Z!<%8$K$*$$$FB>$N4F;kJ}<0$rA*Br$7$F$/$@$5$$!#\e(B
 \e$B$^$?$O!"\e(B<a href=http://java.com/ja/index.jsp><b>java.com</b></a>
 \e$B$+$i\e(BJavaPlugIn\e$B$r%@%&%s%m!<%I$9$l$P!"\e(BJava\e$B$rF0$+$9$3$H$,$G$-$^$9!#\e(B
 
@@ -54,3 +55,7 @@ if(!navigator.javaEnabled()){
 
 </body>
 </html>
+
+
+
+
index 9fff96a..4be790e 100644 (file)
@@ -5,11 +5,11 @@
 </head>
 <body>
 
-<p>\e$B%M%C%H%o!<%/$rMxMQ$G$-$^$9!#\e(B
-\e$B%M%C%H%o!<%/$O;XDj;~4V8e$KJD:?$H$J$j$^$9!#\e(B</p>
-<p>\e$B0BA4$N$?$a$K!"MxMQ=*N;;~$K$O!"\e(B<a href="%%TERMINATEURL%%">
-<b>\e$BMxMQCfCG\e(B</b></a>\e$B$r%/%j%C%/$7$F$/$@$5$$!#\e(B</p>
-<p>\e$B$3$NJ}K!$O!"B>$NJ}K!$,<:GT$9$k>l9g$K$N$_MxMQ$7$F2<$5$$!#\e(B</p>
+<p>\e$B%M%C%H%o!<%/$rMxMQ$G$-$^$9!#\e(J
+\e$B%M%C%H%o!<%/$O;XDj;~4V7P2a8e$KJD:?$H$J$j$^$9!#\e(J</p>
+<p>\e$B0BA4$N$?$a$K!"MxMQ=*N;;~$K$O!"\e(J<a href="%%TERMINATEURL%%">
+<b>\e$BMxMQCfCG\e(J</b></a>\e$B$r%/%j%C%/$7$F$/$@$5$$!#\e(J</p>
+<p>\e$B$3$NJ}K!$O!"B>$N4F;kJ}K!$,;HMQ$G$-$J$$>l9g$K$N$_MxMQ$7$F2<$5$$!#\e(J</p>
 
 <script language="JavaScript">
 <!--
@@ -20,9 +20,9 @@
 
 <table bgcolor="lightyellow" border="1">
 <tr><td>
-<b>\e$B$3$N%Z!<%8$O$3$N$^$^$K!JKt$O:G>/2=!K$7$F!"JL$N%&%$%s%I%&$G:n6H$7$F$/$@$5$$!#\e(B</b>
-\e$B:n6HMQ%&%#%s%I%&$,3+$+$J$$>l9g$K$O!"\e(B
-<a href="%%STARTURL%%" target="_blank"><h3>[\e$B%9%?!<%H%Z!<%8\e(B]</h3></a>\e$B$r%/%j%C%/$7$F$/$@$5$$!#\e(B
+<b>\e$B$3$N%Z!<%8$O$3$N$^$^$K!JKt$O:G>/2=!K$7$F!"JL$N%&%$%s%I%&$G:n6H$7$F$/$@$5$$!#\e(J</b>
+\e$B:n6HMQ%&%#%s%I%&$,3+$+$J$$>l9g$K$O!"\e(J
+<a href="%%STARTURL%%" target="_blank"><h3>[\e$B%9%?!<%H%Z!<%8\e(J]</h3></a>\e$B$r%/%j%C%/$7$F$/$@$5$$!#\e(J
 
 </td></tr>
 </table>
index 3341df6..090bd92 100644 (file)
@@ -7,6 +7,6 @@
 <P>
 \e$B%M%C%H%o!<%/MxMQG'>Z$K<:GT$7$^$7$?!#$b$&0lEY$d$jD>$7$F2<$5$$!#\e(B
 </P>
-<A HREF=https://%%AUTHCGIURL%%?%%ADDR4%%&ja><H3>\e$BLa$k\e(B</H3></A>
+<A HREF="https://%%AUTHCGIURL%%?addr=%%ADDR4%%&lang=ja"><H3>\e$BLa$k\e(B</H3></A>
 </BODY>
 </HTML>
index 6e90adc..6cfb870 100644 (file)
@@ -7,6 +7,6 @@
 <P>
 \e$B%M%C%H%o!<%/MxMQG'>Z$K<:GT$7$^$7$?!#$b$&0lEY$d$jD>$7$F2<$5$$!#\e(B
 </P>
-<A HREF=http://%%AUTHCGIURL%%?%%ADDR4%%&ja><H3>\e$BLa$k\e(B</H3></A>
+<A HREF="http://%%AUTHCGIURL%%?addr=%%ADDR4%%&lang=ja"><H3>\e$BLa$k\e(B</H3></A>
 </BODY>
 </HTML>
index acb43f8..c64b35d 100644 (file)
@@ -9,17 +9,16 @@
 
 <body>
 
-<noscript>
-<p><b>JavaScript\e$B$,L58z$K@_Dj$5$l$F$$$^$9!#3NG'2<$5$$!#\e(B</b></p>
-</noscript>
 
 
 <p>\e$B%M%C%H%o!<%/$rMxMQ$G$-$^$9!#\e(B</p>
-<p>\e$BMxMQ$,=*$C$?$iI,$:\e(BWeb\e$B%V%i%&%6$r=*N;$7$F$/$@$5$$!#%M%C%H%o!<%/MxMQ5v2D$b<+F0E*$K<h$j>C$5$l$^$9!#\e(B
-</p>
+<p>\e$BMxMQ$,=*$C$?$iI,$:\e(BWeb\e$B%V%i%&%6$r=*N;$7$F$/$@$5$$!#%M%C%H%o!<%/MxMQ5v2D$b<+F0E*$K<h$j>C$5$l$^$9!#\e(B</p>
+<noscript>
+<p><b>JavaScript\e$B$,L58z$K@_Dj$5$l$F$$$^$9!#JQ99$7$F2<$5$$!#\e(B</b></p>
+</noscript>
 <hr />
 <p>
-<div align="center">
+<div id="watchdog" align="center">
 <table width="60%" bgcolor="yellow" >
 <tr>
 <td align='center'>\e$B%M%C%H%o!<%/MxMQ5v2D\e(B</td>
@@ -32,9 +31,9 @@
 </p>
 <hr />
 
-<p>\e$B@5>o;~$K$O!">e$N%P!<1&C<$N;~7W$,99?7$5$l$^$9!#$=$&$J$i$J$$>l9g$O!"\e(B
+<p>\e$B>e$N\e(B2\e$BK\$N@~$N4V$K2+?'$N%P!<$,I=<($5$l$J$$>l9g$J$IF0:n$,$*$+$7$$>l9g$O!"\e(B
 <a href="%%TERMINATEURL%%"><b>\e$BMxMQCfCG\e(B</b></a>\e$B$r%/%j%C%/$7$F\e(B
-\e$B%V%i%&%6$r=*N;$7$?8e!"G'>Z%Z!<%8$K$*$$$F\e(BJAVA\e$BJ}<0$rA*Br$7$F$/$@$5$$!#\e(B
+\e$B%V%i%&%6$r=*N;$7$?8e!"G'>Z%Z!<%8$K$*$$$FB>$N4F;kJ}<0$rA*Br$7$F$/$@$5$$!#\e(B
 </p>
 
 <table bgcolor="lightyellow" border="1">
 </td></tr>
 </table>
 
-<script>
+<script type="text/JavaScript">
 //<!--
   window.open("%%STARTURL%%","window1");
- initHttpkeep(%%HTTPHELLOINTERVAL%%,"%%HTTPHELLOURL%%");
+
+  applet  =' <applet code="Opengate.class" archive="Opengate.jar" ';
+  applet +='  codebase="%%OPENGATEDIR%%" width="600" height="30" > ';
+  applet +='  <param name=port value="%%OPENGATEPORT%%"> ';
+  applet +='  <param name=user value="%%USERID%%"> ';
+  applet +='  <param name=sessionid value="%%SESSIONID%%"> ';
+  applet +='  <param name=lang value="%%LANGUAGE%%"> ';
+  applet +=' </applet> ';
+
+  initHttpkeep(%%HTTPHELLOINTERVAL%%,"%%HTTPHELLOURL%%",applet);
 //-->
 </script>
 
index 98765ba..2b69b92 100644 (file)
@@ -11,7 +11,7 @@
 
 <H2>\e$B%M%C%H%o!<%/MxMQ<TG'>Z\e(B</H2>
 <hr>
-[<a href="https://%%AUTHCGIURL%%?%%ADDR4%%&en">English version</a>]
+[<a href="https://%%AUTHCGIURL%%?addr=%%ADDR4%%&lang=en">English version</a>]
 <hr SIZE=4 WIDTH="100%">
 
 <P><font size=+1>\e$B%M%C%H%o!<%/$NMxMQ$r;O$a$kA0$K!"\e(B \e$BMxMQ;q3J$N3NG'$r9T$C$F$/$@$5$$!#\e(B</font></P>
index e71155f..151c5f1 100644 (file)
@@ -11,7 +11,7 @@
 
 <H2>\e$B%M%C%H%o!<%/MxMQ<TG'>Z\e(B</H2>
 <hr>
-[<a href="http://%%AUTHCGIURL%%?%%ADDR4%%&en">English version</a>]
+[<a href="http://%%AUTHCGIURL%%?addr=%%ADDR4%%&lang=en">English version</a>]
 <hr>
 <div align=center>
 
@@ -24,7 +24,7 @@
 \e$B%Q%9%o!<%I$NEpD0$rKI$0$?$a$K!"$G$-$k$@$1\e(BSSL\e$BBP1~G'>Z$rMxMQ$7$F2<$5$$!#\e(B
 </P>
 
-<P><A HREF="https://%%AUTHCGIURL%%?%%ADDR4%%&ja">SSL\e$BBP1~G'>Z\e(B</A></P>
+<P><A HREF="https://%%AUTHCGIURL%%?addr=%%ADDR4%%&lang=ja">SSL\e$BBP1~G'>Z\e(B</A></P>
 
 <P>
 <FORM METHOD="POST" ACTION="http://%%CGIURL%%">
index a63aeef..6184f29 100644 (file)
@@ -2,7 +2,7 @@
 <HEAD>
 <META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=iso-2022-jp">
 <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
-<META HTTP-EQUIV="Refresh" CONTENT="1; URL=https://%%AUTHCGIURL%%?%%ADDR4%%&ja">
+<META HTTP-EQUIV="Refresh" CONTENT="1; URL=https://%%AUTHCGIURL%%?addr=%%ADDR4%%&lang=ja">
 
 <TITLE>OpengateStart</TITLE>
 </HEAD>
@@ -11,8 +11,8 @@ Opengate\e$B$K$h$k!V%M%C%H%o!<%/MxMQG'>Z!W$N%Z!<%8$X<+F00\F0$7$^$9!#\e(B
 <P>
 \e$B<+F00\F0$G$-$J$$J}$O$3$A$i$r%/%j%C%/$7$F2<$5$$!#\e(B
 <P>
-<a href="https://%%AUTHCGIURL%%?%%ADDR4%%&ja">\e$B%M%C%H%o!<%/MxMQ<TG'>Z\e(B</a><br>
-<a href="http://%%AUTHCGIURL%%?%%ADDR4%%&ja">\e$B%M%C%H%o!<%/MxMQ<TG'>Z!J\e(BSSL\e$BHsBP1~!K\e(B</a>
+<a href="https://%%AUTHCGIURL%%?%%addr=ADDR4%%&lang=ja">\e$B%M%C%H%o!<%/MxMQ<TG'>Z\e(B</a><br>
+<a href="http://%%AUTHCGIURL%%?%%addr=ADDR4%%&lang=ja">\e$B%M%C%H%o!<%/MxMQ<TG'>Z!J\e(BSSL\e$BHsBP1~!K\e(B</a>
 <HR>
 \e$B:42lBg3X\e(B
 </BODY>
index e4a7a04..00b7669 100644 (file)
@@ -99,7 +99,7 @@ install-conf:
                cp ../conf/ipfwctrl.pl.sample  ${CONFIGPATH}
                #
                #------------------------------------------------------#
-               # Rename above x.sample, if you need to enable these.  #
+               # COPY above x.sample to x and EDIT it, if you need.   #
                #   Eg. 'cp opengatesrv.conf.sample  opengatesrv.conf' #
                #------------------------------------------------------#
 
index dd371d7..3753236 100644 (file)
@@ -110,16 +110,16 @@ int addrDecode(char dotSepAddr[], char encodeAddr[])
 
 int AddrEncode(char encodeAddr[], char dotSepAddr[]){
   int ret;
-  if(debug) err_msg("DEBUG:=>addrEncode(,%s)",dotSepAddr);
+  if(debug>1) err_msg("DEBUG:=>addrEncode(,%s)",dotSepAddr);
   ret = addrEncode(encodeAddr, dotSepAddr);
-  if(debug) err_msg("DEBUG:(%d)<=addrEncode(%s,)",ret,encodeAddr);
+  if(debug>1) err_msg("DEBUG:(%d)<=addrEncode(%s,)",ret,encodeAddr);
   return ret;
 }
 
 int AddrDecode(char dotSepAddr[], char encodeAddr[]){
   int ret;
-  if(debug) err_msg("DEBUG:=>addrDecode(,%s)",encodeAddr);
+  if(debug>1) err_msg("DEBUG:=>addrDecode(,%s)",encodeAddr);
   ret = addrDecode(dotSepAddr, encodeAddr);
-  if(debug) err_msg("DEBUG:(%d)<=addrDecode(%s,)",ret,dotSepAddr);
+  if(debug>1) err_msg("DEBUG:(%d)<=addrDecode(%s,)",ret,dotSepAddr);
   return ret;
 }
index 0bc7fdb..5740cac 100644 (file)
@@ -69,7 +69,7 @@ int authFtpse(char *userid, char *passwd)
   }
 
   /* get [220 <host> FTP server ..]*/
-  if((n = readln(sockfd, recvline, BUFFMAXLN)) <= 0) {
+  if((n = readln(sockfd, recvline, BUFFMAXLN)) < 0) {
     err_msg("ERR at %s#%d: Ftpse server is not normal 1",__FILE__,__LINE__);
     Close(sockfd);
     return DENY;
@@ -84,7 +84,7 @@ int authFtpse(char *userid, char *passwd)
   Writefmt(sockfd, "AUTH TLS\r\n");
 
   /* get [234 AUTH TLS successful] */
-  if((n = readln(sockfd, recvline, BUFFMAXLN)) <= 0) {
+  if((n = readln(sockfd, recvline, BUFFMAXLN)) < 0) {
     err_msg("ERR at %s#%d: Ftpse server is not normal 3",__FILE__,__LINE__);
     Close(sockfd);
     return DENY;
@@ -128,7 +128,7 @@ int authFtpse(char *userid, char *passwd)
   WritefmtSSL(ssl, "USER %s\r\n", userid);
 
   /* get [331 Password required ..] */
-  if((n = readlnSSL(ssl, recvline, BUFFMAXLN)) <= 0) {
+  if((n = readlnSSL(ssl, recvline, BUFFMAXLN)) < 0) {
     err_msg("ERR at %s#%d: Ftpse server is not normal 5",__FILE__,__LINE__);
     authResult=DENY;
     goto EXITPOINT;
@@ -136,7 +136,7 @@ int authFtpse(char *userid, char *passwd)
 
   /* if multi-line greeting [220 ...] exist, skip them. */
   while(strstr(recvline,"220")==recvline){
-    if((n = readlnSSL(ssl, recvline, BUFFMAXLN)) <= 0) {
+    if((n = readlnSSL(ssl, recvline, BUFFMAXLN)) < 0) {
       err_msg("ERR at %s#%d: Ftpse server is not normal 6",__FILE__,__LINE__);
       authResult=DENY;
       goto EXITPOINT;
@@ -154,7 +154,7 @@ int authFtpse(char *userid, char *passwd)
   WritefmtSSL(ssl, "PASS %s\r\n", passwd);
 
   /* get [230 User <userid> logged in] */
-  if((n = readlnSSL(ssl, recvline, BUFFMAXLN)) <= 0) {
+  if((n = readlnSSL(ssl, recvline, BUFFMAXLN)) < 0) {
     err_msg("ERR at %s#%d: Ftpse server is not normal 8",__FILE__,__LINE__);
     authResult=DENY;
     goto EXITPOINT;
@@ -247,7 +247,7 @@ int authFtpsi(char *userid, char *passwd)
   /* DATA EXCHANGE - Send a message and receive a reply. */
 
   /* get [220 <host> FTP server ..]*/
-  if((n = readlnSSL(ssl, recvline, BUFFMAXLN)) <= 0) {
+  if((n = readlnSSL(ssl, recvline, BUFFMAXLN)) < 0) {
     err_msg("ERR at %s#%d: Ftpsi server is not normal 1",__FILE__,__LINE__);
     authResult=DENY;
     goto EXITPOINT;
@@ -262,7 +262,7 @@ int authFtpsi(char *userid, char *passwd)
   WritefmtSSL(ssl, "USER %s\r\n", userid);
 
   /* get [331 Password required ..] */
-  if((n = readlnSSL(ssl, recvline, BUFFMAXLN)) <= 0) {
+  if((n = readlnSSL(ssl, recvline, BUFFMAXLN)) < 0) {
     err_msg("ERR at %s#%d: Ftpi server is not normal 3",__FILE__,__LINE__);
     authResult=DENY;
     goto EXITPOINT;
@@ -270,7 +270,7 @@ int authFtpsi(char *userid, char *passwd)
 
   /* if multi-line greeting [220 ...] exist, skip them. */
   while(strstr(recvline,"220")==recvline){
-    if((n = readlnSSL(ssl, recvline, BUFFMAXLN)) <= 0) {
+    if((n = readlnSSL(ssl, recvline, BUFFMAXLN)) < 0) {
       err_msg("ERR at %s#%d: Ftpsi server is not normal 4",__FILE__,__LINE__);
       authResult=DENY;
       goto EXITPOINT;
@@ -288,7 +288,7 @@ int authFtpsi(char *userid, char *passwd)
   WritefmtSSL(ssl, "PASS %s\r\n", passwd);
 
   /* get [230 User <userid> logged in] */
-  if((n = readlnSSL(ssl, recvline, BUFFMAXLN)) <= 0) {
+  if((n = readlnSSL(ssl, recvline, BUFFMAXLN)) < 0) {
     err_msg("ERR at %s#%d: Ftpsi server is not normal 6",__FILE__,__LINE__);
     authResult=DENY;
     goto EXITPOINT;
@@ -319,9 +319,9 @@ int AuthFtpse(char *userid, char *passwd)
 {
   int ret;
 
-  if(debug) err_msg("DEBUG:=>authFtpse(%s,passwd)",userid);
+  if(debug>1) err_msg("DEBUG:=>authFtpse(%s,passwd)",userid);
   ret=authFtpse(userid,passwd);
-  if(debug) err_msg("DEBUG:(%d)<=authFtpse( )",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=authFtpse( )",ret);
 
   return ret;
 }
@@ -330,9 +330,9 @@ int AuthFtpsi(char *userid, char *passwd)
 {
   int ret;
 
-  if(debug) err_msg("DEBUG:=>authFtpsi(%s,passwd)",userid);
+  if(debug>1) err_msg("DEBUG:=>authFtpsi(%s,passwd)",userid);
   ret=authFtpsi(userid,passwd);
-  if(debug) err_msg("DEBUG:(%d)<=authFtpsi( )",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=authFtpsi( )",ret);
 
   return ret;
 }
index 90cbd6a..a7313bc 100644 (file)
@@ -141,9 +141,9 @@ int AuthPam(char *userid, char *passwd)
 {
   int ret;
 
-  if(debug) err_msg("DEBUG:=>authPam(%s,passwd)",userid);
+  if(debug>1) err_msg("DEBUG:=>authPam(%s,passwd)",userid);
   ret=authPam(userid, passwd);
-  if(debug) err_msg("DEBUG:(%d)<=authPam( )",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=authPam( )",ret);
 
   return ret;
 }
index 8d4b9ac..4082c84 100644 (file)
@@ -97,7 +97,7 @@ int authPop3s(char *userid, char *passwd)
   /*  pop3 message exchange */
 
   /* get [+OK POP3 <host> <ver> server ready]*/
-  if((n = readlnSSL(ssl, recvline, BUFFMAXLN)) <= 0) {
+  if((n = readlnSSL(ssl, recvline, BUFFMAXLN)) < 0) {
     err_msg("ERR at %s#%d: Pop3s server is not normal 1",__FILE__,__LINE__);
     authResult=DENY;
     goto EXITPOINT;
@@ -113,7 +113,7 @@ int authPop3s(char *userid, char *passwd)
   WritefmtSSL(ssl, "user %s\r\n", userid);
 
   /* get [+OK User name accepted, password please] */
-  if((n = readlnSSL(ssl, recvline, BUFFMAXLN)) <= 0) {
+  if((n = readlnSSL(ssl, recvline, BUFFMAXLN)) < 0) {
     err_msg("ERR at %s#%d: Pop3s server is not normal 3",__FILE__,__LINE__);
     authResult=DENY;
     goto EXITPOINT;
@@ -129,7 +129,7 @@ int authPop3s(char *userid, char *passwd)
   WritefmtSSL(ssl, "pass %s\r\n", passwd);
 
   /* get [+OK Mailbox open, <count> messages] */
-  if((n = readlnSSL(ssl, recvline, BUFFMAXLN)) <= 0) {
+  if((n = readlnSSL(ssl, recvline, BUFFMAXLN)) < 0) {
     err_msg("ERR at %s#%d: Pop3s server is not normal 5",__FILE__,__LINE__);
     authResult=DENY;
     goto EXITPOINT;
@@ -159,9 +159,9 @@ int AuthPop3s(char *userid, char *passwd)
 {
   int ret;
 
-  if(debug) err_msg("DEBUG:=>authPop3s(%s,passwd)",userid);
+  if(debug>1) err_msg("DEBUG:=>authPop3s(%s,passwd)",userid);
   ret=authPop3s(userid,passwd);
-  if(debug) err_msg("DEBUG:(%d)<=authPop3s( )",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=authPop3s( )",ret);
 
   return ret;
 }
index 61e9215..670478b 100644 (file)
@@ -92,9 +92,9 @@ int AuthRadius(char *userid, char *passwd)
 {
   int ret;
 
-  if(debug) err_msg("DEBUG:=>authRadius(%s,passwd)",userid);
+  if(debug>1) err_msg("DEBUG:=>authRadius(%s,passwd)",userid);
   ret=authRadius(userid,passwd);
-  if(debug) err_msg("DEBUG:(%d)<=authRadius( )",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=authRadius( )",ret);
 
   return ret;
 }
index 0df7e36..ce2d50f 100644 (file)
@@ -78,9 +78,9 @@ int GetMacAddrFromArp(char *clientAddr4, char* macAddr4)
 {
   int ret;
 
-  if(debug) err_msg("DEBUG:=>getMacAddrFromArp(%s,)",clientAddr4);
+  if(debug>1) err_msg("DEBUG:=>getMacAddrFromArp(%s,)",clientAddr4);
   ret=getMacAddrFromArp(clientAddr4,macAddr4);
-  if(debug) err_msg("DEBUG:(%d)<=getMacAddrFromArp(,%s)",ret,macAddr4);
+  if(debug>1) err_msg("DEBUG:(%d)<=getMacAddrFromArp(,%s)",ret,macAddr4);
 
   return ret;
 }  
index 5fac2e9..bb63172 100644 (file)
@@ -159,7 +159,7 @@ int authFtp(char *userid, char *passwd)
   }
 
   /* get [220 <host> FTP server ..]*/
-  if((n = readln(sockfd, recvline, BUFFMAXLN)) <= 0) {
+  if((n = readln(sockfd, recvline, BUFFMAXLN)) < 0) {
     err_msg("ERR at %s#%d: Ftp server is not normal 1",__FILE__,__LINE__);
     Close(sockfd);
     return DENY;
@@ -174,7 +174,7 @@ int authFtp(char *userid, char *passwd)
   Writefmt(sockfd, "user %s\r\n", userid);
 
   /* get [331 Password required ..] */
-  if((n = readln(sockfd, recvline, BUFFMAXLN)) <= 0) {
+  if((n = readln(sockfd, recvline, BUFFMAXLN)) < 0) {
     err_msg("ERR at %s#%d: Ftp server is not normal 3",__FILE__,__LINE__);
     Close(sockfd);
     return DENY;
@@ -182,7 +182,7 @@ int authFtp(char *userid, char *passwd)
 
   /* if multi-line greeting [220 ...] exist, skip them. */
   while(strstr(recvline,"220")==recvline){
-    if((n = readln(sockfd, recvline, BUFFMAXLN)) <= 0) {
+    if((n = readln(sockfd, recvline, BUFFMAXLN)) < 0) {
       err_msg("ERR at %s#%d: Ftp server is not normal 3",__FILE__,__LINE__);
       Close(sockfd);
       return DENY;
@@ -200,7 +200,7 @@ int authFtp(char *userid, char *passwd)
   Writefmt(sockfd, "pass %s\r\n", passwd);
 
   /* get [230 User <userid> logged in] */
-  if((n = readln(sockfd, recvline, BUFFMAXLN)) <= 0) {
+  if((n = readln(sockfd, recvline, BUFFMAXLN)) < 0) {
     err_msg("ERR at %s#%d: Ftp server is not normal 5",__FILE__,__LINE__);
     Close(sockfd);
     return DENY;
@@ -253,7 +253,7 @@ int authPop3(char *userid, char *passwd)
   }
 
   /* get [+OK POP3 <host> <ver> server ready]*/
-  if((n = readln(sockfd, recvline, BUFFMAXLN)) <= 0) {
+  if((n = readln(sockfd, recvline, BUFFMAXLN)) < 0) {
     err_msg("ERR at %s#%d: Pop3 server is not normal 1",__FILE__,__LINE__);
     Close(sockfd);
     return DENY;
@@ -268,7 +268,7 @@ int authPop3(char *userid, char *passwd)
   Writefmt(sockfd, "user %s\r\n", userid);
 
   /* get [+OK User name accepted, password please] */
-  if((n = readln(sockfd, recvline, BUFFMAXLN)) <= 0) {
+  if((n = readln(sockfd, recvline, BUFFMAXLN)) < 0) {
     err_msg("ERR at %s#%d: Pop3 server is not normal 3",__FILE__,__LINE__);
     Close(sockfd);
     return DENY;
@@ -283,7 +283,7 @@ int authPop3(char *userid, char *passwd)
   Writefmt(sockfd, "pass %s\r\n", passwd);
 
   /* get [+OK Mailbox open, <count> messages] */
-  if((n = readln(sockfd, recvline, BUFFMAXLN)) <= 0) {
+  if((n = readln(sockfd, recvline, BUFFMAXLN)) < 0) {
     err_msg("ERR at %s#%d: Pop3 server is not normal 5",__FILE__,__LINE__);
     Close(sockfd);
     return DENY;
@@ -309,9 +309,9 @@ int AuthFtp(char *userid, char *passwd)
 {
   int ret;
 
-  if(debug) err_msg("DEBUG:=>authFtp(%s,passwd)",userid);
+  if(debug>1) err_msg("DEBUG:=>authFtp(%s,passwd)",userid);
   ret=authFtp(userid,passwd);
-  if(debug) err_msg("DEBUG:(%d)<=authFtp( )",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=authFtp( )",ret);
 
   return ret;
 }
@@ -321,9 +321,9 @@ int AuthPop3(char *userid, char *passwd)
 {
   int ret;
 
-  if(debug) err_msg("DEBUG:=>authPop3(%s,passwd)",userid);
+  if(debug>1) err_msg("DEBUG:=>authPop3(%s,passwd)",userid);
   ret=authPop3(userid,passwd);
-  if(debug) err_msg("DEBUG:(%d)<=authPop3( )",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=authPop3( )",ret);
 
   return ret;
 }
@@ -332,16 +332,16 @@ int AuthenticateUser(char *userid, char *password)
 {
   int ret;
 
-  if(debug) err_msg("DEBUG:=>authenticateUser(%s,passwd)",userid);
+  if(debug>1) err_msg("DEBUG:=>authenticateUser(%s,passwd)",userid);
   ret=authenticateUser(userid,password);
-  if(debug) err_msg("DEBUG:(%d)<=authenticateUser( )",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=authenticateUser( )",ret);
 
   return ret;
 }
 
 void SplitId(char* userid, char* useridshort, char* extraId)
 {
-  if(debug) err_msg("DEBUG:=>splitId(%s,,)",userid);
+  if(debug>1) err_msg("DEBUG:=>splitId(%s,,)",userid);
   splitId(userid,useridshort,extraId);
-  if(debug) err_msg("DEBUG:<=splitId(%s,%s,%s)",userid,useridshort,extraId);
+  if(debug>1) err_msg("DEBUG:<=splitId(%s,%s,%s)",userid,useridshort,extraId);
 }
index b2e95b5..4dbfb90 100644 (file)
@@ -256,7 +256,7 @@ void putClientMsg(char *message)
 /*********************************************/
 /* put accept message and java to the client */
 /*********************************************/
-void putClientAccept(char *userid, int port, int pid, char *clientAddr4, char *clientAddr6, int ipStatus, int duration, char *watchMode)
+void putClientAccept(char *userid, char *sessionId, int port, int pid, char *clientAddr4, char *clientAddr6, int ipStatus, int duration, char *watchMode)
 {
   FILE *fp;
   char buff[BUFFMAXLN];
@@ -308,15 +308,15 @@ void putClientAccept(char *userid, int port, int pid, char *clientAddr4, char *c
          "http://%s%s/%s/%s",GetConfValue("OpengateServerName"),
          GetConfValue("OpengateDir"),language,GetConfValue("AcceptDoc2"));
 
-  /* create terminate url [http://<servaddr>:<port>/terminate<pid>] */
-  snprintf(terminateurl, BUFFMAXLN, "http://%s:%d/terminate%d", 
-         GetConfValue("OpengateServerName"), port, pid);
+  /* create terminate url [http://<servaddr>:<port>/terminate-<pid>] */
+  snprintf(terminateurl, BUFFMAXLN, "http://%s:%d/terminate-%d", 
+         GetConfValue("OpengateServerName"), port, getpid());
 
   /* create httpkeep page url
      ['http://<servaddr>:<port>/httpkeep-<userid>'] */
   snprintf(httpkeepUrl, BUFFMAXLN,
-          "'http://%s:%d/httpkeep-%s'", 
-         GetConfValue("OpengateServerName"), port, userid);
+          "'http://%s:%d/httpkeep-%s-%s'", 
+         GetConfValue("OpengateServerName"), port, userid,sessionId);
 
   /* create port string */
   snprintf(portStr, WORDMAXLN, "%d", port);
@@ -336,6 +336,7 @@ void putClientAccept(char *userid, int port, int pid, char *clientAddr4, char *c
     htmlReplace(buff, "%%OPENGATEDIR%%", opengateDir);
     htmlReplace(buff, "%%OPENGATEPORT%%", portStr);
     htmlReplace(buff, "%%USERID%%", userid);
+    htmlReplace(buff, "%%SESSIONID%%", sessionId);
     htmlReplace(buff, "%%LANGUAGE%%", language);
     
     htmlReplace(buff, "%%TERMINATEURL%%", terminateurl);
@@ -438,9 +439,9 @@ int checkReferer(void)
 /*******************************/
 void GetClientAddr(char *clientAddr)
 {
-  if(debug) err_msg("DEBUG:=>getClientAddr( )");
+  if(debug>1) err_msg("DEBUG:=>getClientAddr( )");
   getClientAddr(clientAddr);
-  if(debug) err_msg("DEBUG:<=getClientAddr(%s)",clientAddr);
+  if(debug>1) err_msg("DEBUG:<=getClientAddr(%s)",clientAddr);
 }
 
 
@@ -448,45 +449,45 @@ int GetPostData(char *userid, char *password, char *clientAddr4, int *durationPt
 {
   int ret;
 
-  if(debug) err_msg("DEBUG:=>getPostData( )");
+  if(debug>1) err_msg("DEBUG:=>getPostData( )");
   ret=getPostData(userid,password,clientAddr4,durationPtr, watchMode);
-  if(debug) err_msg("DEBUG:%d<=getPostData(%s,passwd,%s,%d,%s)",ret,userid,clientAddr4,*durationPtr,watchMode);
+  if(debug>1) err_msg("DEBUG:%d<=getPostData(%s,passwd,%s,%d,%s)",ret,userid,clientAddr4,*durationPtr,watchMode);
   return ret;
 }
 
-void PutClientAccept(char *userid, int port, int pid, char *clientAddr4, char *clientAddr6, int ipStatus, int duration, char *watchMode)
+void PutClientAccept(char *userid, char *sessionId, int port, int pid, char *clientAddr4, char *clientAddr6, int ipStatus, int duration, char *watchMode)
 {
-  if(debug) err_msg("DEBUG:=>putClientAccept(%s,%d,%d,%s,%s,%d,%d,%s)",userid,port,pid,clientAddr4,clientAddr6,ipStatus, duration, watchMode);
-  putClientAccept(userid,port,pid,clientAddr4,clientAddr6,ipStatus,duration,watchMode);
-  if(debug) err_msg("DEBUG:<=putClientAccept( )");
+  if(debug>1) err_msg("DEBUG:=>putClientAccept(%s,%s,%d,%d,%s,%s,%d,%d,%s)",userid,sessionId,port,pid,clientAddr4,clientAddr6,ipStatus, duration, watchMode);
+  putClientAccept(userid,sessionId,port,pid,clientAddr4,clientAddr6,ipStatus,duration,watchMode);
+  if(debug>1) err_msg("DEBUG:<=putClientAccept( )");
 }
 
 void PutClientDeny(char *clientAddr4)
 {
-  if(debug) err_msg("DEBUG:=>putClientDeny(&s)",clientAddr4);
+  if(debug>1) err_msg("DEBUG:=>putClientDeny(&s)",clientAddr4);
   putClientDeny(clientAddr4);
-  if(debug) err_msg("DEBUG:<=putClientDeny( )");
+  if(debug>1) err_msg("DEBUG:<=putClientDeny( )");
 }
 
 void PutClientRetry(char *lang)
 {
-  if(debug) err_msg("DEBUG:=>putClientRetry(%s)",lang);
+  if(debug>1) err_msg("DEBUG:=>putClientRetry(%s)",lang);
   putClientRetry(lang);
-  if(debug) err_msg("DEBUG:<=putClientRetry( )");
+  if(debug>1) err_msg("DEBUG:<=putClientRetry( )");
 }
 
 void PutClientMsg(char *message)
 {
-  if(debug) err_msg("DEBUG:=>putClientMsg( %s )",message);
+  if(debug>1) err_msg("DEBUG:=>putClientMsg( %s )",message);
   putClientMsg(message);
-  if(debug) err_msg("DEBUG:<=putClientMsg( )");
+  if(debug>1) err_msg("DEBUG:<=putClientMsg( )");
 }
 
 int CheckReferer(void)
 {
   int ret;
-  if(debug) err_msg("DEBUG:=>checkReferer( )");
+  if(debug>1) err_msg("DEBUG:=>checkReferer( )");
   ret = checkReferer();
-  if(debug) err_msg("DEBUG:(%d)<=checkReferer( )",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=checkReferer( )",ret);
   return ret;
 }
index 21c53d0..adbd291 100644 (file)
@@ -341,9 +341,9 @@ int GetRuleNumber6(char *clientAddr6)
 {\r
   int ret;\r
 \r
-  if(debug) err_msg("DEBUG:=>getRuleNumber6(%s)",clientAddr6);\r
+  if(debug>1) err_msg("DEBUG:=>getRuleNumber6(%s)",clientAddr6);\r
   ret=getRuleNumber6(clientAddr6);\r
-  if(debug) err_msg("DEBUG:(%d)<=getRuleNumber6( )",ret);\r
+  if(debug>1) err_msg("DEBUG:(%d)<=getRuleNumber6( )",ret);\r
 \r
   return ret;\r
 }\r
@@ -352,27 +352,27 @@ int OpenClientGate6(char *clientAddr6, char *userid, char *macAddr6, char *userP
 {\r
   int ret;\r
 \r
-  if(debug) err_msg("DEBUG:=>openClientGate6(%s,%s,%s,%s)",clientAddr6,userid,macAddr6,userProperty);\r
+  if(debug>1) err_msg("DEBUG:=>openClientGate6(%s,%s,%s,%s)",clientAddr6,userid,macAddr6,userProperty);\r
   ret=openClientGate6(clientAddr6, userid, macAddr6, userProperty);\r
-  if(debug) err_msg("DEBUG:(%d)<=openClientGate6( )",ret);\r
+  if(debug>1) err_msg("DEBUG:(%d)<=openClientGate6( )",ret);\r
 \r
   return ret;\r
 }\r
 \r
 void CloseClientGate6(struct clientAddr *pClientAddr, char *userid, char *macAddr6)\r
 {\r
-  if(debug) err_msg("DEBUG:=>closeClientGate6(%p,%s,%s)",pClientAddr,userid,macAddr6);\r
+  if(debug>1) err_msg("DEBUG:=>closeClientGate6(%p,%s,%s)",pClientAddr,userid,macAddr6);\r
   closeClientGate6(pClientAddr,userid,macAddr6);\r
-  if(debug) err_msg("DEBUG:<=closeClientGate6( )");\r
+  if(debug>1) err_msg("DEBUG:<=closeClientGate6( )");\r
 }\r
 \r
 int GetPacketCount6(char *ruleNumber)\r
 {\r
   int ret;\r
 \r
-  if(debug) err_msg("DEBUG:=>getPacketCount6(%s)",ruleNumber);\r
+  if(debug>1) err_msg("DEBUG:=>getPacketCount6(%s)",ruleNumber);\r
   ret=getPacketCount6(ruleNumber);\r
-  if(debug) err_msg("DEBUG:(%d)<=getPacketCount6( )",ret);\r
+  if(debug>1) err_msg("DEBUG:(%d)<=getPacketCount6( )",ret);\r
 \r
   return ret;\r
 }\r
@@ -381,15 +381,15 @@ int CountRuleNumber6(char *ruleNumber)
 {\r
   int ret;\r
   \r
-  if(debug) err_msg("DEBUG:=>countRuleNumber6(%s)", ruleNumber);\r
+  if(debug>1) err_msg("DEBUG:=>countRuleNumber6(%s)", ruleNumber);\r
   ret=countRuleNumber6(ruleNumber);\r
-  if(debug) err_msg("DEBUG:(%d)<=countRuleNumber6( )",ret);\r
+  if(debug>1) err_msg("DEBUG:(%d)<=countRuleNumber6( )",ret);\r
   \r
   return ret;\r
 }\r
 \r
 void DelIp6fwRule(char *ruleNumber){\r
-  if(debug) err_msg("DEBUG:=>delIp6fwRule(%s)",ruleNumber);\r
+  if(debug>1) err_msg("DEBUG:=>delIp6fwRule(%s)",ruleNumber);\r
   delIp6fwRule(ruleNumber);\r
-  if(debug) err_msg("DEBUG:<=delIp6fwRule( )");\r
+  if(debug>1) err_msg("DEBUG:<=delIp6fwRule( )");\r
 }\r
index 0b1afa1..8d72b56 100644 (file)
@@ -340,9 +340,9 @@ int GetRuleNumber4(char *clientAddr4)
 {
   int ret;
 
-  if(debug) err_msg("DEBUG:=>getRuleNumber4(%s)",clientAddr4);
+  if(debug>1) err_msg("DEBUG:=>getRuleNumber4(%s)",clientAddr4);
   ret=getRuleNumber4(clientAddr4);
-  if(debug) err_msg("DEBUG:(%d)<=getRuleNumber4( )",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=getRuleNumber4( )",ret);
 
   return ret;
 }
@@ -351,18 +351,18 @@ int OpenClientGate4(char *clientAddr4, char *userid, char *macAddr4, char *userP
 {
   int ret;
 
-  if(debug) err_msg("DEBUG:=>openClientGate4(%s,%s,%s,%s)",clientAddr4,userid,macAddr4,userProperty);
+  if(debug>1) err_msg("DEBUG:=>openClientGate4(%s,%s,%s,%s)",clientAddr4,userid,macAddr4,userProperty);
   ret=openClientGate4(clientAddr4, userid, macAddr4, userProperty);
-  if(debug) err_msg("DEBUG:(%d)<=openClientGate4( )",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=openClientGate4( )",ret);
 
   return ret;
 }
 
 void CloseClientGate4(struct clientAddr *pClientAddr, char *userid, char *macAddr4)
 {
-  if(debug) err_msg("DEBUG:=>closeClientGate4(%p,%s,%s)",pClientAddr,userid,macAddr4);
+  if(debug>1) err_msg("DEBUG:=>closeClientGate4(%p,%s,%s)",pClientAddr,userid,macAddr4);
   closeClientGate4(pClientAddr,userid,macAddr4);
-  if(debug) err_msg("DEBUG:<=closeClientGate4( )");
+  if(debug>1) err_msg("DEBUG:<=closeClientGate4( )");
 }
 
 
@@ -370,26 +370,26 @@ int GetPacketCount4(char *ruleNumber)
 {
   int ret;
 
-  if(debug) err_msg("DEBUG:=>getPacketCount4(%s)",ruleNumber);
+  if(debug>1) err_msg("DEBUG:=>getPacketCount4(%s)",ruleNumber);
   ret=getPacketCount4(ruleNumber);
-  if(debug) err_msg("DEBUG:(%d)<=getPacketCount4( )",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=getPacketCount4( )",ret);
 
   return ret;
 }
 
 void DelIpfwRule(char *ruleNumber){
- if(debug) err_msg("DEBUG:=>delIpfwRule(%s)",ruleNumber);
+ if(debug>1) err_msg("DEBUG:=>delIpfwRule(%s)",ruleNumber);
   delIpfwRule(ruleNumber);
-  if(debug) err_msg("DEBUG:<=delIpfwRule( )");
+  if(debug>1) err_msg("DEBUG:<=delIpfwRule( )");
 }
 
 int CountRuleNumber4(char *ruleNumber)
 {
   int ret;
   
-  if(debug) err_msg("DEBUG:=>countRuleNumber4(%s)", ruleNumber);
+  if(debug>1) err_msg("DEBUG:=>countRuleNumber4(%s)", ruleNumber);
   ret=countRuleNumber4(ruleNumber);
-  if(debug) err_msg("DEBUG:(%d)<=countRuleNumber4( )",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=countRuleNumber4( )",ret);
   
   return ret;
 }
index 543a4e0..00a71f1 100644 (file)
@@ -207,23 +207,23 @@ int GetMacAddrFromNdp(char *clientAddr6, char* macAddr6)
 {
   int ret;
 
-  if(debug) err_msg("DEBUG:=>getMacAddrFromNdp(%s,)",clientAddr6);
+  if(debug>1) err_msg("DEBUG:=>getMacAddrFromNdp(%s,)",clientAddr6);
   ret=getMacAddrFromNdp(clientAddr6,macAddr6);
-  if(debug) err_msg("DEBUG:(%d)<=getMacAddrFromNdp(,%s)",ret,macAddr6);
+  if(debug>1) err_msg("DEBUG:(%d)<=getMacAddrFromNdp(,%s)",ret,macAddr6);
 
   return ret;
 }
 
 void DeleteNdpEntry(char *clientAddr6)
 {
-  if(debug) err_msg("DEBUG:=>deleteNdpEntry(%s)",clientAddr6);
+  if(debug>1) err_msg("DEBUG:=>deleteNdpEntry(%s)",clientAddr6);
   deleteNdpEntry(clientAddr6);
-  if(debug) err_msg("DEBUG:<=deleteNdpEntry( )");
+  if(debug>1) err_msg("DEBUG:<=deleteNdpEntry( )");
 }
 
 void ScanNdpEntry(struct clientAddr *pClientAddr, char *userid, char *macAddr6, char *userProperty)
 {
-  if(debug) err_msg("DEBUG:=>scanNdpEntry(%p,%s,%s,%s)",pClientAddr,userid,macAddr6, userProperty);
+  if(debug>1) err_msg("DEBUG:=>scanNdpEntry(%p,%s,%s,%s)",pClientAddr,userid,macAddr6, userProperty);
   scanNdpEntry(pClientAddr,userid,macAddr6,userProperty);
-  if(debug) err_msg("DEBUG:<=scanNdpEntry( )");
+  if(debug>1) err_msg("DEBUG:<=scanNdpEntry( )");
 }
index 889ad2a..7d0f34c 100644 (file)
@@ -41,9 +41,9 @@ int GetUserProperty(char *userid, char *userProperty)
 {
   int ret;
 
-  if(debug) err_msg("DEBUG:=>getUserProperty(%s,)",userid);
+  if(debug>1) err_msg("DEBUG:=>getUserProperty(%s,)",userid);
   ret=getUserProperty(userid,userProperty);
-  if(debug) err_msg("DEBUG:(%d)<=getUserProperty(,%s)",ret, userProperty);
+  if(debug>1) err_msg("DEBUG:(%d)<=getUserProperty(,%s)",ret, userProperty);
 
   return ret;
 }
index 46bc755..2702bcf 100644 (file)
@@ -316,10 +316,10 @@ void listAlarm(void)
 int AddAlarm(char *name, int timeout, int preceding, Sigfunc *func){
   int ret;
 
-  if(debug) err_msg("DEBUG:=>addAlarm(%s,%d, %d, %x)", 
+  if(debug>1) err_msg("DEBUG:=>addAlarm(%s,%d, %d, %x)", 
                    name, timeout, preceding, func);
   ret=addAlarm(name, timeout, preceding, func);
-  if(debug) err_msg("DEBUG:(%d)<=addAlarm( )",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=addAlarm( )",ret);
 
   return ret;
 }
@@ -327,12 +327,12 @@ int AddAlarm(char *name, int timeout, int preceding, Sigfunc *func){
 int RemoveAlarm(char *name){
   int ret;
 
-  if(debug){
+  if(debug>1){
     if(name==NULL) err_msg("DEBUG:=>removeAlarm(NULL)");
     else           err_msg("DEBUG:=>removeAlarm(%s)", name);
   }
   ret=removeAlarm(name);
-  if(debug) err_msg("DEBUG:(%d)<=removeAlarm( )",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=removeAlarm( )",ret);
 
   return ret;
 }
@@ -340,9 +340,9 @@ int RemoveAlarm(char *name){
 int EnableAlarm(void){
   int ret;
 
-  if(debug) err_msg("DEBUG:=>enableAlarm()");
+  if(debug>1) err_msg("DEBUG:=>enableAlarm()");
   ret=enableAlarm();
-  if(debug) err_msg("DEBUG:(%d)<=enableAlarm( )",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=enableAlarm( )",ret);
 
   return ret;
 }
@@ -350,9 +350,9 @@ int EnableAlarm(void){
 int DisableAlarm(void){
   int ret;
 
-  //  if(debug) err_msg("DEBUG:=>disableAlarm()");
+  //  if(debug>1) err_msg("DEBUG:=>disableAlarm()");
   ret=disableAlarm();
-  //  if(debug) err_msg("DEBUG:(%d)<=disableAlarm( )",ret);
+  //  if(debug>1) err_msg("DEBUG:(%d)<=disableAlarm( )",ret);
 
   return ret;
 }
index aac2a2f..099a765 100644 (file)
@@ -325,44 +325,44 @@ int getPacketCount(struct clientAddr *pClientAddr)
 int OpenClientGate(char *clientAddr4, char *macAddr4, char *clientAddr6, char *macAddr6, char *userid, char *userProperty, int ipStatus)
 {
   int ret;
-  if(debug) err_msg("DEBUG:=>openClientGate(%s,%s,%s,%s,%s,%s,%d)",clientAddr4,macAddr4,clientAddr6,macAddr6,userid,userProperty, ipStatus);
+  if(debug>1) err_msg("DEBUG:=>openClientGate(%s,%s,%s,%s,%s,%s,%d)",clientAddr4,macAddr4,clientAddr6,macAddr6,userid,userProperty, ipStatus);
   ret = openClientGate(clientAddr4,macAddr4,clientAddr6,macAddr6,userid,userProperty, ipStatus);
-  if(debug) err_msg("DEBUG:(%d)<=openClientGate()",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=openClientGate()",ret);
   return ret;
 }
 
 struct clientAddr *CreateAddrListItem(char* ipAddr, char *ruleNumber, int ipType)
 {
   struct clientAddr *ret;
-  if(debug) err_msg("DEBUG:=>createAddrListItem(%s,%s,%d)",ipAddr,ruleNumber,ipType);
+  if(debug>1) err_msg("DEBUG:=>createAddrListItem(%s,%s,%d)",ipAddr,ruleNumber,ipType);
   ret = createAddrListItem(ipAddr, ruleNumber, ipType);
-  if(debug) err_msg("DEBUG: [%p] <=createAddrListItem( )",ret);
+  if(debug>1) err_msg("DEBUG: [%p] <=createAddrListItem( )",ret);
   return ret;
 }
 
 int CheckIpVersions(char *clientAddr4, char *clientAddr6)
 {
   int ret;
-  if(debug) err_msg("DEBUG:=>checkIpVersions(%s,%s)", clientAddr4, clientAddr6);
+  if(debug>1) err_msg("DEBUG:=>checkIpVersions(%s,%s)", clientAddr4, clientAddr6);
   ret=checkIpVersions(clientAddr4, clientAddr6);
-  if(debug) err_msg("DEBUG:(%d)<=checkIpVersions( )", ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=checkIpVersions( )", ret);
 
   return ret;
 }
 
 void RemoveOverlapRule(int overlapRule4, int overlapRule6){
 
-  if(debug) err_msg("DEBUG:=>removeOverlapRule(%d,%d)",overlapRule4,overlapRule6);
+  if(debug>1) err_msg("DEBUG:=>removeOverlapRule(%d,%d)",overlapRule4,overlapRule6);
   removeOverlapRule(overlapRule4,overlapRule6);
-  if(debug) err_msg("DEBUG:<=removeOverlapRule( )");
+  if(debug>1) err_msg("DEBUG:<=removeOverlapRule( )");
 }
 
 void KillOverlapProcess(int overlapRule4, int overlapRule6, 
                       char *clientAddr4, char *clientAddr6){
-  if(debug) err_msg("DEBUG:=>killOverlapProcess(%d,%d,%s,%s)", 
+  if(debug>1) err_msg("DEBUG:=>killOverlapProcess(%d,%d,%s,%s)", 
                    overlapRule4,overlapRule6,clientAddr4,clientAddr6);
   killOverlapProcess(overlapRule4,overlapRule6,clientAddr4,clientAddr6);
-  if(debug) err_msg("DEBUG:<=killOverlapProcess( )");
+  if(debug>1) err_msg("DEBUG:<=killOverlapProcess( )");
 }
 
 
@@ -370,9 +370,9 @@ int GetPacketCount(struct clientAddr *pClientAddr)
 {
   int ret;
 
-  if(debug) err_msg("DEBUG:=>getPacketCount(%p)",pClientAddr);
+  if(debug>1) err_msg("DEBUG:=>getPacketCount(%p)",pClientAddr);
   ret=getPacketCount(pClientAddr);
-  if(debug) err_msg("DEBUG:(%d)<=getPacketCount( )",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=getPacketCount( )",ret);
 
   return ret;
 }
index 1f9a596..a6b3c29 100644 (file)
@@ -107,24 +107,24 @@ int isSameMacAddr(char* macAddr4, char* macAddr6){
 /*****************************************************/
 void ReFormatMacAddr(char* macAddr4, char* macAddr6)
 {
-  if(debug) err_msg("DEBUG:=>reFormatMacAddr(%s)", macAddr4);
+  if(debug>1) err_msg("DEBUG:=>reFormatMacAddr(%s)", macAddr4);
   reFormatMacAddr(macAddr4, macAddr6);
-  if(debug) err_msg("DEBUG:<=reFormatMacAddr(%s)", macAddr6);
+  if(debug>1) err_msg("DEBUG:<=reFormatMacAddr(%s)", macAddr6);
 }
 
 void GetMacAddr(char *clientAddr4, char *macAddr4, char *clientAddr6, char *macAddr6, int ipStatus)
 {
-  if(debug) err_msg("DEBUG:=>getMacAddr(%s,,%s,,%d)",clientAddr4,clientAddr6,ipStatus);
+  if(debug>1) err_msg("DEBUG:=>getMacAddr(%s,,%s,,%d)",clientAddr4,clientAddr6,ipStatus);
   getMacAddr(clientAddr4,macAddr4,clientAddr6,macAddr6, ipStatus);
-  if(debug) err_msg("DEBUG:<=getMacAddr(,%s,,%s)", macAddr4, macAddr6);
+  if(debug>1) err_msg("DEBUG:<=getMacAddr(,%s,,%s)", macAddr4, macAddr6);
 }
 
 int IsSameMacAddr(char* macAddr4, char* macAddr6){
   int ret;
 
-  if(debug) err_msg("DEBUG:=>isSameMacAddr(%s,%s)",macAddr4,macAddr6);
+  if(debug>1) err_msg("DEBUG:=>isSameMacAddr(%s,%s)",macAddr4,macAddr6);
   ret=isSameMacAddr(macAddr4,macAddr6);
-  if(debug) err_msg("DEBUG:(%d)<=isSameMacAddr( )",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=isSameMacAddr( )",ret);
 
   return ret;
 }
index 11cc9f2..2d7a453 100644 (file)
@@ -316,51 +316,51 @@ char *convertToFacilityRaw(char *pValue)
 /***********************************************/
 int OpenConfFile(void){
   int ret;
-  if(debug) err_msg("DEBUG:=>openConfFile( )");
+  if(debug>1) err_msg("DEBUG:=>openConfFile( )");
   ret = openConfFile();
-  if(debug) err_msg("DEBUG:(%d)<=openConfFile( )",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=openConfFile( )",ret);
   return ret;
 }
 
 void CloseConfFile(void){
-  if(debug) err_msg("DEBUG:=>closeConfFile( )");
+  if(debug>1) err_msg("DEBUG:=>closeConfFile( )");
   closeConfFile();
-  if(debug) err_msg("DEBUG:<=closeConfFile( )");
+  if(debug>1) err_msg("DEBUG:<=closeConfFile( )");
 }
 
 void SetupConfExtra(char *userId, char *extraId){
-  if(debug) err_msg("DEBUG:=>setupConfExtra(%s,%s)",userId, extraId);
+  if(debug>1) err_msg("DEBUG:=>setupConfExtra(%s,%s)",userId, extraId);
   setupConfExtra(userId, extraId);
-  if(debug) err_msg("DEBUG:<=setupConfExtra( )");
+  if(debug>1) err_msg("DEBUG:<=setupConfExtra( )");
 }
 
 char *GetConfValue(char *name){
   char *ret;
-  if(debug) err_msg("DEBUG:=>getConfValue(%s)",name);
+  if(debug>1) err_msg("DEBUG:=>getConfValue(%s)",name);
   ret=getConfValue(name);
-  if(debug) err_msg("DEBUG:(%s)<=getConfValue( )",ret);
+  if(debug>1) err_msg("DEBUG:(%s)<=getConfValue( )",ret);
   return ret;
 }
 
 char *GetConfValueExtra(char *name){
   char *ret;
-  if(debug) err_msg("DEBUG:=>getConfValueExtra(%s)",name);
+  if(debug>1) err_msg("DEBUG:=>getConfValueExtra(%s)",name);
   ret=getConfValueExtra(name);
-  if(debug) err_msg("DEBUG:(%s)<=getConfValueExtra( )",ret);
+  if(debug>1) err_msg("DEBUG:(%s)<=getConfValueExtra( )",ret);
   return ret;
 }
 
 void InitConf(void){
-  if(debug) err_msg("DEBUG:=>initConf( )");
+  if(debug>1) err_msg("DEBUG:=>initConf( )");
   initConf();
-  if(debug) err_msg("DEBUG:<=initConf( )");
+  if(debug>1) err_msg("DEBUG:<=initConf( )");
 }
 
 int RegExMatch(const char *inStr, const char *regEx){
   int ret;
-  if(debug) err_msg("DEBUG:=>regExMatch(%s,%s)", inStr, regEx);
+  if(debug>1) err_msg("DEBUG:=>regExMatch(%s,%s)", inStr, regEx);
   ret=regExMatch(inStr, regEx);
-  if(debug) err_msg("DEBUG:(%d)<=regExMatch( )",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=regExMatch( )",ret);
   return ret;
 }
   
index 7812c70..3b2b4b9 100644 (file)
@@ -96,25 +96,25 @@ char* strSplit(char* str,const char* delimStr)
 int HtmlTemplate(char* filename, struct html_key* keys){
 
   int ret;
-  if(debug) err_msg("DEBUG:=>htmlTemlate(%s,..)", 
+  if(debug>1) err_msg("DEBUG:=>htmlTemlate(%s,..)", 
                    filename);
   ret = htmlTemplate(filename,keys);
-  if(debug) err_msg("DEBUG:(%d)<=htmlTemplate()",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=htmlTemplate()",ret);
   return ret;
 }
 
 int HtmlReplace(char* buff,char *beforeStr,char *afterStr){
   int ret;
-  if(debug) err_msg("DEBUG:=>htmlReplace(%s,%s,%s)",buff,beforeStr,afterStr);
+  if(debug>1) err_msg("DEBUG:=>htmlReplace(%s,%s,%s)",buff,beforeStr,afterStr);
   ret = htmlReplace(buff, beforeStr, afterStr);
-  if(debug) err_msg("DEBUG:(%d)<=htmlReplace()",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=htmlReplace()",ret);
   return ret;
 }
 char* StrSplit(char* str,const char* delimStr){
   char* ret;
-  if(debug) err_msg("DEBUG:=>strSplit(%s,%s)",str,delimStr);
+  if(debug>1) err_msg("DEBUG:=>strSplit(%s,%s)",str,delimStr);
   ret = strSplit(str, delimStr);
-  if(debug) err_msg("DEBUG:(%s)<=strSplit()",ret);
+  if(debug>1) err_msg("DEBUG:(%s)<=strSplit()",ret);
   return ret;
 }
 
index 43d1ae6..35fb182 100644 (file)
@@ -41,6 +41,7 @@ char extraId[USERMAXLN];
 char userProperty[BUFFMAXLN];
 time_t timeIn, timeOut;
 int connectionMode;   /* client connect mode */
+char sessionId[BUFFMAXLN];    /* session ID */
 
 void PutCloseMsg(time_t timeOut, time_t timeIn);
 void SetProcessTitle(char *useridshort, char *clientAddr4, char * ruleNumber4, char *clientAddr6, char * ruleNumber6, int ipStatus);
@@ -56,6 +57,7 @@ int  main(int argc, char **argv)
   int port;
   int dummyfd[2];
   int pid;
+  int parentpid;
   int duration;     /* requested usage duration */
   int authResult;
   int ipStatus;              /* flag for IPv4 or IPv6 */
@@ -124,6 +126,9 @@ int  main(int argc, char **argv)
     return 0;
   }
 
+  /* create session ID */
+  CreateSessionId(sessionId);
+
   /* set terminate signal handler */
   if(Signal(SIGTERM, closeExit)==SIG_ERR){
     PutClientMsg("Error: Please contact to the administrator");    
@@ -146,6 +151,8 @@ int  main(int argc, char **argv)
     closeExit(1);
   }
 
+  parentpid=getpid();
+
   /* fork */
   if((pid=Fork())==-1){
     err_msg("ERR at %s#%d: fork error",__FILE__,__LINE__);
@@ -156,7 +163,7 @@ int  main(int argc, char **argv)
   if(pid!=0){
     /** parent process **/
     /* send accept page with java */
-    PutClientAccept(userid, port, pid, clientAddr4, clientAddr6, ipStatus, duration, watchMode);
+    PutClientAccept(userid, sessionId, port, pid, clientAddr4, clientAddr6, ipStatus, duration, watchMode);
 
     /* detach from Web server */
     return 0;
@@ -173,7 +180,7 @@ int  main(int argc, char **argv)
   /* wait connection from the client */
   /* if no connection, close gate when duration is passed */
   /* or ipaddr for the macAddr4 is changed */
-  connectionMode=WaitClientConnect(userid, userProperty, clientAddr4, clientAddr6, duration, macAddr4, macAddr6, ipStatus, pClientAddr, language, port);
+  connectionMode=WaitClientConnect(userid, userProperty, sessionId, clientAddr4, clientAddr6, duration, macAddr4, macAddr6, ipStatus, pClientAddr, language, port, parentpid);
 
   if(connectionMode==JAVACONNECT){
 
@@ -238,7 +245,7 @@ void closeExit(int signo)
   /* put out time */
   timeOut=time(NULL);
   PutCloseMsg(timeOut,timeIn);
-  if(debug) err_msg("DEBUG:terminated");
+  if(debug>1) err_msg("DEBUG:terminated");
 
   exit(1);
 }
@@ -276,7 +283,7 @@ void logConnectMode(char *userid)
   char *mode[4]={"NONE","JAVA","HTTP","TIME"};
 
   if(connectionMode<0 || connectionMode>3) connectionMode=0;
-  err_msg("INFO: user %s is watched by [%s]",userid, mode[connectionMode]);
+  if(debug>0) err_msg("INFO: user %s is watched by [%s]",userid, mode[connectionMode]);
 }
 
 
@@ -284,14 +291,14 @@ void logConnectMode(char *userid)
 /*****************************/
 void PutCloseMsg(time_t timeOut, time_t timeIn)
 {
-  if(debug) err_msg("DEBUG:=>putCloseMsg( )");
+  if(debug>1) err_msg("DEBUG:=>putCloseMsg( )");
   putCloseMsg(timeOut,timeIn);
-  if(debug) err_msg("DEBUG:<=putCloseMsg( )");
+  if(debug>1) err_msg("DEBUG:<=putCloseMsg( )");
 }
 
 void SetProcessTitle(char *useridshort, char *clientAddr4, char * ruleNumber4, char *clientAddr6, char * ruleNumber6, int ipStatus){
-  if(debug) err_msg("DEBUG:=>setProcessTitle(%s,%s,%s,%s,%s,%d)",useridshort,
+  if(debug>1) err_msg("DEBUG:=>setProcessTitle(%s,%s,%s,%s,%s,%d)",useridshort,
                    clientAddr4,ruleNumber4,clientAddr6,ruleNumber6, ipStatus);
   setProcessTitle(useridshort,clientAddr4,ruleNumber4,clientAddr6,ruleNumber6,ipStatus);
-  if(debug) err_msg("DEBUG:<=setProcessTitle( )");
+  if(debug>1) err_msg("DEBUG:<=setProcessTitle( )");
 }
index c976a7e..7f81cd3 100644 (file)
@@ -1,7 +1,7 @@
 /**************************************************
 Opengate authentication CGI main
 
-This program is accessed as [http(s)://xx.yy/opengateauth.cgi?ja]
+This program is accessed as [http(s)://xx.yy/opengateauth.cgi?0-0-0&ja]
 It send out the authentication page after keywords replacement.
 
 Copyright (C) 2005 Opengate Project Team
@@ -69,7 +69,7 @@ int  main(int argc, char **argv)
   /* initialize config */
   InitConf();
 
-  if(debug) err_msg("DEBUG: started");
+  if(debug>1) err_msg("DEBUG: started");
 
   /* create URL string */
   snprintf(authCgiUrl, BUFFMAXLN, "%s%s%s/%s",
@@ -112,13 +112,13 @@ int  main(int argc, char **argv)
     paramString[0]='\0';
   }
 
-  /* split language and address */
+  /* split language and address in paramString[addr=0-0-0&lang=ja] */
   pAddr4=paramString;
-  pLang=strnstr(paramString, "&", BUFFMAXLN);
-  if(pLang!=NULL){
-    *pLang='\0';
-    pLang++;
+  if((pLang=strnstr(paramString, "&", BUFFMAXLN))!=NULL){
+    *pLang='\0'; pLang++;
   }
+  if(strnstr(pAddr4, "addr=", BUFFMAXLN)==pAddr4) pAddr4+=5;
+  if(strnstr(pLang, "lang=", BUFFMAXLN)==pLang)  pLang+=5;
 
   /* copy clientAddr(encoded) */
   if(isNull(pAddr4)){
@@ -155,7 +155,7 @@ int  main(int argc, char **argv)
   /* replace keywords and send out */
   HtmlTemplate(htmlFile, keys);
 
-  if(debug) err_msg("DEBUG: terminated");  
+  if(debug>1) err_msg("DEBUG: terminated");  
 
   return 0;
 }
index f45de49..306cdec 100644 (file)
@@ -67,7 +67,7 @@ int  main(int argc, char **argv)
   /* initialize config */
   InitConf();
 
-  if(debug) err_msg("DEBUG: started");
+  if(debug>1) err_msg("DEBUG: started");
 
   /* create authcgi URL string */
   snprintf(authCgiUrl, BUFFMAXLN, "%s%s%s/%s",
@@ -110,7 +110,7 @@ int  main(int argc, char **argv)
   /* relpace keywords and send out */
   HtmlTemplate(htmlFile, keys);
 
-  if(debug) err_msg("DEBUG: terminated");
+  if(debug>1) err_msg("DEBUG: terminated");
 
   return 0;
 }
index e16f237..2153ae2 100644 (file)
@@ -69,7 +69,7 @@ typedef       void    Sigfunc(int);   /* for signal handlers */
 #define CONFIGFILE "/etc/opengate/opengatesrv.conf"
 
 
-#define COMMWAITTIMEOUT 60         /* communication reply timeout(second) */
+#define COMMWAITTIMEOUT 30         /* communication reply timeout(second) */
 #define PACKETLOGDELAY 10          /* wait log writing time(second)   */
 #define LOCKTIMEOUT 10   /* ipfw exclusive exec lock timeout (second) */
 #define MAXFWDDELAY 300   /* max delay from fwd.cgi to auth.cgi (second) */
@@ -151,12 +151,12 @@ int CheckReferer(void);
 void PutClientDeny(char *clientAddr4);
 void PutClientRetry(char *lang);
 void PutClientMsg(char *message);
-void PutClientAccept(char *userid, int port, int pid, char *clientAddr4, char *clientAddr6, int ipStatus, int duration, char *watchMode);
+void PutClientAccept(char *userid, char *sessionId, int port, int pid, char *clientAddr4, char *clientAddr6, int ipStatus, int duration, char *watchMode);
 
-/* TCP communication with java applet */
+/* TCP communication with client */
 void WaitJavaClose(struct clientAddr *pClientAddr, char *userid, char *userProperty, char *macAddr6, int ipStatus);
 int GetListenPort(void);
-int WaitClientConnect(char *userid, char *userProperty, char *clientAddr4, char *clientAddr6, int duration, char *macAddr4, char *macAddr6, int ipStatus, struct clientAddr *pClientAddr, char *language, int port);
+int WaitClientConnect(char *userid, char *userProperty, char *sessionId, char *clientAddr4, char *clientAddr6, int duration, char *macAddr4, char *macAddr6, int ipStatus, struct clientAddr *pClientAddr, char *language, int port, int pid);
 void WaitHttpClose(struct clientAddr *pClientAddr, char *userid, char *userProperty, char *macAddr6, int ipStatus);
 
 /* utilities */
@@ -171,6 +171,7 @@ int Systeml(const char *path, ...);
 int Pclose(FILE *stream);
 int isNull(const char *pStr);
 char *GetServicePortStr(char *servName);
+void CreateSessionId(char *sessionId);
 
 void ReFormatMacAddr(char* macAddr4, char* macAddr6);
 void GetMacAddr(char *clientAddr4, char *macAddr4, char *clientAddr6, char *macAddr6, int ipStatus);
index 84a53d4..5bd84e5 100644 (file)
@@ -97,8 +97,8 @@ int  main(int argc, char **argv)
   printf("===============================================\n\n");
 
   /* connection wait */
-  connMode=WaitClientConnect(userID, "", clientAddr4,clientAddr6, 
-                          duration,"?","?",4,pClientAddr, language, port);
+  connMode=WaitClientConnect(userID, "", "999",clientAddr4,clientAddr6, 
+                          duration,"?","?",4,pClientAddr, language, port, 99);
   switch(connMode){
 
   case JAVACONNECT:
index d5747a7..44b773a 100644 (file)
@@ -65,12 +65,15 @@ void WritefmtSSL(SSL *fd, const char *fmt, ...)
   return;
 }
 
-/**************************************************/
-/* Read one line                                  */
-/*  fd: file descriptor                           */
-/*  vptr: input buffer pointer                    */
-/*  maxlen: buffer length                         */
-/**************************************************/
+/****************************************************/
+/* Read one line                                    */
+/*  fd: file descriptor                             */
+/*  vptr: input buffer pointer                      */
+/*  maxlen: buffer length                           */
+/* return value is the count of readin chars        */
+/*              if error, return -1                 */
+/* ## this function assumes two EOL chars [CR LF]   */ 
+/****************************************************/
 ssize_t
 readln(int fd, void *vptr, size_t maxlen)
 {
@@ -81,37 +84,30 @@ readln(int fd, void *vptr, size_t maxlen)
 
   /* pre read */
   rc = read(fd, &c, 1);
-  if(rc <= 0) return rc;
-
-  /* skip one control char, if exist */
-  /*  this is the second char of CR LF */
-  /*  the first char is read as the end of previous line */
-  if(iscntrl(c)){
-    rc = read(fd, &c, 1);
-    if(rc <= 0) return rc;
-  }
+  if(rc<=0) return(-1);
 
   /* get char loop */
   n=0;
   while(n < maxlen-1) {
     if ( rc == 1) {      /* get some char */
-      if (iscntrl(c))break; /* cntrl char means line end */
+      if (iscntrl(c)){         /* get control char (means EOL) */
+       rc = read(fd, &c, 1);  /* skip second EOL char */
+       break;
+      }
       *ptr++ = c;
       n++;
     }else if (rc == 0) { /* EOF */
       break;
     } else {             /* ERR */
-      if (errno != EINTR) return(-1);
+      return(-1);
     }
     rc = read(fd, &c, 1);
   }
   /* null terminate string */  
   *ptr++ = 0;
-  n++;
   return(n);
 }
 
-
 ssize_t
 readlnSSL(SSL *fd, void *vptr, size_t maxlen)
 {
@@ -120,31 +116,29 @@ readlnSSL(SSL *fd, void *vptr, size_t maxlen)
 
   ptr=vptr;
 
-  /* skip pre ctrl char */
-  while(1){
-    rc = SSL_read(fd, &c, 1);
-    if(rc <= 0) return rc;
-    if(iscntrl(c)) continue;
-    break;  /* get some normal char */
-  }
+  /* pre read */
+  rc = SSL_read(fd, &c, 1);
+  if(rc<=0) return(-1);
 
   /* get char loop */
   n=0;
   while(n < maxlen-1) {
     if ( rc == 1) {      /* get some char */
-      if (iscntrl(c))break; /* cntrl char means line end */
+      if (iscntrl(c)){      /* get control char (means EOL) */
+         rc = SSL_read(fd, &c, 1); /* skip second EOL char */
+         break;
+      }
       *ptr++ = c;
       n++;
     }else if (rc == 0) { /* EOF */
       break;
     } else {             /* ERR */
-      if (errno != EINTR) return(-1);
+      return(-1);
     }
     rc = SSL_read(fd, &c, 1);
   }
   /* null terminate string */  
   *ptr++ = 0;
-  n++;
   return(n);
 }
 
@@ -216,9 +210,9 @@ FILE *Popenl(const char *type, const char *path, ...)
   va_end(ap);
 
   /* open the pipe to the program  */
-  if(debug) err_msg("DEBUG:=>popen(%s, %s)", commandLine, type);
+  if(debug>1) err_msg("DEBUG:=>popen(%s, %s)", commandLine, type);
   file=popen(commandLine, type);
-  if(debug) err_msg("DEBUG:(%x)<=popen( )",file);  
+  if(debug>1) err_msg("DEBUG:(%x)<=popen( )",file);  
 
   return file;
 }
@@ -251,9 +245,9 @@ int Systeml(const char *path, ...)
   va_end(ap);
 
   /* execute shell  */
-  if(debug) err_msg("DEBUG:=>system(%s)", commandLine);
+  if(debug>1) err_msg("DEBUG:=>system(%s)", commandLine);
   ret=system(commandLine);
-  if(debug) err_msg("DEBUG:<=system()");
+  if(debug>1) err_msg("DEBUG:<=system()");
 
   return ret;
 }
@@ -281,6 +275,16 @@ char *getServicePortStr(char *servName)
   return portStr;
 }
 
+/*******************************************/
+/* create random session id                */
+/*  simple but might be overlapped         */
+/*  change logic, if you need identical id */ 
+/*******************************************/
+void createSessionId(char *sessionId)
+{
+  srandom(getpid()+time(NULL));
+  snprintf(sessionId, BUFFMAXLN, "%ld", random() );
+}
 
 /****************************************/
 /****************************************/
@@ -288,9 +292,9 @@ int Pclose(FILE *stream)
 {
   int ret;
 
-  if(debug) err_msg("DEBUG:=>pclose( )");
+  if(debug>1) err_msg("DEBUG:=>pclose( )");
   ret = pclose(stream);
-  if(debug) err_msg("DEBUG:<=pclose( )");  
+  if(debug>1) err_msg("DEBUG:<=pclose( )");  
 
   return ret;
 }
@@ -299,9 +303,9 @@ char *GetServicePortStr(char *servName)
 {
   char *ret;
 
-  if(debug) err_msg("DEBUG:=>getServicePortStr(%s)", servName);
+  if(debug>1) err_msg("DEBUG:=>getServicePortStr(%s)", servName);
   ret = getServicePortStr(servName);
-  if(debug) err_msg("DEBUG:(%s)<=getServicePortStr( )", ret);  
+  if(debug>1) err_msg("DEBUG:(%s)<=getServicePortStr( )", ret);  
 
   return ret;
 }
@@ -310,11 +314,11 @@ ssize_t Readln(int fd, void *ptr, size_t maxlen)
 {
   ssize_t              n;
 
-  if(debug) err_msg("DEBUG:=>readln( )");
+  if(debug>1) err_msg("DEBUG:=>readln( )");
   if ( (n = readln(fd, ptr, maxlen)) < 0){
     err_msg("ERR at %s#%d: readln error",__FILE__,__LINE__);
   }
-  if(debug) err_msg("DEBUG:(%d)<=readln( )",n);
+  if(debug>1) err_msg("DEBUG:(%d)<=readln( )",n);
 
   return(n);
 }
@@ -323,9 +327,9 @@ int Lock(int fd)
 {
   int ret;
 
-  if(debug) err_msg("DEBUG:=>lock( )");
+  if(debug>1) err_msg("DEBUG:=>lock( )");
   ret=lock(fd);
-  if(debug) err_msg("DEBUG:(%d)<=lock( )",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=lock( )",ret);
 
   return ret;
 }
@@ -335,11 +339,16 @@ int Unlock(int fd)
 {
   int ret;
 
-  if(debug) err_msg("DEBUG:=>unlock( )");
+  if(debug>1) err_msg("DEBUG:=>unlock( )");
   ret=unlock(fd);
-  if(debug) err_msg("DEBUG:(%d)<=unlock( )",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=unlock( )",ret);
 
   return ret;
 }
 
 
+void CreateSessionId(char *sessionId){
+  if(debug>1) err_msg("DEBUG:=>createSessionId( )");
+  createSessionId(sessionId);
+  if(debug>1) err_msg("DEBUG:<=createSessionId(%s)",sessionId);
+}
index 8b87daf..3fdfa18 100644 (file)
@@ -29,7 +29,7 @@ void GetPeerAddr(int sockfd, char *peerAddr);
 void SendTerminateReply(void);
 void ReadHttpHeaders(void);
 void SendReplyToGetHello(void);
-void SendHttpKeepPage(char *userid, char *language, int port);
+void SendHttpKeepPage(char *userid, char *sessionId, char *language, int port);
 int SelectAccept(void);
 
 void OnUsageTimeLimitAlarm(int signo);
@@ -41,6 +41,7 @@ void OnAjaxWaitAlarm(int signo);
 
 extern char ruleNumber4[WORDMAXLN];  /* ipfw rule number in string form  */
 extern char ruleNumber6[WORDMAXLN];  /* ip6fw rule number in string form */
+extern char language[WORDMAXLN]; /* message language */
 
 int ipType=IPV4;                     /* using IP type */
 int listenfd[2]; /* file descriptor for listen port */
@@ -127,11 +128,12 @@ int getListenPort(void)
 /************************************/
 /* wait for connection of client side program */
 /************************************/
-int waitClientConnect(char *userid, char *userProperty, char *clientAddr4, char *clientAddr6, int duration, char *macAddr4, char *macAddr6, int ipStatus, struct clientAddr *pClientAddr, char *language, int port)
+int waitClientConnect(char *userid, char *userProperty, char *sessionId, char *clientAddr4, char *clientAddr6, int duration, char *macAddr4, char *macAddr6, int ipStatus, struct clientAddr *pClientAddr, char *language, int port, int pid)
 {
   char buff[BUFFMAXLN];             /* read in buffer */
   char connectAddr[ADDRMAXLN];      /* connected client address */
   char httpStr[BUFFMAXLN];          /* HTTP GET string at terminate */
+  char useridAndSessionId[BUFFMAXLN]; /* comcat userid and sessionid */
 
   /* set alarm function arguments */
   alarmArg.pClientAddr=pClientAddr;
@@ -144,32 +146,30 @@ int waitClientConnect(char *userid, char *userProperty, char *clientAddr4, char
   alarmArg.ipStatus=ipStatus;
   alarmArg.checkInterval=atoi(GetConfValue("ActiveCheck/Interval"));
   alarmArg.noPacketInterval=atoi(GetConfValue("ActiveCheck/NoPacketInterval"));  
+
+  /* set no conection initially */
+  connectMode=NOCONNECT;
+
   /* set the alarm for usage time limit */
   AddAlarm("UsageTimeLimitAlarm",duration,FALSE,OnUsageTimeLimitAlarm);
 
   /* set the alarm for periodic keep alive check */
   AddAlarm("CheckBasicAlarm", alarmArg.checkInterval, FALSE, OnCheckBasicAlarm);
-  /* start the alarms */
-  EnableAlarm();
-
 
   /* loop until accepting correct user */
-  while(1){
+  while(connectMode == NOCONNECT){
 
-    /* at termination, exit loop */
-    if(connectMode == ENDCONNECT) break;
+    /* start alarms */
+    EnableAlarm();
 
     /* connection wait */
     connfd = SelectAccept();
 
-    /* some abnormal connect */
-    if(connfd < 0){
-      if(connectMode==ENDCONNECT) break;
-      else continue;
-    }
+    /*at abnormal connect */
+    if(connfd < 0) continue;
 
-    /* normal connection */
-    /* stop alarm interupt between check exec */
+    /* at normal connection */
+    /* stop alarm interupt between checking */
     DisableAlarm();
     
     /* is it from the correct client addr */
@@ -177,6 +177,7 @@ int waitClientConnect(char *userid, char *userProperty, char *clientAddr4, char
     if(ipType==IPV4 && ipStatus!=IPV6ONLY){
       GetPeerAddr(connfd, connectAddr);
       if(isNull(connectAddr)||strcmp(connectAddr, clientAddr4)!=0){
+       connectMode=NOCONNECT;
        Close(connfd);
        continue;
       }
@@ -186,66 +187,71 @@ int waitClientConnect(char *userid, char *userProperty, char *clientAddr4, char
     AddAlarm("ReadWaitAlarm",COMMWAITTIMEOUT, TRUE, OnReadWaitAlarm); 
     EnableAlarm();
     /* get string from connection */
-    if(readln(connfd, buff, BUFFMAXLN) <=0){
-      /* if abnormal, exit */
-      connectMode=ENDCONNECT;
-      err_msg("ERR at %s#%d: abnormal readin ",
-           __FILE__,__LINE__);
-      break;
+    if(readln(connfd, buff, BUFFMAXLN) <0){
+      /* if abnormal, wait next request */
+      connectMode=NOCONNECT;
+      Close(connfd);
+      continue;
     }
     RemoveAlarm("ReadWaitAlarm");
 
-
     /* is it the correct userid from java applet */
-    if(strcmp(buff, userid)==0){
+    /* the request is [<userid>:<sessionId>] */
+    snprintf(useridAndSessionId, BUFFMAXLN, "%s-%s", userid,sessionId);
+    if(strcmp(buff, useridAndSessionId)==0){
+
+      /* enter to the Java watch mode on the connection */
       connectMode=JAVACONNECT;
       break;
     }
 
     /* is it the httpkeep page download request */
     /* the request is [GET /httpkeep.html ....] */
-    snprintf(httpStr, BUFFMAXLN, "GET /httpkeep-%s", userid);
+    snprintf(httpStr, BUFFMAXLN, "GET /httpkeep-%s-%s", userid,sessionId);
     
     if(strstr(buff, httpStr)==buff){
       
       /* page download request found */
       /* read out the remained headers and send the page */
       ReadHttpHeaders();
-      SendHttpKeepPage(userid, language, port);
-      
+      SendHttpKeepPage(userid, sessionId, language, port);
+
       /* to check the ajax ablility of the client, wait ajax request */
       AddAlarm("AjaxWaitAlarm",COMMWAITTIMEOUT, TRUE, OnAjaxWaitAlarm); 
       EnableAlarm();
       /* read wait for ajax request in the connection */
-      if(readln(connfd, buff, BUFFMAXLN) <=0){
-       connectMode=ENDCONNECT;         /* if abnormal or timeout, exit */
-       err_msg("ERR at %s#%d: abnormal readin or timeout",
-               __FILE__,__LINE__);
-       break;
+      if(readln(connfd, buff, BUFFMAXLN) <0){
+        /* if timeout, no ajax ability */
+       connectMode=NOCONNECT;  
+       Close(connfd);
+       continue;
       }
+      /* recieve request */
       RemoveAlarm("AjaxWaitAlarm");
       ReadHttpHeaders();
+
+      /* enter to the Http watch mode on the connection */
       connectMode=HTTPCONNECT;
       break;
     }
   
     /* is it the terminate request */
-    /* the request is [GET /terminate<pid> ....] */
-    snprintf(httpStr, BUFFMAXLN, "GET /terminate%d", getpid());
+    /* the request is [GET /terminate-<pid> ..] */
+    snprintf(httpStr, BUFFMAXLN, "GET /terminate-%d", pid);
     if(strstr(buff, httpStr)==buff){
       /* terminate request found */
       SendTerminateReply();
       connectMode=ENDCONNECT;
+      Close(connfd);
       break;
     }
-    
+
+    /* some other unknown request */    
     err_msg("ERR at %s#%d: unknown request [%s] sent from client",
            __FILE__,__LINE__);
     connectMode=NOCONNECT;
-
-    /* wait new connection */
     Close(connfd);
-    EnableAlarm();
+    continue;
   }
 
   /* stop all alarms */
@@ -429,7 +435,7 @@ void waitJavaClose(struct clientAddr *pClientAddr, char *userid, char *userPrope
     /* stop alarm */
     DisableAlarm();
 
-    if(ret>0){
+    if(ret>=0){
       /* normal read */
       connectMode=JAVACONNECT;
       /* read quit, then quit */
@@ -558,7 +564,7 @@ void waitHttpClose(struct clientAddr *pClientAddr, char *userid, char *userPrope
     /* at some request, stop alarm between readin check*/
     DisableAlarm();
 
-    if(ret>0){
+    if(ret>=0){
       /* normal read */
       connectMode=HTTPCONNECT;
 
@@ -585,6 +591,7 @@ void waitHttpClose(struct clientAddr *pClientAddr, char *userid, char *userPrope
     else{
       /*abnormal read */
       /* some alarm is ringed or connecion is closed */
+      /*  connectionMode might be modified in onAlarm */
       if(connectMode==ENDCONNECT) break;
     }
       
@@ -634,8 +641,10 @@ void readHttpHeaders(void)
   char buff[BUFFMAXLN];             /* read in buffer */
   int n;
 
-  /* read until null line (only CR code) */
-  while((n=readln(connfd, buff, BUFFMAXLN))>1);
+  /* read until null line (only CRLF code) */
+  while((n=readln(connfd, buff, BUFFMAXLN))>0){
+    ;
+  }
 }
 
 /********************************************************/
@@ -663,7 +672,7 @@ void sendReplyToGetHello(void)
 /***************************************************/
 /* send httpkeep page to client via connfd         */
 /***************************************************/
-void sendHttpKeepPage(char *userid, char *language, int port)
+void sendHttpKeepPage(char *userid, char *sessionId, char *language, int port)
 {
   char buff[BUFFMAXLN];             /* read in buffer */
   FILE *fp;
@@ -675,19 +684,22 @@ void sendHttpKeepPage(char *userid, char *language, int port)
   char httpkeepJsUrl[BUFFMAXLN];
   char *startPageUrl=GetConfValue("StartPage/Url");
   int startPageType=atoi(GetConfValue("StartPage/Type"));
+  char opengateDir[BUFFMAXLN];
+  char portStr[WORDMAXLN];
+
 
   /* create path to accept2 doc */
   snprintf(acceptDoc2Url, BUFFMAXLN, 
          "http://%s%s/%s/%s",GetConfValue("OpengateServerName"),
          GetConfValue("OpengateDir"),language,GetConfValue("AcceptDoc2"));
 
-  /* create terminate url [http://<servaddr>:<port>/terminate<pid>] */
-  snprintf(terminateUrl, BUFFMAXLN, "http://%s:%d/terminate%d", 
+  /* create terminate url [http://<servaddr>:<port>/terminate-<pid>] */
+  snprintf(terminateUrl, BUFFMAXLN, "http://%s:%d/terminate-%d", 
          GetConfValue("OpengateServerName"), port, getpid());
 
-  /* create httphello url [http://<servaddr>:<port>/hello-<userid>] */
-  snprintf(httpHelloUrl, BUFFMAXLN, "http://%s:%d/hello-%s", 
-         GetConfValue("OpengateServerName"), port, userid);
+  /* create httphello url [http://<servaddr>:<port>/hello] */
+  snprintf(httpHelloUrl, BUFFMAXLN, "http://%s:%d/hello", 
+         GetConfValue("OpengateServerName"), port);
 
   /* create httphello interval [50] */
   snprintf(httpHelloInterval, WORDMAXLN, "%s", GetConfValue("HttpHelloInterval"));
@@ -701,6 +713,13 @@ void sendHttpKeepPage(char *userid, char *language, int port)
   snprintf(httpKeepDoc,BUFFMAXLN, "%s%s/%s/%s",GetConfValue("DocumentRoot"),
          GetConfValue("OpengateDir"),language,GetConfValue("HttpKeepDoc"));
 
+  /* create port string */
+  snprintf(portStr, WORDMAXLN, "%d", port);
+
+  /* create absolute url to opengateDir[http://<serveraddr>/opengate] */
+  snprintf(opengateDir, BUFFMAXLN, "http://%s%s", 
+          GetConfValue("OpengateServerName"), GetConfValue("OpengateDir"));
+
   /* open httpkeepdoc */
   if((fp=fopen(httpKeepDoc, "r"))==NULL){
     err_msg("ERR at %s#%d: cannot open %s",__FILE__,__LINE__,httpKeepDoc);
@@ -722,9 +741,14 @@ void sendHttpKeepPage(char *userid, char *language, int port)
     htmlReplace(buff, "%%HTTPHELLOINTERVAL%%", httpHelloInterval);
     htmlReplace(buff, "%%HTTPHELLOURL%%", httpHelloUrl);
     htmlReplace(buff, "%%USERID%%", userid);
+    htmlReplace(buff, "%%SESSIONID%%", sessionId);
     htmlReplace(buff, "%%TERMINATEURL%%", terminateUrl);
     htmlReplace(buff, "%%HTTPKEEPJSURL%%", httpkeepJsUrl);
 
+    htmlReplace(buff, "%%OPENGATEDIR%%", opengateDir);
+    htmlReplace(buff, "%%OPENGATEPORT%%", portStr);
+    htmlReplace(buff, "%%LANGUAGE%%", language);
+
     /* replace start url mark */
     if( startPageType==1 ){
       htmlReplace(buff, "%%STARTURL%%", startPageUrl);
@@ -748,9 +772,9 @@ void sendHttpKeepPage(char *userid, char *language, int port)
 /***************************************************/
 void GetPeerAddr(int sockfd, char *peerAddr)
 {
-  if(debug) err_msg("DEBUG:=>getPeerAddr( )"); 
+  if(debug>1) err_msg("DEBUG:=>getPeerAddr( )"); 
   getPeerAddr(sockfd,peerAddr);
-  if(debug) err_msg("DEBUG:<=getPeerAddr(,%s)",peerAddr);
+  if(debug>1) err_msg("DEBUG:<=getPeerAddr(,%s)",peerAddr);
 }
 
 
@@ -758,124 +782,124 @@ int GetListenPort(void)
 {
   int ret;
 
-  if(debug) err_msg("DEBUG:=>getListenPort( )");
+  if(debug>1) err_msg("DEBUG:=>getListenPort( )");
   ret=getListenPort();
-  if(debug) err_msg("DEBUG:(%d)<=getListenPort( )",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=getListenPort( )",ret);
 
   return ret;
 }
 
-int WaitClientConnect(char *userid, char *userProperty, char *clientAddr4, char *clientAddr6, int duration, char *macAddr4, char *macAddr6, int ipStatus, struct clientAddr *pClientAddr, char *language, int port)
+int WaitClientConnect(char *userid, char *userProperty, char *sessionId, char *clientAddr4, char *clientAddr6, int duration, char *macAddr4, char *macAddr6, int ipStatus, struct clientAddr *pClientAddr, char *language, int port, int pid)
 {
   int ret;
 
-  if(debug) err_msg("DEBUG:=>waitClientConnect(%s,%s,%s,%s,%d,%s,%s,%d,%s,%d)",userid,userProperty,clientAddr4,clientAddr6,duration,macAddr4,macAddr6,ipStatus,language,port);
-  ret=waitClientConnect(userid,userProperty,clientAddr4,clientAddr6,duration,macAddr4,macAddr6,ipStatus,pClientAddr,language,port);
-  if(debug) err_msg("DEBUG:(%d)<=waitClientConnect( )",ret);
+  if(debug>1) err_msg("DEBUG:=>waitClientConnect(%s,%s,%s,%s,%s,%d,%s,%s,%d,%s,%d,%d)",userid,userProperty,sessionId,clientAddr4,clientAddr6,duration,macAddr4,macAddr6,ipStatus,language,port,pid);
+  ret=waitClientConnect(userid,userProperty,sessionId,clientAddr4,clientAddr6,duration,macAddr4,macAddr6,ipStatus,pClientAddr,language,port,pid);
+  if(debug>1) err_msg("DEBUG:(%d)<=waitClientConnect( )",ret);
 
   return ret;
 }
 
 void WaitJavaClose(struct clientAddr *pClientAddr, char *userid, char *userProperty, char *macAddr6, int ipStatus)
 {
-  if(debug) err_msg("DEBUG:=>waitJavaClose(%p,%s,%s,userProperty,%d)",pClientAddr,userid,macAddr6,ipStatus);
+  if(debug>1) err_msg("DEBUG:=>waitJavaClose(%p,%s,userProperty,%s,%d)",pClientAddr,userid,macAddr6,ipStatus);
   waitJavaClose(pClientAddr,userid,userProperty,macAddr6,ipStatus);
-  if(debug) err_msg("DEBUG:<=waitJavaClose( )");
+  if(debug>1) err_msg("DEBUG:<=waitJavaClose( )");
 }
 
 void SendQuitClient(void)
 {
-  if(debug) err_msg("DEBUG:=>sendQuitClient( )");
+  if(debug>1) err_msg("DEBUG:=>sendQuitClient( )");
   sendQuitClient();
-  if(debug) err_msg("DEBUG:<=sendQuitClient( )");
+  if(debug>1) err_msg("DEBUG:<=sendQuitClient( )");
 }
 
 void SendTerminateReply(void)
 {
-  if(debug) err_msg("DEBUG:=>sendTerminateReply( )");
+  if(debug>1) err_msg("DEBUG:=>sendTerminateReply( )");
   sendTerminateReply();
-  if(debug) err_msg("DEBUG:<=sendTerminateReply( )");
+  if(debug>1) err_msg("DEBUG:<=sendTerminateReply( )");
 }
 
 void WaitHttpClose(struct clientAddr *pClientAddr, char *userid, char *userProperty, char *macAddr6, int ipStatus)
 {
-  if(debug) err_msg("DEBUG:=>waitHttpClose(%p,%s,%s,userProperty,%d)",pClientAddr,userid,macAddr6,ipStatus);
+  if(debug>1) err_msg("DEBUG:=>waitHttpClose(%p,%s,userProperty,%s,%d)",pClientAddr,userid,macAddr6,ipStatus);
   waitHttpClose(pClientAddr,userid,userProperty,macAddr6,ipStatus);
-  if(debug) err_msg("DEBUG:<=waitHttpClose( )");
+  if(debug>1) err_msg("DEBUG:<=waitHttpClose( )");
 
 }
 
 void ReadHttpHeaders(void)
 {
-  if(debug) err_msg("DEBUG:=>readHttpHeaders( )");
+  if(debug>1) err_msg("DEBUG:=>readHttpHeaders( )");
   readHttpHeaders();
-  if(debug) err_msg("DEBUG:<=readHttpHeaders( )");
+  if(debug>1) err_msg("DEBUG:<=readHttpHeaders( )");
 }
 
 void SendReplyToGetHello(void)
 {
-  if(debug) err_msg("DEBUG:=>sendReplyToGetHello( )");
+  if(debug>1) err_msg("DEBUG:=>sendReplyToGetHello( )");
   sendReplyToGetHello();
-  if(debug) err_msg("DEBUG:<=sendReplyToGetHello( )");
+  if(debug>1) err_msg("DEBUG:<=sendReplyToGetHello( )");
 
 }
 
-void SendHttpKeepPage(char *userid, char *language, int port)
+void SendHttpKeepPage(char *userid, char *sessionId, char *language, int port)
 {
-  if(debug) err_msg("DEBUG:=>sendHttpKeepPage(%s,%s,%d,%d)", userid, language, port);
-  sendHttpKeepPage(userid, language, port);
-  if(debug) err_msg("DEBUG:<=sendHttpKeepPage( )");
+  if(debug>1) err_msg("DEBUG:=>sendHttpKeepPage(%s,%s,%s,%d)", userid, sessionId, language, port);
+  sendHttpKeepPage(userid, sessionId, language, port);
+  if(debug>1) err_msg("DEBUG:<=sendHttpKeepPage( )");
 
 }
 
 void OnUsageTimeLimitAlarm(int signo){
 
-  if(debug) err_msg("DEBUG:=>onUsageTimeLimitAlarm()");
+  if(debug>1) err_msg("DEBUG:=>onUsageTimeLimitAlarm()");
   onUsageTimeLimitAlarm(signo);
-  if(debug) err_msg("DEBUG:<=onUsageTimeLimitAlarm()");
+  if(debug>1) err_msg("DEBUG:<=onUsageTimeLimitAlarm()");
 }
 
 void OnCheckBasicAlarm(int signo){
 
-  if(debug) err_msg("DEBUG:=>onCheckBasicAlarm()");
+  if(debug>1) err_msg("DEBUG:=>onCheckBasicAlarm()");
   onCheckBasicAlarm(signo);
-  if(debug) err_msg("DEBUG:<=onCheckBasicAlarm()");
+  if(debug>1) err_msg("DEBUG:<=onCheckBasicAlarm()");
 }
 
 void OnCheckJavaAlarm(int signo){
 
-  if(debug) err_msg("DEBUG:=>onCheckJavaAlarm()");
+  if(debug>1) err_msg("DEBUG:=>onCheckJavaAlarm()");
   onCheckJavaAlarm(signo);
-  if(debug) err_msg("DEBUG:<=onCheckJavaAlarm()");
+  if(debug>1) err_msg("DEBUG:<=onCheckJavaAlarm()");
 }
 
 void OnCheckHttpAlarm(int signo){
 
-  if(debug) err_msg("DEBUG:=>onCheckHttpAlarm()");
+  if(debug>1) err_msg("DEBUG:=>onCheckHttpAlarm()");
   onCheckHttpAlarm(signo);
-  if(debug) err_msg("DEBUG:<=onCheckHttpAlarm()");
+  if(debug>1) err_msg("DEBUG:<=onCheckHttpAlarm()");
 }
 
 void OnReadWaitAlarm(int signo){
 
-  if(debug) err_msg("DEBUG:=>onReadWaitAlarm()");
+  if(debug>1) err_msg("DEBUG:=>onReadWaitAlarm()");
   onReadWaitAlarm(signo);
-  if(debug) err_msg("DEBUG:<=onReadWaitAlarm()");
+  if(debug>1) err_msg("DEBUG:<=onReadWaitAlarm()");
 }
 
 void OnAjaxWaitAlarm(int signo){
 
-  if(debug) err_msg("DEBUG:=>onAjaxWaitAlarm()");
+  if(debug>1) err_msg("DEBUG:=>onAjaxWaitAlarm()");
   onAjaxWaitAlarm(signo);
-  if(debug) err_msg("DEBUG:<=onAjaxWaitAlarm()");
+  if(debug>1) err_msg("DEBUG:<=onAjaxWaitAlarm()");
 }
 
 int SelectAccept(void){
   int ret;
 
-  if(debug) err_msg("DEBUG:=>selectAccept()");
+  if(debug>1) err_msg("DEBUG:=>selectAccept()");
   ret=selectAccept();
-  if(debug) err_msg("DEBUG:(%d)<=selectAccept()",ret);
+  if(debug>1) err_msg("DEBUG:(%d)<=selectAccept()",ret);
 
   return ret;
 }