0
     ˆÀŽþ\Vq°9 €!ÆA‹ùÍƒn?Ì¿ÂÉ !    # Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/

class Sessions::Event::ChatSessionInit < Sessions::Event::ChatBase

=begin

a customer requests a new chat session

payload

  {
    event: 'chat_session_init',
    data: {
      chat_id: 'the id of chat',
      url: 'the browser url',
    },
  }

return is sent as message back to peer

=end

  def run
    return super if super
    return if !check_chat_exists

    # geo ip lookup
    geo_ip = nil
    if remote_ip
      geo_ip = Service::GeoIp.location(remote_ip)
    end

    # dns lookup
    dns_name = nil
    if remote_ip
      begin
        dns = Resolv::DNS.new
        dns.timeouts = 3
        result = dns.getname remote_ip
        if result
          dns_name = result.to_s
        end
      rescue => e
        Rails.logger.error e
      end
    end

    # create chat session
    chat_session = Chat::Session.create(
      chat_id:     @payload['data']['chat_id'],
      name:        '',
      state:       'waiting',
      preferences: {
        url:          @payload['data']['url'],
        participants: [@client_id],
        remote_ip:    remote_ip,
        geo_ip:       geo_ip,
        dns_name:     dns_name,
      },
    )

    # send broadcast to agents
    Chat.broadcast_agent_state_update([chat_session.chat_id])

    # return new session
    {
      event: 'chat_session_queue',
      data:  {
        state:      'queue',
        position:   Chat.waiting_chat_count([chat_session.chat_id]),
        session_id: chat_session.session_id,
      },
    }
  end

end
     ˆÆÅÌ540ÁÂÉ     ‹      ½•ßoÚ0ÇßûWx~Ø9‰ÖÉÔ¤¡µ€ ›¦©2±!V“Ù¦¡ýëç$ ²	öCE<ùì|swŸóÙ&ï‚q?ü6 OáÃ=š|ùx?ì#Ü ˜·û AT:N³0a„ccÖ7 yž;yÛ‘jáb“&ÐF‰È8Ì0ì_‘bÍ¿B$æ”Ù#LÂýaÆøÉ%¹1Z0îî�ýØtá•¦)e�IÆSÉ6	×�Kõ´�ÛF.2&sÐ*"P¹´A`…,${)‚·ÎÈú+è¢ŒW˜Ê'&FÏ4«ÌÃF®±ODºBVïa‘Ì4,š=9+±Äˆ&ÆÃß‡ýñ«û„¢Xñ¥‡?ô½ÑíØ»Ãþˆ¦œ =®y¨4÷TdÓKÁÙIñ¬ÏÄëi‡�ÕØ¸Ž”X!³ƒ,b5’‰^SËzm	bUWUö·jÐè—bLî¦ƒQ§UIXáâ�Ý·ûªxfP �ŒT/;²*Ìûl¡×·û)Úå­Ä*6ØG¨�Ž*ÿÖð­©Ã†_Ã£˜ó*mÇhììz®¿%ç6Ýn£Ùk¸]ÔìÝ´Û�¢p{Ÿ/EñøÌ•¶ÝSbÔ&gáèºÛQ\%ÄÞ:Açº}1‚”kMW|6/)ê³s�´÷Í=µ”	ãªÎrê
Ø‘h{’«ñ,½ôÇ“ý�—ìžåkC zê~\ÈŽ£M        ˆÈ�þBãYÇÈA$¯¶àüÿÍƒh/;ÌÇÂÉ [    /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
/*
 *  Universal TUN/TAP device driver.
 *  Copyright (C) 1999-2000 Maxim Krasnyansky <max_mk@yahoo.com>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details.
 */

#ifndef __IF_TUN_H
#define __IF_TUN_H

#include <linux/types.h>
#include <linux/if_ether.h>
#include <linux/filter.h>

/* Read queue size */
#define TUN_READQ_SIZE	500
/* TUN device type flags: deprecated. Use IFF_TUN/IFF_TAP instead. */
#define TUN_TUN_DEV 	IFF_TUN
#define TUN_TAP_DEV	IFF_TAP
#define TUN_TYPE_MASK   0x000f

/* Ioctl defines */
#define TUNSETNOCSUM  _IOW('T', 200, int) 
#define TUNSETDEBUG   _IOW('T', 201, int) 
#define TUNSETIFF     _IOW('T', 202, int) 
#define TUNSETPERSIST _IOW('T', 203, int) 
#define TUNSETOWNER   _IOW('T', 204, int)
#define TUNSETLINK    _IOW('T', 205, int)
#define TUNSETGROUP   _IOW('T', 206, int)
#define TUNGETFEATURES _IOR('T', 207, unsigned int)
#define TUNSETOFFLOAD  _IOW('T', 208, unsigned int)
#define TUNSETTXFILTER _IOW('T', 209, unsigned int)
#define TUNGETIFF      _IOR('T', 210, unsigned int)
#define TUNGETSNDBUF   _IOR('T', 211, int)
#define TUNSETSNDBUF   _IOW('T', 212, int)
#define TUNATTACHFILTER _IOW('T', 213, struct sock_fprog)
#define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
#define TUNGETVNETHDRSZ _IOR('T', 215, int)
#define TUNSETVNETHDRSZ _IOW('T', 216, int)
#define TUNSETQUEUE  _IOW('T