summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 57122ef)
raw | patch | inline | side by side (parent: 57122ef)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 30 Nov 2007 12:45:32 +0000 (12:45 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 30 Nov 2007 12:45:32 +0000 (12:45 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7955 594d385d-05f5-0310-b6e9-bd551577e9d8
contrib/socket_server/client.php | patch | blob | history | |
contrib/socket_server/server.php | patch | blob | history | |
include/class_socketClient.inc | patch | blob | history |
index b1f9e2ae8a1b2830addfdd4e814db0e8118af417..c41f1d12b19c418a38a19a1fb630807cb7470802 100755 (executable)
echo "\n\nTry to connect";
$sock = new Socket_Client("localhost","10000",TRUE,1);
-#$sock->SetEncryptionKey("Hallo hier bin ich.");
+$sock->SetEncryptionKey("Hallo hier bin ich.");
if($sock->connected()){
echo "... successful\n";
echo "|--Reading welcome message : \n";
index b094930224ae6ec536bb20a6e6aab382965102ac..66663517aa9930adc259e0d83d510bcda893ad7f 100755 (executable)
$max_clients = 3;
// Rijndal encrypt key
-$enable_encryption = FALSE;
+$enable_encryption = TRUE;
$encrypt_key = "Hallo hier bin ich.";
socket_write($clients[$i]['socket'],encrypt(
"Welcome to GOsa Test Server
============================
-Type some text here:\n",$encrypt_key));
+Type some text here:",$encrypt_key)."\n");
echo("New client connected: " . $clients[$i]['ipaddy'] . " \n");
break;
if(isset($clients[$i]) && in_array($clients[$i]['socket'],$read)) {
/* Read socket data */
- $data = socket_read($clients[$i]['socket'],1024000, PHP_NORMAL_READ);
+ $data = @socket_read($clients[$i]['socket'],1024000, PHP_NORMAL_READ);
/* Client disconnected */
if ($data === FALSE) {
if($enable_encryption){
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
- $data = mcrypt_encrypt (MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_ECB, $iv);
+ $data = base64_encode(mcrypt_encrypt (MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_ECB, $iv));
}
return($data);
}
if($enable_encryption){
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
- $data = mcrypt_decrypt (MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_ECB, $iv);
+ $data = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($data), MCRYPT_MODE_ECB, $iv);
}
return($data);
}
index 45d427c2e183fec9ffe4f31af53647474dac6b7e..74066e4bb3bcdcd48cd7e118539ef3cdcce58c20 100755 (executable)
{
/* Encrypt data */
if($this->encrypt){
- $data = mcrypt_encrypt (MCRYPT_RIJNDAEL_256, $this->crypt_key, $data, MCRYPT_MODE_ECB, $this->iv);
+ $data = base64_encode(mcrypt_encrypt (MCRYPT_RIJNDAEL_256, $this->crypt_key, $data, MCRYPT_MODE_ECB, $this->iv));
}
return($data);
}
{
/* decrypt data */
if($this->encrypt){
- $data = mcrypt_decrypt (MCRYPT_RIJNDAEL_256, $this->crypt_key, $data, MCRYPT_MODE_ECB, $this->iv);
+ $data = mcrypt_decrypt (MCRYPT_RIJNDAEL_256, $this->crypt_key, base64_decode($data), MCRYPT_MODE_ECB, $this->iv);
}
return($data);
}
/* Check if there is something to read for us */
$read = array("0"=>$this->handle);
$num = @stream_select($read,$write=NULL,$accept=NULL,$this->timeout);
-
+ $str = "";
+
/* Read data if necessary */
while($num && $this->b_data_send){
$str.= fread($this->handle, 1024000);