mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-08-15 11:43:46 +02:00
Server: Prevented several ConnectionState members from being changed after instantiation
This commit is contained in:
parent
107d755269
commit
d753135620
2 changed files with 48 additions and 15 deletions
|
@ -18,28 +18,30 @@ namespace SMBLibrary.Server
|
||||||
|
|
||||||
internal class ConnectionState
|
internal class ConnectionState
|
||||||
{
|
{
|
||||||
public Socket ClientSocket;
|
private Socket m_clientSocket;
|
||||||
public IPEndPoint ClientEndPoint;
|
private IPEndPoint m_clientEndPoint;
|
||||||
public NBTConnectionReceiveBuffer ReceiveBuffer;
|
private NBTConnectionReceiveBuffer m_receiveBuffer;
|
||||||
public BlockingQueue<SessionPacket> SendQueue;
|
private BlockingQueue<SessionPacket> m_sendQueue;
|
||||||
protected LogDelegate LogToServerHandler;
|
private LogDelegate LogToServerHandler;
|
||||||
public SMBDialect Dialect;
|
public SMBDialect Dialect;
|
||||||
public GSSContext AuthenticationContext;
|
public GSSContext AuthenticationContext;
|
||||||
|
|
||||||
public ConnectionState(LogDelegate logToServerHandler)
|
public ConnectionState(Socket clientSocket, IPEndPoint clientEndPoint, LogDelegate logToServerHandler)
|
||||||
{
|
{
|
||||||
ReceiveBuffer = new NBTConnectionReceiveBuffer();
|
m_clientSocket = clientSocket;
|
||||||
SendQueue = new BlockingQueue<SessionPacket>();
|
m_clientEndPoint = clientEndPoint;
|
||||||
|
m_receiveBuffer = new NBTConnectionReceiveBuffer();
|
||||||
|
m_sendQueue = new BlockingQueue<SessionPacket>();
|
||||||
LogToServerHandler = logToServerHandler;
|
LogToServerHandler = logToServerHandler;
|
||||||
Dialect = SMBDialect.NotSet;
|
Dialect = SMBDialect.NotSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConnectionState(ConnectionState state)
|
public ConnectionState(ConnectionState state)
|
||||||
{
|
{
|
||||||
ClientSocket = state.ClientSocket;
|
m_clientSocket = state.ClientSocket;
|
||||||
ClientEndPoint = state.ClientEndPoint;
|
m_clientEndPoint = state.ClientEndPoint;
|
||||||
ReceiveBuffer = state.ReceiveBuffer;
|
m_receiveBuffer = state.ReceiveBuffer;
|
||||||
SendQueue = state.SendQueue;
|
m_sendQueue = state.SendQueue;
|
||||||
LogToServerHandler = state.LogToServerHandler;
|
LogToServerHandler = state.LogToServerHandler;
|
||||||
Dialect = state.Dialect;
|
Dialect = state.Dialect;
|
||||||
}
|
}
|
||||||
|
@ -70,6 +72,38 @@ namespace SMBLibrary.Server
|
||||||
LogToServer(severity, String.Format(message, args));
|
LogToServer(severity, String.Format(message, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Socket ClientSocket
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_clientSocket;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IPEndPoint ClientEndPoint
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_clientEndPoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public NBTConnectionReceiveBuffer ReceiveBuffer
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_receiveBuffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockingQueue<SessionPacket> SendQueue
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_sendQueue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string ConnectionIdentifier
|
public string ConnectionIdentifier
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
|
@ -115,11 +115,10 @@ namespace SMBLibrary.Server
|
||||||
|
|
||||||
// Windows will set the TCP keepalive timeout to 120 seconds for an SMB connection
|
// Windows will set the TCP keepalive timeout to 120 seconds for an SMB connection
|
||||||
SocketUtils.SetKeepAlive(clientSocket, TimeSpan.FromMinutes(2));
|
SocketUtils.SetKeepAlive(clientSocket, TimeSpan.FromMinutes(2));
|
||||||
ConnectionState state = new ConnectionState(Log);
|
|
||||||
// Disable the Nagle Algorithm for this tcp socket:
|
// Disable the Nagle Algorithm for this tcp socket:
|
||||||
clientSocket.NoDelay = true;
|
clientSocket.NoDelay = true;
|
||||||
state.ClientSocket = clientSocket;
|
IPEndPoint clientEndPoint = (IPEndPoint)clientSocket.RemoteEndPoint;
|
||||||
state.ClientEndPoint = clientSocket.RemoteEndPoint as IPEndPoint;
|
ConnectionState state = new ConnectionState(clientSocket, clientEndPoint, Log);
|
||||||
state.LogToServer(Severity.Verbose, "New connection request");
|
state.LogToServer(Severity.Verbose, "New connection request");
|
||||||
Thread senderThread = new Thread(delegate()
|
Thread senderThread = new Thread(delegate()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue