Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

ServerInfo.java 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /*
  2. * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. package com.dmdirc.parser.irc;
  23. import java.net.URI;
  24. /**
  25. * Contains Server information.
  26. *
  27. * @author Shane Mc Cormack
  28. * @author Chris Smith
  29. * @see IRCParser
  30. */
  31. public class ServerInfo {
  32. /**
  33. * A version number for this class. It should be changed whenever the class
  34. * structure is changed (or anything else that would prevent serialized
  35. * objects being unserialized with the new class).
  36. */
  37. private static final long serialVersionUID = 1;
  38. /** Server to connect to (Default: "irc.quakenet.org"). */
  39. private String host = "irc.quakenet.org";
  40. /** Port server listens on for client connections (Default: 6667). */
  41. private int port = 6667;
  42. /** Optional password needed to connect to server (Default: ""). */
  43. private String password = "";
  44. /** Is this an ssl-enabled server (Default: false). */
  45. private boolean isSSL = false;
  46. /** Are we using a socks proxy (Default: false). */
  47. private boolean useSocksProxy = false;
  48. /** Proxy server to connect to (Default: "127.0.0.1"). */
  49. private String proxyHost = "127.0.0.1";
  50. /** Port server listens on for client connections (Default: 8080). */
  51. private int proxyPort = 1080;
  52. /** Proxy username if required. */
  53. private String proxyUser = "";
  54. /** Proxy password if required. */
  55. private String proxyPass = "";
  56. /** Constructor using Default values. */
  57. public ServerInfo () { }
  58. /**
  59. * Constructor using specifed host, port and password, SSL/Proxy must be specifed separately.
  60. *
  61. * @param serverHost Host to use
  62. * @param serverPort Port to use
  63. * @param serverPass Password to use
  64. */
  65. public ServerInfo (final String serverHost, final int serverPort, final String serverPass) {
  66. host = serverHost;
  67. port = serverPort;
  68. password = serverPass;
  69. }
  70. /**
  71. * Creates a new ServerInfo which will represent the server described by
  72. * the specified URI.
  73. *
  74. * @param uri The URI of the server
  75. * @since 0.6.3
  76. */
  77. public ServerInfo(final URI uri) {
  78. host = uri.getHost();
  79. port = uri.getPort();
  80. if ("ircs".equals(uri.getScheme())) {
  81. setSSL(true);
  82. }
  83. password = uri.getUserInfo() == null ? "" : uri.getUserInfo();
  84. }
  85. /**
  86. * Set the hostname.
  87. *
  88. * @param newValue Value to set to.
  89. */
  90. public void setHost(final String newValue) { host = newValue; }
  91. /**
  92. * Get the hostname.
  93. *
  94. * @return Current hostname
  95. */
  96. public String getHost() { return host; }
  97. /**
  98. * Set the port.
  99. *
  100. * @param newValue Value to set to.
  101. */
  102. public void setPort(final int newValue) { port = newValue; }
  103. /**
  104. * Get the port.
  105. *
  106. * @return Current port
  107. */
  108. public int getPort() { return port; }
  109. /**
  110. * Set the password.
  111. *
  112. * @param newValue Value to set to.
  113. */
  114. public void setPassword(final String newValue) { password = newValue; }
  115. /**
  116. * Get the password.
  117. *
  118. * @return Current Password
  119. */
  120. public String getPassword() { return password; }
  121. /**
  122. * Set if the server uses ssl.
  123. *
  124. * @param newValue true if server uses ssl, else false
  125. */
  126. public void setSSL(final boolean newValue) { isSSL = newValue; }
  127. /**
  128. * Get if the server uses ssl.
  129. *
  130. * @return true if server uses ssl, else false
  131. */
  132. public boolean getSSL() { return isSSL; }
  133. /**
  134. * Set if we are connecting via a socks proxy.
  135. *
  136. * @param newValue true if we are using socks, else false
  137. */
  138. public void setUseSocks(final boolean newValue) { useSocksProxy = newValue; }
  139. /**
  140. * Get if we are connecting via a socks proxy.
  141. *
  142. * @return true if we are using socks, else false
  143. */
  144. public boolean getUseSocks() { return useSocksProxy; }
  145. /**
  146. * Set the Proxy hostname.
  147. *
  148. * @param newValue Value to set to.
  149. */
  150. public void setProxyHost(final String newValue) { proxyHost = newValue; }
  151. /**
  152. * Get the Proxy hostname.
  153. *
  154. * @return Current Proxy hostname
  155. */
  156. public String getProxyHost() { return proxyHost; }
  157. /**
  158. * Set the Proxy port.
  159. *
  160. * @param newValue Value to set to.
  161. */
  162. public void setProxyPort(final int newValue) { proxyPort = newValue; }
  163. /**
  164. * Get the Proxy port.
  165. *
  166. * @return Current Proxy port
  167. */
  168. public int getProxyPort() { return proxyPort; }
  169. /**
  170. * Set the Proxy username.
  171. *
  172. * @param newValue Value to set to.
  173. */
  174. public void setProxyUser(final String newValue) { proxyUser = newValue; }
  175. /**
  176. * Get the Proxy username.
  177. *
  178. * @return Current Proxy username
  179. */
  180. public String getProxyUser() { return proxyUser; }
  181. /**
  182. * Set the Proxy password.
  183. *
  184. * @param newValue Value to set to.
  185. */
  186. public void setProxyPass(final String newValue) { proxyPass = newValue; }
  187. /**
  188. * Get the Proxy password.
  189. *
  190. * @return Current Proxy password
  191. */
  192. public String getProxyPass() { return proxyPass; }
  193. }