Weblogic 只允许能连接5个IP的解决办法

Weblogic 只允许能连接5个IP的解决办法

0. Weblogic试用版只允许连接5个不同IP, 尽管可重新启动weblogic server可以重新获取5个IP,
对于开发测试环境来说, 对于开发测试来说很不方便, 也不可能购买Weblogic的licences.


1. shell scripts & Java command
local_port: 12345
host: ydc062
remote_port: 8080

java -classpath ./Relay.jar Relay 12345 ydc062 8080

2. 使用方法
http://ydc062:8080(limit 5 ip)

http://ydc062:12345(not limit forward to above access)


3. Java source code

/**
* DataRelay.java
*/
import java.io.InputStream;
import java.io.OutputStream;

public class DataRelay implements Runnable {
private InputStream in;

private OutputStream out;

public void run() {
byte abyte0[] = new byte[4096];
try {
do {
int i = in.read(abyte0);
if (i == 0)
break;
out.write(abyte0, 0, i);
} while (true);
try {
in.close();
} catch (Exception exception) {
}
try {
out.close();
} catch (Exception exception1) {
}
} catch (Exception exception2) {
try {
in.close();
} catch (Exception exception3) {
}
try {
out.close();
} catch (Exception exception4) {
}
}
}

public DataRelay(InputStream inputstream, OutputStream outputstream) {
in = inputstream;
out = outputstream;
}
}


/**
* Relay.java
*/
import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class Relay implements Runnable {

public int listenPort;

public String relayHost;

public int relayPort;

public Relay() {
}

public Relay(int i, String s, int j) {
listenPort = i;
relayHost = s;
relayPort = j;
}

public void run() {
try {
ServerSocket serversocket = new ServerSocket(listenPort);
do {
Socket socket = serversocket.accept();
try {
Socket socket1 = new Socket(relayHost, relayPort);
startRelay(socket.getInputStream(), socket1
.getOutputStream());
startRelay(socket1.getInputStream(), socket
.getOutputStream());
} catch (Exception exception1) {
exception1.printStackTrace();
socket.close();
}
} while (true);
} catch (Exception exception) {
exception.printStackTrace();
}
}

public void startRelay(InputStream inputstream, OutputStream outputstream)
throws IOException {
DataRelay datarelay = new DataRelay(inputstream, outputstream);
Thread thread = new Thread(datarelay);
thread.start();
}

public static void main(String args[]) {
if (args.length < 3) {
System.out.println("-------------------------------------------");
System.out.println("Usage: ./Relay local_port host remote_port");
System.out.println("-------------------------------------------");
System.exit(0);
}
int i = 0;
try {
i = Integer.parseInt(args[0]);
} catch (Exception exception) {
System.out.println("Invalid local port: " + args[0]);
System.exit(0);
}
int j = 0;
try {
j = Integer.parseInt(args[2]);
} catch (Exception exception1) {
System.out.println("Invalid remote port: " + args[2]);
System.exit(0);
}
Relay relay = new Relay(i, args[1], j);
relay.run();
}

}

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/4082/viewspace-1003120/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/4082/viewspace-1003120/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值