aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/Ivy.java24
-rwxr-xr-xsrc/IvyWatcher.java10
-rw-r--r--src/Probe.java16
-rw-r--r--src/ProxyClient.java23
-rw-r--r--src/ProxyMaster.java18
-rw-r--r--src/Puppet.java26
6 files changed, 100 insertions, 17 deletions
diff --git a/src/Ivy.java b/src/Ivy.java
index 2647434..5e3362f 100755
--- a/src/Ivy.java
+++ b/src/Ivy.java
@@ -13,6 +13,8 @@
*</pre>
*
* CHANGELOG:
+ * 1.2.13:
+ * - adds support for RESyntaxException
* 1.2.12:
* - directMessage goes protected
* 1.2.9:
@@ -114,7 +116,7 @@ public class Ivy implements Runnable {
* the library version, useful for development purposes only, when java is
* invoked with -DIVY_DEBUG
*/
- public static final String libVersion ="1.2.12";
+ public static final String libVersion ="1.2.13";
private boolean debug;
private ServerSocket app;
@@ -235,7 +237,12 @@ public class Ivy implements Runnable {
Properties sysProp = System.getProperties();
sysProp.put("IVYBUS",domainbus);
String range=(String)sysProp.get("IVYRANGE");
- RE rangeRE = new RE("(\\d+)-(\\d+)"); // tcp range min and max
+ RE rangeRE; // tcp range min and max
+ try {
+ rangeRE = new RE("(\\d+)-(\\d+)"); // tcp range min and max
+ } catch ( RESyntaxException res ) {
+ throw new IvyException("Regular Expression bug in Ivy source code ... bailing out");
+ }
if ((range!=null)&&rangeRE.match(range)) {
int rangeMin=Integer.parseInt(rangeRE.getParen(1));
int rangeMax=Integer.parseInt(rangeRE.getParen(2));
@@ -575,7 +582,18 @@ public class Ivy implements Runnable {
* @param exp a string regular expression
* must be synchronized ( RE is not threadsafe )
*/
- private static final RE bounded = new RE("^\\^([a-zA-Z0-9_-]+).*");
+ private static RE bounded ;
+
+ static {
+ try {
+ bounded = new RE("^\\^([a-zA-Z0-9_-]+).*");
+ } catch ( RESyntaxException res ) {
+ res.printStackTrace();
+ System.out.println("Regular Expression bug in Ivy source code ... bailing out");
+ System.exit(0);
+ }
+ }
+
public synchronized boolean CheckRegexp( String exp ) {
if (filter==null) return true; // there's no message filter
if (!bounded.match(exp)) return true; // the regexp is not bounded
diff --git a/src/IvyWatcher.java b/src/IvyWatcher.java
index bf8dc3f..3281079 100755
--- a/src/IvyWatcher.java
+++ b/src/IvyWatcher.java
@@ -14,6 +14,9 @@
* thing.
*
* CHANGELOG:
+ * 1.2.13:
+ * - TCP_NO_DELAY to disable Nagle's algorithm
+ * - private static ?! pour already present ...
* 1.2.9:
* - added an application Id in the UDP broadcast. It seems to be ok with
* most implementations ( VERSION PORT APPID APPNAME \n) is compatible with (VERSION
@@ -187,7 +190,9 @@ class IvyWatcher implements Runnable {
if (!alreadyBroadcasted(remotehost.toString(),remotePort)) {
traceDebug("no known agent originating from " + remotehost + ":" + remotePort);
try {
- bus.createIvyClient(new Socket(remotehost,remotePort),remotePort,false);
+ Socket s = new Socket(remotehost,remotePort);
+ s.setTcpNoDelay(true);
+ bus.createIvyClient(s,remotePort,false);
} catch ( java.net.ConnectException jnc ) {
traceDebug("cannot connect to "+remotehostname+":"+remotePort+", he probably stopped his bus");
}
@@ -278,7 +283,8 @@ class IvyWatcher implements Runnable {
*
* regoes static ...
*/
- private static Hashtable alreadySocks=new Hashtable();
+ //private static Hashtable alreadySocks=new Hashtable();
+ private Hashtable alreadySocks=new Hashtable();
private synchronized boolean alreadyBroadcasted(String s,int port) {
// System.out.println("DEBUUUUUUUG " + s+ ":" + port);
if (s==null) return false;
diff --git a/src/Probe.java b/src/Probe.java
index 56085fe..c3f05c2 100644
--- a/src/Probe.java
+++ b/src/Probe.java
@@ -7,6 +7,8 @@
* (c) CENA
*
* Changelog:
+ * 1.2.13
+ * - adds support for RESyntaxException
* 1.2.12
* - .ping is back
* 1.2.9
@@ -145,9 +147,19 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin
private Ivy bus;
private boolean timestamp,quiet,debug,exitOnDie=false;
- private static RE directMsgRE = new RE("^\\.direct ([^ ]*) ([0-9]+) (.*)");
- private static RE timeCountRE = new RE("^\\.time (\\d+) (.*)");
+ private static RE directMsgRE, timeCountRE;
+
+ static {
+ try {
+ directMsgRE = new RE("^\\.direct ([^ ]*) ([0-9]+) (.*)");
+ timeCountRE = new RE("^\\.time (\\d+) (.*)");
+ } catch ( RESyntaxException res ) {
+ res.printStackTrace();
+ System.out.println("Regular Expression bug in Ivy source code ... bailing out");
+ System.exit(0);
+ }
+ }
public Probe(BufferedReader in, boolean timestamp,boolean quiet,boolean debug) {
this.in=in;
this.timestamp=timestamp;
diff --git a/src/ProxyClient.java b/src/ProxyClient.java
index 9eb1e41..91af0ba 100644
--- a/src/ProxyClient.java
+++ b/src/ProxyClient.java
@@ -7,7 +7,9 @@
* (c) ENAC
*
* changelog:
- * 1.2.12
+ * 1.2.13
+ * - adds support for RESyntaxException
+ *
*/
package fr.dgac.ivy ;
import java.io.*;
@@ -96,10 +98,21 @@ public class ProxyClient extends Ivy {
send("Hello bus="+domain);
}
- RE getId=new RE("^ID id=(.*) value=(.*)");
- RE fwdGhost=new RE("^ForwardGhost id=(.*) buffer=(.*)");
- RE fwdPuppet=new RE("^ForwardPuppet id=(.*) buffer=(.*)");
- RE puppetRe=new RE("^CreatePuppet id=(.*)");
+ static RE getId,fwdGhost,fwdPuppet,puppetRe;
+
+ static {
+ try {
+ getId=new RE("^ID id=(.*) value=(.*)");
+ fwdGhost=new RE("^ForwardGhost id=(.*) buffer=(.*)");
+ fwdPuppet=new RE("^ForwardPuppet id=(.*) buffer=(.*)");
+ puppetRe=new RE("^CreatePuppet id=(.*)");
+ } catch ( RESyntaxException res ) {
+ res.printStackTrace();
+ System.out.println("Regular Expression bug in Ivy source code ... bailing out");
+ System.exit(0);
+ }
+ }
+
void parseMsg(String msg) {
// System.out.println("PC parsing "+msg);
if (getId.match(msg)) {
diff --git a/src/ProxyMaster.java b/src/ProxyMaster.java
index f80fa11..f8585fd 100644
--- a/src/ProxyMaster.java
+++ b/src/ProxyMaster.java
@@ -7,6 +7,8 @@
* (c) ENAC
*
* changelog:
+ * 1.2.13
+ * - adds support for RESyntaxException
* 1.2.12
*/
package fr.dgac.ivy.tools ; // TODO go into sub tools, and build a shell/.BAT script
@@ -86,8 +88,19 @@ public class ProxyMaster {
PrintWriter out;
String hostname=null; // I will know from the socket
String busDomain=null; // I will know it from the Hello message
+ RE helloRE, getId,fwdPuppet,fwdGhost;
SubReader(Socket socket) throws IOException {
+ try {
+ helloRE=new RE("^Hello bus=(.*)");
+ getId=new RE("^GetID id=(.*)");
+ fwdPuppet=new RE("^ForwardPuppet id=(.*) buffer=(.*)");
+ fwdGhost=new RE("^ForwardGhost id=(.*) buffer=(.*)");
+ } catch ( RESyntaxException res ) {
+ res.printStackTrace();
+ System.out.println("Regular Expression bug in Ivy source code ... bailing out");
+ System.exit(0);
+ }
proxyClients.addElement(this);
hostname = socket.getInetAddress().getHostName();
in=new BufferedReader(new InputStreamReader(socket.getInputStream()));
@@ -119,10 +132,7 @@ public class ProxyMaster {
proxyClients.removeElement(this);
}
- RE helloRE=new RE("^Hello bus=(.*)");
- RE getId=new RE("^GetID id=(.*)");
- RE fwdPuppet=new RE("^ForwardPuppet id=(.*) buffer=(.*)");
- RE fwdGhost=new RE("^ForwardGhost id=(.*) buffer=(.*)");
+
void parseMsg(String msg) {
// System.out.println("PM parsing "+msg);
diff --git a/src/Puppet.java b/src/Puppet.java
index e2a90ee..5398798 100644
--- a/src/Puppet.java
+++ b/src/Puppet.java
@@ -1,3 +1,16 @@
+/**
+ * Part of a Ivy-level proxy
+ *
+ * @author Yannick Jestin
+ * @author <a href="http://www.tls.cena.fr/products/ivy/">http://www.tls.cena.fr/products/ivy/</a>
+ *
+ * (c) CENA 1998-2004
+ *
+ * CHANGELOG:
+ * 1.2.13:
+ * - adds support for RESyntaxException
+ */
+
package fr.dgac.ivy ;
import java.lang.Thread;
import java.net.*;
@@ -57,7 +70,18 @@ class Puppet {
}
// ivy forwarded protocol message
- static final RE ivyProto = new RE("(\\d+) (\\d+)\\02(.*)");
+ static RE ivyProto;
+
+ static {
+ try {
+ ivyProto = new RE("(\\d+) (\\d+)\\02(.*)");
+ } catch ( RESyntaxException res ) {
+ res.printStackTrace();
+ System.out.println("Regular Expression bug in Ivy source code ... bailing out");
+ System.exit(0);
+ }
+ }
+
void parse(String s) throws IvyException {
if (!ivyProto.match(s)) { System.out.println("Puppet error, can't parse "+s); return; }
int pcode=Integer.parseInt(ivyProto.getParen(1));