Changeset 184 for binary-improvements/7dtd-server-fixes/src/NetConnections/Servers/Telnet/TelnetConnection.cs
- Timestamp:
- Sep 9, 2014, 9:52:41 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/src/NetConnections/Servers/Telnet/TelnetConnection.cs
r183 r184 11 11 public class TelnetConnection : IConnection 12 12 { 13 BlockingQueue<string> toClientQueue = new BlockingQueue<string> (); 14 private Thread receiveThread = null; 15 private Thread sendThread = null; 13 private readonly BlockingQueue<string> toClientQueue = new BlockingQueue<string> (); 14 private readonly Telnet owner; 15 private readonly Thread receiveThread = null; 16 private readonly Thread sendThread = null; 17 private int authTries = 0; 16 18 private bool authenticated = false; 17 private bool authEnabled;19 private readonly bool authEnabled; 18 20 private TcpClient client; 19 private NetworkStream stream; 20 private EndPoint endpoint; 21 private readonly NetworkStream stream; 22 private readonly EndPoint endpoint; 23 private readonly int endpointAddressHash; 21 24 22 public TelnetConnection (T cpClient client, bool authEnabled)25 public TelnetConnection (Telnet owner, TcpClient client, bool authEnabled) 23 26 { 27 this.owner = owner; 24 28 this.authEnabled = authEnabled; 25 29 this.client = client; … … 33 37 sendThread = ThreadMaster.Create ("TelnetClientSend", new ThreadStart (SendThread)); 34 38 sendThread.Start (); 39 40 if (endpoint is IPEndPoint) { 41 endpointAddressHash = ((IPEndPoint)endpoint).Address.GetHashCode(); 42 Log.Out ("Hash: " + endpointAddressHash); 43 } else { 44 Log.Out ("EndPoint is not an IPEndPoint but: " + endpoint.GetType().ToString()); 45 } 35 46 36 47 if (authEnabled) { … … 80 91 LoginMessage (); 81 92 } else { 82 WriteLine ("Password incorrect, please enter password:"); 93 authTries++; 94 // TODO: check if IP has more login attempts by now 95 if (authTries < 3) { 96 WriteLine ("Password incorrect, please enter password:"); 97 } else { 98 WriteLine ("Too many failed login attempts!"); 99 Log.Out ("Telnet connection closed for too many login attempts: " + endpoint); 100 //TODO: owner.FailedLogins(); 101 Close (); 102 break; 103 } 83 104 } 84 105 } else {
Note:
See TracChangeset
for help on using the changeset viewer.