NetConnectionConfig.java 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.communityserver.network.netcon;
  16. import java.io.File;
  17. import java.io.FileInputStream;
  18. import java.io.InputStream;
  19. import java.util.Properties;
  20. public final class NetConnectionConfig
  21. {
  22. public NetConnectionConfig (final String configFilePath) throws Exception
  23. {
  24. final Properties settings = new Properties();
  25. final InputStream is = new FileInputStream(new File(configFilePath));
  26. settings.load(is);
  27. is.close();
  28. INITIAL_CRYPT = settings.getProperty("InitialCrypt", "_;v.]05-31!|+-%xT!^[$\00");
  29. TCP_EXTERNAL_HOST_ADDRESS = settings.getProperty("ExternalHostAddress", "*");
  30. TCP_EXTERNAL_PORT = Integer.parseInt(settings.getProperty("ExternalPort", "0"));
  31. TCP_CONNECTION_QUEUE = Integer.parseInt(settings.getProperty("ConnectionQueue", "50"));
  32. TCP_FLOOD_PROTECTION_ENABLED = Boolean.parseBoolean(settings.getProperty("FloodProtectionEnabled", "False"));
  33. TCP_FAST_CONNECTION_LIMIT = Integer.parseInt(settings.getProperty("FastConnectionLimit", "15"));
  34. TCP_FAST_CONNECTION_TIME = Integer.parseInt(settings.getProperty("FastConnectionTime", "350"));
  35. TCP_NORMAL_CONNECTION_TIME = Integer.parseInt(settings.getProperty("NormalConnectionTime", "700"));
  36. TCP_MAX_CONNECTION_PER_IP = Integer.parseInt(settings.getProperty("MaxConnectionperIP", "50"));
  37. TCP_IP_BANN_ENABLED = Boolean.parseBoolean(settings.getProperty("IPBannEnabled", "False"));
  38. TCP_IP_BANN_LIST = settings.getProperty("IPBannList", "").split(":");
  39. TCP_SEND_BUFFER_SIZE = Integer.parseInt(settings.getProperty("SendBufferSize", "8192"));
  40. TCP_RECEIVE_BUFFER_SIZE = Integer.parseInt(settings.getProperty("ReceiveBufferSize", "8192"));
  41. if (TCP_SEND_BUFFER_SIZE < 1024)
  42. throw new IllegalArgumentException("Init: TCP_SEND_BUFFER_SIZE < 1024");
  43. if (TCP_RECEIVE_BUFFER_SIZE < 1024)
  44. throw new IllegalArgumentException("Init: TCP_RECEIVE_BUFFER_SIZE < 2048");
  45. }
  46. /**
  47. * ##################################################
  48. * Crypt
  49. * ##################################################
  50. */
  51. public final String INITIAL_CRYPT;
  52. /**
  53. * ##################################################
  54. * TCP Server start
  55. * ##################################################
  56. */
  57. /** TCP external host address default '*' */
  58. public final String TCP_EXTERNAL_HOST_ADDRESS;
  59. /** TCP external port default 0 */
  60. public final int TCP_EXTERNAL_PORT;
  61. /** TCP external port default 50 */
  62. public final int TCP_CONNECTION_QUEUE;
  63. /** TCP FloodProtection default false */
  64. public final boolean TCP_FLOOD_PROTECTION_ENABLED;
  65. /** TCP Fast connection limit default 15 */
  66. public final int TCP_FAST_CONNECTION_LIMIT;
  67. /** TCP Fast connection time default 350 */
  68. public final int TCP_FAST_CONNECTION_TIME;
  69. /** TCP Normal connection time default 700 */
  70. public final int TCP_NORMAL_CONNECTION_TIME;
  71. /** TCP Max connection per IP 50 */
  72. public final int TCP_MAX_CONNECTION_PER_IP;
  73. /** TCP IP ban default false*/
  74. public final boolean TCP_IP_BANN_ENABLED;
  75. /** TCP IP ban list default empty*/
  76. public final String[] TCP_IP_BANN_LIST;
  77. /**
  78. * ##################################################
  79. * TCP Client start
  80. * ##################################################
  81. */
  82. /** TCP send buffer size default 8192 */
  83. public final int TCP_SEND_BUFFER_SIZE;
  84. /** TCP receive buffer size default 8192 */
  85. public final int TCP_RECEIVE_BUFFER_SIZE;
  86. }