Compare commits

...

2 Commits

10 changed files with 45 additions and 120 deletions

View File

@ -2,6 +2,7 @@
<creole> <creole>
<files> <files>
<file filelist='ninegate' name='/etc/eole/eole-db.d/ninegate-db.yml' rm='True' mkdir='True'/> <file filelist='ninegate' name='/etc/eole/eole-db.d/ninegate-db.yml' rm='True' mkdir='True'/>
<file filelist='ninegate_nginx' name='/etc/nginx/web.d/ninegate.conf' source='ninegate-nginx.conf' rm='True' mkdir='True' />
</files> </files>
<containers> <containers>
@ -9,6 +10,7 @@
<package>ninegate-apps</package> <package>ninegate-apps</package>
<file filelist='ninegate' name='/etc/apache2/sites-available/ninegate' source='ninegate-apache.conf' rm="True"/> <file filelist='ninegate' name='/etc/apache2/sites-available/ninegate' source='ninegate-apache.conf' rm="True"/>
<file filelist='ninegate' name='/lib/systemd/system/wssninegate.service' source='ninegate.service'/>
<file filelist="ninegate" name="/var/www/html/ninegate/app/config/parameters.yml" source="ninegate-parameters.yml" rm="True"/> <file filelist="ninegate" name="/var/www/html/ninegate/app/config/parameters.yml" source="ninegate-parameters.yml" rm="True"/>
<file filelist="ninegate" name="/var/www/html/ninegate/app/config/template.yml" source="ninegate-template.yml" rm="True"/> <file filelist="ninegate" name="/var/www/html/ninegate/app/config/template.yml" source="ninegate-template.yml" rm="True"/>
<file filelist="ninegate" name="/var/www/html/ninegate/scripts/ninegate-postservice-00.sh" source="ninegate-postservice-00.sh" rm="True" mode="700" /> <file filelist="ninegate" name="/var/www/html/ninegate/scripts/ninegate-postservice-00.sh" source="ninegate-postservice-00.sh" rm="True" mode="700" />
@ -18,11 +20,6 @@
<file filelist='ninegate-migration' name='/var/www/html/envole-migration/config/config-db-ninegate.php' source='ninegate-migration.php' mkdir='True'/> <file filelist='ninegate-migration' name='/var/www/html/envole-migration/config/config-db-ninegate.php' source='ninegate-migration.php' mkdir='True'/>
<service method='apache' servicelist='ninegate'>ninegate</service> <service method='apache' servicelist='ninegate'>ninegate</service>
<service_access service='ninegate_websocket'>
<port port_type="SymLinkOption">ninegate_websocket_portexterne</port>
</service_access>
</container> </container>
</containers> </containers>
@ -372,19 +369,6 @@
<variable type='string' name='ninegate_widwordpress_url' description='URL complète de votre Wordpress' mandatory='True' /> <variable type='string' name='ninegate_widwordpress_url' description='URL complète de votre Wordpress' mandatory='True' />
<variable type='string' name='ninegate_widwordpress_syncenvole' description='URL Posh-Profil pour synchronisation Wordpress' mandatory='True' /> <variable type='string' name='ninegate_widwordpress_syncenvole' description='URL Posh-Profil pour synchronisation Wordpress' mandatory='True' />
<!-- WEBSOCKET -->
<variable type='string' name='ninegate_websocket_url' description='Host du serveur Websocket' mandatory='True' />
<variable type='string' name='ninegate_websocket_portexterne' description='Port de commuinication externe du serveur Websocket' mandatory='True' >
<value>5555</value>
</variable>
<variable type='string' name='ninegate_websocket_portinterne' description='Port de commuinication interne du serveur Websocket' mandatory='True'>
<value>5556</value>
</variable>
<!-- EMAIL --> <!-- EMAIL -->
<variable type='string' name='ninegate_noreply' description='Adresse mail utilisé pour le noreply' mandatory='True' /> <variable type='string' name='ninegate_noreply' description='Adresse mail utilisé pour le noreply' mandatory='True' />
<variable type="oui/non" name='ninegate_activer_localmail' description="Utiliser le serveur d'envoi de mail local" mandatory='True'> <variable type="oui/non" name='ninegate_activer_localmail' description="Utiliser le serveur d'envoi de mail local" mandatory='True'>
@ -441,7 +425,7 @@
<separator name="ninegate_activate_widroundcube">Paramètres associés à Roundcube</separator> <separator name="ninegate_activate_widroundcube">Paramètres associés à Roundcube</separator>
<separator name="ninegate_activate_widsacoche">Paramètres associés à Sacoche</separator> <separator name="ninegate_activate_widsacoche">Paramètres associés à Sacoche</separator>
<separator name="ninegate_activate_widwordpress">Paramètres associés à Wordpress</separator> <separator name="ninegate_activate_widwordpress">Paramètres associés à Wordpress</separator>
<separator name="ninegate_websocket_url">Paramètres associés au Serveur WEBSOCKET</separator> <separator name="ninegate_activate_websocket">Paramètres associés au Serveur WEBSOCKET</separator>
<separator name="ninegate_noreply">Paramètres associés aux Mails</separator> <separator name="ninegate_noreply">Paramètres associés aux Mails</separator>
<separator name="ninegate_db_mode">Paramètres EoleDB associés à Ninegate</separator> <separator name="ninegate_db_mode">Paramètres EoleDB associés à Ninegate</separator>
</separators> </separators>
@ -453,6 +437,11 @@
<target type='variable'>activer_ninegate</target> <target type='variable'>activer_ninegate</target>
</condition> </condition>
<condition name='hidden_if_in' source='activer_revprox'>
<param>non</param>
<target type='filelist'>nineboard_nginx</target>
</condition>
<condition name='hidden_if_in' source='activer_ninegate'> <condition name='hidden_if_in' source='activer_ninegate'>
<param>non</param> <param>non</param>
@ -529,6 +518,7 @@
<target type='variable'>ninegate_dbpass</target> <target type='variable'>ninegate_dbpass</target>
<target type='filelist'>ninegate</target> <target type='filelist'>ninegate</target>
<target type='filelist'>ninegate_nginx</target>
<target type='filelist'>ninegate-migration</target> <target type='filelist'>ninegate-migration</target>
<target type='servicelist'>ninegate</target> <target type='servicelist'>ninegate</target>
@ -796,25 +786,6 @@
<target type='variable'>ninegate_widsacoche_syncenvole</target> <target type='variable'>ninegate_widsacoche_syncenvole</target>
</condition> </condition>
<!-- AFFICHAGE EN FONCTION DU MODULE WEBSOCKET -->
<condition name='hidden_if_in' source='ninegate_activate_websocket'>
<param>non</param>
<target type='variable'>ninegate_websocket_url</target>
<target type='variable'>ninegate_websocket_portinterne</target>
<target type='variable'>ninegate_websocket_portexterne</target>
<target type='servicelist'>ninegate_websocket</target>
</condition>
<fill name='calc_multi_condition' target='ninegate_websocket_url'>
<param>oui</param>
<param type='eole' name='condition_1' hidden='False'>activer_apache</param>
<param type='eole' name='match' hidden='False'>web_url</param>
<param name='default_mismatch'>None</param>
</fill>
<!-- AFFICHAGE EN FONCTION DU WIDGET ADMINER --> <!-- AFFICHAGE EN FONCTION DU WIDGET ADMINER -->
<fill name='calc_multi_condition' target='ninegate_activate_widadminer'> <fill name='calc_multi_condition' target='ninegate_activate_widadminer'>
<param>oui</param> <param>oui</param>

View File

@ -127,16 +127,16 @@ gos_web_socket:
firewall: main firewall: main
shared_config: true shared_config: true
server: server:
port: %websocket_port% #The port the socket server will listen on port: 443 #The port the socket server will listen on
host: %websocket_host% #The host ip to bind to host: %weburl%/wssninegate #The host ip to bind to
router: router:
resources: resources:
- "@CadolesWebsocketBundle/Resources/config/topic.yml" - "@CadolesWebsocketBundle/Resources/config/topic.yml"
pushers: pushers:
wamp: wamp:
host: %websocket_host% host: 0.0.0.0
port: %websocket_portinterne% port: 5556
# ckeditor configuration # ckeditor configuration
ivory_ck_editor: ivory_ck_editor:

View File

@ -1,11 +1,9 @@
#!/bin/bash #!/bin/bash
websocket_url=$(CreoleGet adresse_ip_eth0 non)
websocket_portinterne=$(CreoleGet ninegate_websocket_portinterne non)
# Server Websocket # Server Websocket
if [[ "$1" != "restartifdown" ]]; then if [[ "$1" != "restartifdown" ]]; then
echo WEBSOCKET = STOP echo WEBSOCKET = STOP
pid="$(pgrep -a -f gos:websocket | grep $websocket_portinterne)" pid="$(pgrep -a -f gos:websocket | grep 5556)"
if [ -n "${pid}" ]; then if [ -n "${pid}" ]; then
IFS=' ' read -r -a array <<< "$pid" IFS=' ' read -r -a array <<< "$pid"
kill -9 ${array[0]}; kill -9 ${array[0]};
@ -13,7 +11,7 @@ if [[ "$1" != "restartifdown" ]]; then
fi fi
# Port LISTEN ? # Port LISTEN ?
pid="$(pgrep -a -f gos:websocket | grep $websocket_portinterne)" pid="$(pgrep -a -f gos:websocket | grep 5556)"
restart="yes" restart="yes"
if [ "$1" == "restartifdown" ] && [ -n "${pid}" ] ; then if [ "$1" == "restartifdown" ] && [ -n "${pid}" ] ; then
restart="no" restart="no"
@ -22,5 +20,5 @@ fi
if [ "$restart" == "yes" ] && [ "$1" != "stop" ] ; then if [ "$restart" == "yes" ] && [ "$1" != "stop" ] ; then
echo WEBSOCKET = START echo WEBSOCKET = START
cd /var/www/html/ninegate cd /var/www/html/ninegate
bin/console gos:websocket:server --port $websocket_portinterne -a $websocket_url --no-debug -n -q --env=prod & disown systemctl restart wssninegate
fi fi

View File

@ -318,49 +318,6 @@
loadmsgCounter() loadmsgCounter()
}, {{(app.session.get("timerefreshnotif")*1000)}}); }, {{(app.session.get("timerefreshnotif")*1000)}});
{% endif %} {% endif %}
// Init socket de counter
/* Désactiver car il semble préférable de faire un appel ajax régulier plutot qu'ouvrir un channel websocket
{% if websocket_activate %}
var _WS_URI = "wss://{{ gos_web_socket_server_host }}:{{ gos_web_socket_server_port }}";
var webSocket = WS.connect(_WS_URI);
webSocket.on("socket/connect", function (session) {
// The callback function in "subscribe" is called everytime an event is published in that channel.
session.subscribe("websocket/counter", function (uri, payload) {
if(payload.log) {
console.log("Received message", payload.log);
}
if(payload.alert) {
alert(payload.alert);
}
{% if app.user %}
if(payload.from!="{{app.user.id}}") {
menu=$("a[data-group='"+payload.group+"']");
if(menu.length) {
if(payload.add) {
console.log("Ajout counter pour group "+payload.group+" by "+payload.from);
if(menu.children(".badge").length) {
menu.children(".badge").html(+(menu.children(".badge").html())+1);
}
else menu.append("<span id='badge-"+payload.group+"' class='badge'>1</span");
}
}
}
{% endif %}
});
$(document).on('click', '#refreshcounter', function(){
{% if app.user %}
event=$(this).data("event");
event.userid={{app.user.id}}
session.publish("websocket/counter", event);
{% endif %}
});
});
{% endif %}
*/
}); });
$(window).resize(function() { $(window).resize(function() {

View File

@ -51,13 +51,17 @@ class ChatController extends Controller
if(!$group) die(); if(!$group) die();
// Génération d'une clé temporaire d'accès au chat // Génération d'une clé temporaire d'accès au chat
$key = Uuid::uuid4();
$usergroup=$em->getRepository("CadolesCoreBundle:UserGroup")->findOneBy(["group"=>$group,"user"=>$user]); $usergroup=$em->getRepository("CadolesCoreBundle:UserGroup")->findOneBy(["group"=>$group,"user"=>$user]);
$key=null;
if($usergroup) { if($usergroup) {
$key=$usergroup->getKeyvalue();
if(is_null($key)) {
$key = Uuid::uuid4();
$usergroup->setKeyvalue($key); $usergroup->setKeyvalue($key);
$em->persist($usergroup); $em->persist($usergroup);
$em->flush(); $em->flush();
} }
}
// Récupération des message parent du groupe // Récupération des message parent du groupe

View File

@ -362,7 +362,8 @@
function websocket() function websocket()
{ {
var _WS_URI = "wss://{{ gos_web_socket_server_host }}:{{ gos_web_socket_server_port }}"; var _WS_URI = "wss://{{ gos_web_socket_server_host }}";
console.log(_WS_URI);
webSocket = WS.connect(_WS_URI,{retryDelay: delayRetry}); webSocket = WS.connect(_WS_URI,{retryDelay: delayRetry});
webSocket.on("socket/connect", function (sess) { webSocket.on("socket/connect", function (sess) {

View File

@ -9,23 +9,6 @@ Alias /ninegate /var/www/html/ninegate/web
</Directory> </Directory>
%if %%getVar("ninegate_activate_websocket", 'non') == "oui" %if %%getVar("ninegate_activate_websocket", 'non') == "oui"
Listen %%adresse_ip_eth0:%%ninegate_websocket_portexterne ProxyPass /wssninegate ws://0.0.0.0:5556 retry=0 keepalive=On
<VirtualHost %%adresse_ip_eth0:%%ninegate_websocket_portexterne> ProxyPassReverse /wssninegate ws://0.0.0.0:5556 retry=0
ErrorLog /var/log/apache2/ssl_error.log
CustomLog /var/log/apache2/ssl_access.log common
SSLEngine on
%if %%cert_type == "letsencrypt"
SSLCertificateFile /etc/ssl/letsencrypt/conf/live/%%ninegate_websocket_url/cert.pem
SSLCertificateKeyFile /etc/ssl/letsencrypt/conf/live/%%ninegate_websocket_url/privkey.pem
%else
SSLCertificateFile %%server_cert
SSLCertificateKeyFile %%server_key
%end if
SSLProtocol all -SSLv3 -SSLv2
ServerName %%ninegate_websocket_url
RewriteEngine On
ProxyPass / ws://%%adresse_ip_eth0:%%ninegate_websocket_portinterne retry=0 keepalive=On
ProxyPassReverse / ws://%%adresse_ip_eth0:%%ninegate_websocket_portinterne retry=0
</VirtualHost>
%end if %end if

6
tmpl/ninegate-nginx.conf Normal file
View File

@ -0,0 +1,6 @@
location /wssninegate {
proxy_pass https://%%container_ip_web;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}

View File

@ -52,14 +52,8 @@ parameters:
%end if %end if
%if %%getVar("ninegate_activate_websocket", 'non') == "oui" %if %%getVar("ninegate_activate_websocket", 'non') == "oui"
websocket_activate: true websocket_activate: true
websocket_host: %%ninegate_websocket_url
websocket_port: %%ninegate_websocket_portexterne
websocket_portinterne: %%ninegate_websocket_portinterne
%else %else
websocket_activate: false websocket_activate: false
websocket_host: %%web_url
websocket_port: 80
websocket_portinterne: 80
%end if %end if
%if %%getVar("ninegate_activate_portal", 'non') == "oui" %if %%getVar("ninegate_activate_portal", 'non') == "oui"
portal_activate: true portal_activate: true

11
tmpl/ninegate.service Normal file
View File

@ -0,0 +1,11 @@
[Unit]
Description=Ninegate websocket server
After=local-fs.target network.target
[Service]
Type=simple
ExecStart=/var/www/html/ninegate/bin/console gos:websocket:server --port 5556 -a 0.0.0.0 --no-debug -n -q --env=prod
Restart=on-watchdog
[Install]
WantedBy=multi-user.target