protected override bool CheckAuthentication(Context context) { if (context.ReceivedByteCount > 8) { var handshake = new ClientHandshake(new ArraySegment<byte>(context.Buffer, context.ReceivedByteCount - 8, 8), context.Header); // See if our header had the required information if (handshake.IsValid()) { // Optionally check Origin and Location if they're set. if (Origin != string.Empty) { if (handshake.Origin != "http://" + Origin) { return false; } } if (Destination != string.Empty) { if (handshake.Host != Destination + ":" + context.Server.Port) { return false; } } // Generate response handshake for the client var serverShake = GenerateResponseHandshake(handshake, context.Server); // Send the response handshake SendServerHandshake(serverShake, context); return true; } } return false; }
protected override bool CheckAuthentication(Context context) { if (context.ReceivedByteCount > 8) { var handshake = new ClientHandshake(new ArraySegment <byte>(context.Buffer, context.ReceivedByteCount - 8, 8), context.Header); // See if our header had the required information if (handshake.IsValid()) { // Optionally check Origin and Location if they're set. if (Origin != string.Empty) { if (handshake.Origin != "http://" + Origin) { return(false); } } if (Destination != string.Empty) { if (handshake.Host != Destination + ":" + context.Server.Port) { return(false); } } // Generate response handshake for the client var serverShake = GenerateResponseHandshake(handshake, context.Server); // Send the response handshake SendServerHandshake(serverShake, context); return(true); } } return(false); }
protected override bool CheckAuthentication(Context context) { if (context.ReceivedByteCount > 8) { var handshake = new ClientHandshake(new ArraySegment<byte>(context.Buffer, context.ReceivedByteCount - 8, 8), context.Header); // See if our header had the required information if (handshake.IsValid()) { // Optionally check Origin and Location if they're set. if (!String.IsNullOrEmpty(Origin)) { var expectedOrigin = Origin; if (!Origin.Contains("://")) { expectedOrigin = "http://" + Origin; } if (!handshake.Origin.Equals(expectedOrigin, StringComparison.InvariantCultureIgnoreCase)) { return false; } } if (!String.IsNullOrEmpty(Destination)) { if (handshake.Host != Destination + ":" + context.Server.Port) { return false; } } // Generate response handshake for the client var serverShake = GenerateResponseHandshake(handshake, context.Server); // Send the response handshake SendServerHandshake(serverShake, context); return true; } } return false; }
protected override bool CheckAuthentication(Context context) { if (context.ReceivedByteCount > 8) { var handshake = new ClientHandshake(new ArraySegment <byte>(context.Buffer, context.ReceivedByteCount - 8, 8), context.Header); // See if our header had the required information if (handshake.IsValid()) { // Optionally check Origin and Location if they're set. if (!String.IsNullOrEmpty(Origin)) { var expectedOrigin = Origin; if (!Origin.Contains("://")) { expectedOrigin = "http://" + Origin; } if (!handshake.Origin.Equals(expectedOrigin, StringComparison.InvariantCultureIgnoreCase)) { return(false); } } if (!String.IsNullOrEmpty(Destination)) { if (handshake.Host != Destination + ":" + context.Server.Port) { return(false); } } // Generate response handshake for the client var serverShake = GenerateResponseHandshake(handshake, context.Server); // Send the response handshake SendServerHandshake(serverShake, context); return(true); } } return(false); }