added ssl cipher notice on connect
[ircu2.10.12-pk.git] / ircd / s_user.c
index a19691db7edd7cd6954c251be297d7a127ef5864..9853ed237b74e818dfa53267eaaf08767595e065 100644 (file)
@@ -57,6 +57,7 @@
 #include "s_misc.h"
 #include "s_serv.h" /* max_client_count */
 #include "send.h"
+#include "ssl.h"
 #include "struct.h"
 #include "supported.h"
 #include "sys.h"
@@ -395,6 +396,13 @@ int register_user(struct Client *cptr, struct Client *sptr)
                            cli_info(sptr), NumNick(cptr) /* two %s's */);
 
     IPcheck_connect_succeeded(sptr);
+    
+    if(cli_connect(sptr)->con_ssl) {
+      SetSSLConn(sptr);
+      
+      const char *cipher = ssl_get_cipher(cli_connect(sptr)->con_ssl);
+      sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :You are connected to %s with %s", sptr, cli_name(&me), cipher);
+    }
   }
   else {
     struct Client *acptr = user->server;
@@ -499,7 +507,8 @@ static const struct UserMode {
   { FLAG_CHSERV,      'k' },
   { FLAG_DEBUG,       'g' },
   { FLAG_ACCOUNT,     'r' },
-  { FLAG_HIDDENHOST,  'x' }
+  { FLAG_HIDDENHOST,  'x' },
+  { FLAG_SSLCONN,     'S' }
 };
 
 /** Length of #userModeList. */
@@ -1076,6 +1085,12 @@ int set_user_mode(struct Client *cptr, struct Client *sptr, int parc,
       case 'x':
         if (what == MODE_ADD)
          do_host_hiding = 1;
+      case 'S':
+        if (what == MODE_ADD)
+          SetSSLConn(sptr);
+        else
+          ClearSSLConn(sptr);
+        break;
        break;
       case 'r':
        if (*(p + 1) && (what == MODE_ADD)) {
@@ -1102,6 +1117,10 @@ int set_user_mode(struct Client *cptr, struct Client *sptr, int parc,
       ClearLocOp(sptr);
     if (!FlagHas(&setflags, FLAG_ACCOUNT) && IsAccount(sptr))
       ClrFlag(sptr, FLAG_ACCOUNT);
+    if (!FlagHas(&setflags, FLAG_SSLCONN) && IsSSLConn(sptr))
+      ClrFlag(sptr, FLAG_SSLCONN);
+    else if (FlagHas(&setflags, FLAG_SSLCONN) && !IsSSLConn(sptr))
+      SetFlag(sptr, FLAG_SSLCONN);
     /*
      * new umode; servers can set it, local users cannot;
      * prevents users from /kick'ing or /mode -o'ing
@@ -1128,7 +1147,10 @@ int set_user_mode(struct Client *cptr, struct Client *sptr, int parc,
   {
     if ((FlagHas(&setflags, FLAG_OPER) || FlagHas(&setflags, FLAG_LOCOP)) &&
         !IsAnOper(sptr))
+    {
       det_confs_butmask(sptr, CONF_CLIENT & ~CONF_OPERATOR);
+      client_set_privs(sptr, NULL);
+    }
 
     if (SendServNotice(sptr))
     {