- };
-
- private static final JS isResolvable = new JS() {
- public Object call(org.xwt.js.JSArray args) throws JSExn {
- try {
- return (InetAddress.getByName(args.elementAt(0).toString()) != null) ? Boolean.TRUE : Boolean.FALSE;
- } catch (UnknownHostException e) {
- return Boolean.FALSE;
- }
- }
- };
-
- private static final JS isInNet = new JS() {
- public Object call(org.xwt.js.JSArray args) throws JSExn {
- if (args.length() != 3) return Boolean.FALSE;
- try {
- byte[] host = InetAddress.getByName(args.elementAt(0).toString()).getAddress();
- byte[] net = InetAddress.getByName(args.elementAt(1).toString()).getAddress();
- byte[] mask = InetAddress.getByName(args.elementAt(2).toString()).getAddress();
- return ((host[0] & mask[0]) == net[0] &&
- (host[1] & mask[1]) == net[1] &&
- (host[2] & mask[2]) == net[2] &&
- (host[3] & mask[3]) == net[3]) ?
- Boolean.TRUE : Boolean.FALSE;
- } catch (Exception e) {
- throw new JSExn("exception in isInNet(): " + e);
- }
- }
- };
-
- private static final JS dnsResolve = new JS() {
- public Object call(org.xwt.js.JSArray args) throws JSExn {
- try {
- return InetAddress.getByName(args.elementAt(0).toString()).getHostAddress();
- } catch (UnknownHostException e) {
- return null;
- }
- }
- };
-
- private static final JS myIpAddress = new JS() {
- public Object call(org.xwt.js.JSArray args) throws JSExn {
- try {
- return InetAddress.getLocalHost().getHostAddress();
- } catch (UnknownHostException e) {
- if (Log.on) Log.log(this, "strange... host does not know its own address");
- return null;
- }