7 Star 15 Fork 3

马尔凯斯 / cc.hanzs.server

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
LGPL-3.0

#cc.hanzs.server ##. ###介绍 1、此项目为服务端框架,
2、配合cc.hanzs.clent使用。
3、不支持web。
4、写此项目的目的是建立精简、高效、安全的网路连接服务。
5、服务端与客户端之间采用了类似TLS的方式。因无法考证,不知是在TLS之前还是之後,我是在写完这个通信框架之後接触到TLS的。
6、限制单一IP地址频繁访问,阀值是注册用户的2倍。好处是预防DOS攻击,但带来的风险是转而伪造企业公网IP与服务器握手,造成企业无法正常访问云服务。
7、对DDOS、窃取数据在应用层面做了预防处理,降低了被攻击的风险、窃取数据的速度。单一客户端受到如下限制:
  1)只能串行访问。
  2)客户端只承认握手时的IP。
  3)访问频率受到限制,超出峰值频率,则断开对客户端的服务,默认峰值50次。包含心跳服务,此次客户端默认心跳服务1次/分钟。服务端会每分钟递减访问频率,以保障服务器正常提供服务。
  4)向服务器发送的数据量受到限制,超出峰值数据量,则断开对客户端的服务,默认峰值9600。以防客户端向服务端发送大量数据,实测当中,NIO模式下XP系统一次最大只能发送9600。
  5)向服务器请求的数据量受到限制,超出峰值数据量,则断开对客户端的服务,默认峰值12000。以防客户端频繁请求返回数据量大的服务。
  6)向服务器发送的压缩包的压缩率受限,预防压缩包炸弹攻击。
8、不能预防下面问题
  1)同时大量数据涌入,服务器忙于接收数据,阻塞服务器。应用层只接收前(注册用户数量*2)个连接的数据,单次接收的容量是9600字节,攻陷阀值不清楚。
  2)控制肉鸡与服务器握手,利用rsa算法消耗服务器资源。当肉鸡数量足够多时,会造成服务器忙于解密。每个IP的阀值是注册用户数量的2倍,被攻陷的阀值是多少不清楚。
  3)如果是云服务器,伪造企业公网IP与服务器不停的握手,虽然不能攻陷服务器,但也能让企业无法访问服务器,因为服务器会认为受到攻击而拒绝服务,将正常的访问也过滤掉了。
  4)除了基础协议先天问题外,还有就是认为失误、客户端被攻击。例如员工离职,未在系统内注销该员工的权限;客户端被攻陷,用户被当作肉鸡或口令被窃取等等。
9、此框架可用于非web领域。如管理软件,或类似的环境,实现业务与web的分离。 ##. ###所用编辑器 NetBeans、JAVA8。
lib.7z解压到lib文件夹即可,为所需jar。
cc.hanzs.server.7z解压後可得编译并优化後的jar。 ##. ###遵循协议 为尽量保障作者的辛劳与顾客的使用,此项目遵循LGPLv3协议:
1、对软件本身可以修改,但任何人不得将软件本身及修改版用于商业行为。
2、任何人对软件的使用(调用、封装,包括修改後的)可免费用于商业软件。
3、对软件的技术支持,技术支持者可收取费用。 ##. ###使用方法

public class 优化入口 extends cc.hanzs.server.业务.__ {

    public static void main(String[] args) {
        try {
            //配置负载参數
            cc.hanzs.server.负载均衡.Property.i中心端口_i = 8080;


            //此rsa针对java客户端,可将密钥长度提高到很长
            cc.hanzs.server.负载均衡.Property.rsa = cc.hanzs.安全.RSA.d副本(1);
            cc.hanzs.server.负载均衡.Property.rsa.g置私钥(cc.hanzs.编码.Base64.d解码.decode("MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAvnU1UYcd93QJv9VLZuCAPONa9QBL5HaiJEkmecnAZZl0QUsrnVYIUF9uIdQu538YVHhFgdXpgF+PKWQ6NkLcfwIDAQABAkEAoYQQlXU6qpHTesXNzg7xcbF1f3Si57rbwl3urTW1XfKNuoRj9eNW1hvii67V61/6TTdqTQ/VBqVSMNB7sOLQQQIhAPo+JJY78fhXr3uWJ0Hvp8GjVk3kOU6Pm5IDx/5SO/AxAiEAwtbzHMDqjJHuIvLrm5q0nB6Os7WzhAlcWyhX3gecm68CIFUpFsxlxBfux1J4rA19YIq+al2BoJsCtj+/t6zuEWXRAiEAqlYfPoENzQz7YwR6pJPw2BgC6+urYICKhItVnh+Lc7MCIHhkYzuaBPF9DrMj4sNwxiQCxrRHC2iXVmI/5fVw/QWE"));
//            cc.hanzs.server.负载均衡.Property.rsa.g置公钥(cc.hanzs.编码.Base64.d解码.decode("MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAL51NVGHHfd0Cb/VS2bggDzjWvUAS+R2oiRJJnnJwGWZdEFLK51WCFBfbiHULud/GFR4RYHV6YBfjylkOjZC3H8CAwEAAQ=="));

            //此rsa针对c#客户端,固定长度为1024
            //JAVA:
            //公钥:MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCRhc5tk4nJzI3WcDZNDuUjtrVF2IHpBUeW5FMMwdrEYlzqIMjOny4f2GshlDqKfl21Xevj3y0/khhCeKLQp+5cDAafKDXj39GZmG7HKeWZp+DC8AErVYsQCRaXAJuzuowmmunbOa4XoOBfF3aG8o54vz1Tty2MfZpDAur0mUdWbwIDAQAB
            //私钥:MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJGFzm2TicnMjdZwNk0O5SO2tUXYgekFR5bkUwzB2sRiXOogyM6fLh/YayGUOop+XbVd6+PfLT+SGEJ4otCn7lwMBp8oNePf0ZmYbscp5Zmn4MLwAStVixAJFpcAm7O6jCaa6ds5rheg4F8Xdobyjni/PVO3LYx9mkMC6vSZR1ZvAgMBAAECgYAUbIEyY9ic1/a4N/uHCSYjwwriCKcC+1i21sjJK5P2qA9+VKeaSEEC+y7eAZ3NvjqMr+fhjXseRvTcr226dzc+wcGsxkJGWq3uTQa1od4yY1Mu5SRX7OnQ1wnYuIxhgt3+pMtjCe/JbAAZOd+GyDp4t2LJdwPRwOLKzIGmuBb+4QJBAMhxrG0UuQDGreviM1yIwrK/OFNN4EJunGWyrmi23YWxvBIFiGV0IEXRxpXKW/lAMGyQ3q2z9NQjfq/vrkq7EVkCQQC52zzELHNDkHzR3yow5SeEXfyafrdrAyGe+UM0KyOZyUkAvHj6VV7z7Kl8JAzsBdZFU/ujhJeysGNgYlSs6CUHAkEAkI5qa8CmK4kdpSBdKj73KzH8zRc8xKxA3pcecSZwXBryJ40V8RTusWu4bA6khf1k7ucLsPo3d0ah9wBEEmEXAQJAVJ1gq/uEupT0juQoJDyf4h6cG4ZnYRv62ZKoKv8c5S4Dw4cLGQV3BlyPyQnsrCP4KnYS0Z5TJjIx/DaoUFQcTwJAPBkI6jnZ5WzhfGmLfjqzsteICdY3OAO+E+Bsxu2MU3JFGXctu+MW1G+M2+2qZ4jJOsz3WQTY77ZOaH78Ja6kHA==
            //
            //C#:
            //公钥为:AQAB
            //模为:kYXObZOJycyN1nA2TQ7lI7a1RdiB6QVHluRTDMHaxGJc6iDIzp8uH9hrIZQ6in5dtV3r498tP5IYQnii0KfuXAwGnyg149/RmZhuxynlmafgwvABK1WLEAkWlwCbs7qMJprp2zmuF6DgXxd2hvKOeL89U7ctjH2aQwLq9JlHVm8=
            cc.hanzs.server.负载均衡.Property.RsaForDot = cc.hanzs.安全.RSA.d副本(2);
            cc.hanzs.server.负载均衡.Property.RsaForDot.g置私钥(cc.hanzs.编码.Base64.d解码.decode("MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJGFzm2TicnMjdZwNk0O5SO2tUXYgekFR5bkUwzB2sRiXOogyM6fLh/YayGUOop+XbVd6+PfLT+SGEJ4otCn7lwMBp8oNePf0ZmYbscp5Zmn4MLwAStVixAJFpcAm7O6jCaa6ds5rheg4F8Xdobyjni/PVO3LYx9mkMC6vSZR1ZvAgMBAAECgYAUbIEyY9ic1/a4N/uHCSYjwwriCKcC+1i21sjJK5P2qA9+VKeaSEEC+y7eAZ3NvjqMr+fhjXseRvTcr226dzc+wcGsxkJGWq3uTQa1od4yY1Mu5SRX7OnQ1wnYuIxhgt3+pMtjCe/JbAAZOd+GyDp4t2LJdwPRwOLKzIGmuBb+4QJBAMhxrG0UuQDGreviM1yIwrK/OFNN4EJunGWyrmi23YWxvBIFiGV0IEXRxpXKW/lAMGyQ3q2z9NQjfq/vrkq7EVkCQQC52zzELHNDkHzR3yow5SeEXfyafrdrAyGe+UM0KyOZyUkAvHj6VV7z7Kl8JAzsBdZFU/ujhJeysGNgYlSs6CUHAkEAkI5qa8CmK4kdpSBdKj73KzH8zRc8xKxA3pcecSZwXBryJ40V8RTusWu4bA6khf1k7ucLsPo3d0ah9wBEEmEXAQJAVJ1gq/uEupT0juQoJDyf4h6cG4ZnYRv62ZKoKv8c5S4Dw4cLGQV3BlyPyQnsrCP4KnYS0Z5TJjIx/DaoUFQcTwJAPBkI6jnZ5WzhfGmLfjqzsteICdY3OAO+E+Bsxu2MU3JFGXctu+MW1G+M2+2qZ4jJOsz3WQTY77ZOaH78Ja6kHA=="));
//            cc.hanzs.server.负载均衡.Property.rsa.g置公钥(cc.hanzs.编码.Base64.d解码.decode("MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCRhc5tk4nJzI3WcDZNDuUjtrVF2IHpBUeW5FMMwdrEYlzqIMjOny4f2GshlDqKfl21Xevj3y0/khhCeKLQp+5cDAafKDXj39GZmG7HKeWZp+DC8AErVYsQCRaXAJuzuowmmunbOa4XoOBfF3aG8o54vz1Tty2MfZpDAur0mUdWbwIDAQAB"));

            //启动负载均衡
            cc.hanzs.server.负载均衡.负载.init(new 优化入口());
            cc.hanzs.server.负载均衡.负载.start();
            System.out.println("启动完毕");
        } catch (java.io.IOException | java.security.NoSuchAlgorithmException | java.security.spec.InvalidKeySpecException ex) {
        }
    }

    @Override
    public byte[] g处理请求(final int session_i, final byte[] ci客户数据_bytes) {
        cc.hanzs.json.JSONObject ji_JSON = cc.hanzs.json.JSONObject.d副本("{success:true,_:'测试'}");
        ji_JSON.put("@", session_i);
        return ji_JSON.toString().getBytes();
    }

    @Override
    public void removeSession(int session_i) {
    }
}

私钥公钥由用户自己生成,公钥发布给客户端使用。

GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. [http://fsf.org/] Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.

简介

写此项目的目的是建立精简、高效、安全的网路连接服务,具有预防DDOS攻击的作用,适用非WEB领域。 展开 收起
Java
LGPL-3.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/18981885165/cc.hanzs.server.git
git@gitee.com:18981885165/cc.hanzs.server.git
18981885165
cc.hanzs.server
cc.hanzs.server
master

搜索帮助