netcrusher java
1.0.0
NetCrusher是Java的TCP/UDP代理框架,也是可以放置在任何客户端和服务器之间的中间的命令行工具,并允许检查双方是否有故障转移。
NetCrusher建立在Java 8 Nio之上,除SLF4J外没有外部依赖关系。
阅读文档。
下载最新的dist.tar.gz以获取命令行工具。
NioReactor reactor = new NioReactor ();
TcpCrusher crusher = TcpCrusherBuilder . builder ()
. withReactor ( reactor )
. withBindAddress ( "localhost" , 10080 )
. withConnectAddress ( "google.com" , 80 )
. buildAndOpen ();
// ... some actions
// emulate reconnect
crusher . reopen ();
// ... check the client connection is reestablished successfully
// closing
crusher . close ();
reactor . close (); NioReactor reactor = new NioReactor ();
DatagramCrusher crusher = DatagramCrusherBuilder . builder ()
. withReactor ( reactor )
. withBindAddress ( "localhost" , 10188 )
. withConnectAddress ( "time-nw.nist.gov" , 37 )
. buildAndOpen ();
// ... some actions
// check data is sent
Assert . assertTrue ( crusher . getInner (). getReadDatagramMeter (). getTotal () > 0 );
// closing
crusher . close ();
reactor . close ();检查项目根文件夹中的其他示例:
对于手动QA,命令行包装器可用于TCP和Datagram模式
$ ./run-tcp-crusher.sh 127.0.0.1:12345 google.com:80
# Version: 0.8
# Print `HELP` for the list of the commands
# enter the command in the next line
CLOSE
[20:19:20.586] INFO TcpCrusher </127.0.0.1:12345>-<google.com/64.233.161.101:80> is closed
[20:19:20.586] INFO Crusher is closed
# enter the command in the next line
OPEN
[20:19:21.655] INFO TcpCrusher </127.0.0.1:12345>-<google.com/64.233.161.101:80> is open
[20:19:21.655] INFO Crusher is open
有关Wiki中命令行模式的更多信息。
< dependency >
< groupId >com.github.netcrusherorg</ groupId >
< artifactId >netcrusher-core</ artifactId >
< version >0.10</ version >
</ dependency >请参阅Wiki页面
Apache许可证版本2.0,http://www.apache.org/licenses/license-2.0.html