mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-04-30 02:37:49 +02:00
ConnectionState: Renamed ServerDialect to Dialect
This commit is contained in:
parent
054d537c26
commit
3325d1842f
5 changed files with 14 additions and 14 deletions
|
@ -21,14 +21,14 @@ namespace SMBLibrary.Server
|
|||
public IPEndPoint ClientEndPoint;
|
||||
public NBTConnectionReceiveBuffer ReceiveBuffer;
|
||||
protected LogDelegate LogToServerHandler;
|
||||
public SMBDialect ServerDialect;
|
||||
public SMBDialect Dialect;
|
||||
public object AuthenticationContext;
|
||||
|
||||
public ConnectionState(LogDelegate logToServerHandler)
|
||||
{
|
||||
ReceiveBuffer = new NBTConnectionReceiveBuffer();
|
||||
LogToServerHandler = logToServerHandler;
|
||||
ServerDialect = SMBDialect.NotSet;
|
||||
Dialect = SMBDialect.NotSet;
|
||||
}
|
||||
|
||||
public ConnectionState(ConnectionState state)
|
||||
|
@ -37,7 +37,7 @@ namespace SMBLibrary.Server
|
|||
ClientEndPoint = state.ClientEndPoint;
|
||||
ReceiveBuffer = state.ReceiveBuffer;
|
||||
LogToServerHandler = state.LogToServerHandler;
|
||||
ServerDialect = state.ServerDialect;
|
||||
Dialect = state.Dialect;
|
||||
}
|
||||
|
||||
public void LogToServer(Severity severity, string message)
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace SMBLibrary.Server.SMB2
|
|||
}
|
||||
else if (smb2Dialects.Contains(SMB2002Dialect))
|
||||
{
|
||||
state.ServerDialect = SMBDialect.SMB202;
|
||||
state.Dialect = SMBDialect.SMB202;
|
||||
response.DialectRevision = SMB2Dialect.SMB202;
|
||||
}
|
||||
else
|
||||
|
@ -55,12 +55,12 @@ namespace SMBLibrary.Server.SMB2
|
|||
NegotiateResponse response = new NegotiateResponse();
|
||||
if (request.Dialects.Contains(SMB2Dialect.SMB210))
|
||||
{
|
||||
state.ServerDialect = SMBDialect.SMB210;
|
||||
state.Dialect = SMBDialect.SMB210;
|
||||
response.DialectRevision = SMB2Dialect.SMB210;
|
||||
}
|
||||
else if (request.Dialects.Contains(SMB2Dialect.SMB202))
|
||||
{
|
||||
state.ServerDialect = SMBDialect.SMB202;
|
||||
state.Dialect = SMBDialect.SMB202;
|
||||
response.DialectRevision = SMB2Dialect.SMB202;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace SMBLibrary.Server
|
|||
/// </summary>
|
||||
private List<SMB1Command> ProcessSMB1Command(SMB1Header header, SMB1Command command, ref ConnectionState state)
|
||||
{
|
||||
if (state.ServerDialect == SMBDialect.NotSet)
|
||||
if (state.Dialect == SMBDialect.NotSet)
|
||||
{
|
||||
if (command is NegotiateRequest)
|
||||
{
|
||||
|
@ -75,7 +75,7 @@ namespace SMBLibrary.Server
|
|||
if (request.Dialects.Contains(SMBServer.NTLanManagerDialect))
|
||||
{
|
||||
state = new SMB1ConnectionState(state);
|
||||
state.ServerDialect = SMBDialect.NTLM012;
|
||||
state.Dialect = SMBDialect.NTLM012;
|
||||
if (EnableExtendedSecurity && header.ExtendedSecurityFlag)
|
||||
{
|
||||
return NegotiateHelper.GetNegotiateResponseExtended(request, m_serverGuid);
|
||||
|
|
|
@ -69,13 +69,13 @@ namespace SMBLibrary.Server
|
|||
/// </summary>
|
||||
private SMB2Command ProcessSMB2Command(SMB2Command command, ref ConnectionState state)
|
||||
{
|
||||
if (state.ServerDialect == SMBDialect.NotSet)
|
||||
if (state.Dialect == SMBDialect.NotSet)
|
||||
{
|
||||
if (command is NegotiateRequest)
|
||||
{
|
||||
NegotiateRequest request = (NegotiateRequest)command;
|
||||
SMB2Command response = NegotiateHelper.GetNegotiateResponse(request, m_securityProvider, state, m_serverGuid, m_serverStartTime);
|
||||
if (state.ServerDialect != SMBDialect.NotSet)
|
||||
if (state.Dialect != SMBDialect.NotSet)
|
||||
{
|
||||
state = new SMB2ConnectionState(state, AllocatePersistentFileID);
|
||||
}
|
||||
|
|
|
@ -222,8 +222,8 @@ namespace SMBLibrary.Server
|
|||
{
|
||||
// Note: To be compatible with SMB2 specifications, we must accept SMB_COM_NEGOTIATE.
|
||||
// We will disconnect the connection if m_enableSMB1 == false and the client does not support SMB2.
|
||||
bool acceptSMB1 = (state.ServerDialect == SMBDialect.NotSet || state.ServerDialect == SMBDialect.NTLM012);
|
||||
bool acceptSMB2 = (m_enableSMB2 && (state.ServerDialect == SMBDialect.NotSet || state.ServerDialect == SMBDialect.SMB202 || state.ServerDialect == SMBDialect.SMB210));
|
||||
bool acceptSMB1 = (state.Dialect == SMBDialect.NotSet || state.Dialect == SMBDialect.NTLM012);
|
||||
bool acceptSMB2 = (m_enableSMB2 && (state.Dialect == SMBDialect.NotSet || state.Dialect == SMBDialect.SMB202 || state.Dialect == SMBDialect.SMB210));
|
||||
|
||||
if (SMB1Header.IsValidSMB1Header(packet.Trailer))
|
||||
{
|
||||
|
@ -246,14 +246,14 @@ namespace SMBLibrary.Server
|
|||
return;
|
||||
}
|
||||
state.LogToServer(Severity.Verbose, "SMB1 message received: {0} requests, First request: {1}, Packet length: {2}", message.Commands.Count, message.Commands[0].CommandName.ToString(), packet.Length);
|
||||
if (state.ServerDialect == SMBDialect.NotSet && m_enableSMB2)
|
||||
if (state.Dialect == SMBDialect.NotSet && m_enableSMB2)
|
||||
{
|
||||
// Check if the client supports SMB 2
|
||||
List<string> smb2Dialects = SMB2.NegotiateHelper.FindSMB2Dialects(message);
|
||||
if (smb2Dialects.Count > 0)
|
||||
{
|
||||
SMB2Command response = SMB2.NegotiateHelper.GetNegotiateResponse(smb2Dialects, m_securityProvider, state, m_serverGuid, m_serverStartTime);
|
||||
if (state.ServerDialect != SMBDialect.NotSet)
|
||||
if (state.Dialect != SMBDialect.NotSet)
|
||||
{
|
||||
state = new SMB2ConnectionState(state, AllocatePersistentFileID);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue