]> jfr.im git - solanum.git/blobdiff - ircd/s_user.c
Add ipv4-in-ipv6 logic to check_one_kline
[solanum.git] / ircd / s_user.c
index 39c207aeb5f1207f8e5ebc7edc887b0e043d54d8..daba26ec695e67a4b0b6f7f82c18a98c3ac16c47 100644 (file)
@@ -240,7 +240,7 @@ authd_check(struct Client *client_p, struct Client *source_p)
 
                        sendto_one_notice(source_p, ":*** Your IP address %s is listed in %s",
                                source_p->sockhost, blacklist);
-                       add_reject(source_p, NULL, NULL);
+                       add_reject(source_p, NULL, NULL, NULL, "Banned (DNS blacklist)");
                        exit_client(client_p, source_p, &me, "Banned (DNS blacklist)");
                        reject = true;
                }
@@ -283,7 +283,7 @@ authd_check(struct Client *client_p, struct Client *source_p)
                        sendto_one_notice(source_p,
                                ":*** Your IP address %s has been detected as an open proxy (type %s, port %s)",
                                source_p->sockhost, proxy, port);
-                       add_reject(source_p, NULL, NULL);
+                       add_reject(source_p, NULL, NULL, NULL, "Banned (Open proxy)");
                        exit_client(client_p, source_p, &me, "Banned (Open proxy)");
                        reject = true;
                }
@@ -307,7 +307,7 @@ authd_check(struct Client *client_p, struct Client *source_p)
 
                sendto_one_notice(source_p, ":*** Rejected by authentication system: %s",
                        reason);
-               add_reject(source_p, NULL, NULL);
+               add_reject(source_p, NULL, NULL, NULL, "Banned (authentication system)");
                exit_client(client_p, source_p, &me, "Banned (authentication system)");
                reject = true;
                break;
@@ -348,7 +348,6 @@ int
 register_local_user(struct Client *client_p, struct Client *source_p)
 {
        struct ConfItem *aconf, *xconf;
-       struct User *user = source_p->user;
        char tmpstr2[BUFSIZE];
        char ipaddr[HOSTIPLEN];
        char myusername[USERLEN+1];
@@ -367,9 +366,9 @@ register_local_user(struct Client *client_p, struct Client *source_p)
        {
                if(!(source_p->flags & FLAGS_PINGSENT) && source_p->localClient->random_ping == 0)
                {
-                       source_p->localClient->random_ping = (unsigned long) (rand() * rand()) << 1;
-                       sendto_one(source_p, "PING :%08lX",
-                                  (unsigned long) source_p->localClient->random_ping);
+                       source_p->localClient->random_ping = (uint32_t)(((rand() * rand()) << 1) | 1);
+                       sendto_one(source_p, "PING :%08X",
+                                  (unsigned int) source_p->localClient->random_ping);
                        source_p->flags |= FLAGS_PINGSENT;
                        return -1;
                }
@@ -415,13 +414,13 @@ register_local_user(struct Client *client_p, struct Client *source_p)
        /* Apply nick override */
        if(*source_p->preClient->spoofnick)
        {
-               char note[NICKLEN + 10];
+               char note[NAMELEN + 10];
 
                del_from_client_hash(source_p->name, source_p);
                rb_strlcpy(source_p->name, source_p->preClient->spoofnick, NICKLEN + 1);
                add_to_client_hash(source_p->name, source_p);
 
-               snprintf(note, NICKLEN + 10, "Nick: %s", source_p->name);
+               snprintf(note, sizeof(note), "Nick: %s", source_p->name);
                rb_note(source_p->localClient->F, note);
        }
 
@@ -448,6 +447,14 @@ register_local_user(struct Client *client_p, struct Client *source_p)
                return (CLIENT_EXITED);
        }
 
+       if(IsSCTP(source_p) && !IsConfAllowSCTP(aconf))
+       {
+               ServerStats.is_ref++;
+               sendto_one_notice(source_p, ":*** Notice -- You are not allowed to use SCTP on this server");
+               exit_client(client_p, source_p, &me, "SCTP not allowed");
+               return (CLIENT_EXITED);
+       }
+
        if(!IsGotId(source_p))
        {
                const char *p;
@@ -480,7 +487,7 @@ register_local_user(struct Client *client_p, struct Client *source_p)
                }
        }
 
-       if(IsNeedSasl(aconf) && !*user->suser)
+       if(IsNeedSasl(aconf) && !*source_p->user->suser)
        {
                ServerStats.is_ref++;
                sendto_one_notice(source_p, ":*** Notice -- You need to identify via SASL to use this server");
@@ -546,7 +553,7 @@ register_local_user(struct Client *client_p, struct Client *source_p)
           (xconf = find_xline(source_p->info, 1)) != NULL)
        {
                ServerStats.is_ref++;
-               add_reject(source_p, xconf->host, NULL);
+               add_reject(source_p, xconf->host, NULL, NULL, NULL);
                exit_client(client_p, source_p, &me, "Bad user info");
                return CLIENT_EXITED;
        }
@@ -621,11 +628,11 @@ register_local_user(struct Client *client_p, struct Client *source_p)
         */
        if(!*source_p->id)
        {
-               strcpy(source_p->id, generate_uid());
+               rb_strlcpy(source_p->id, generate_uid(), sizeof(source_p->id));
                add_to_id_hash(source_p->id, source_p);
        }
 
-       if (IsSSL(source_p))
+       if (IsSSL(source_p) && !IsInsecure(source_p))
                source_p->umodes |= UMODE_SSLCLIENT;
 
        if (source_p->umodes & UMODE_INVISIBLE)
@@ -665,7 +672,7 @@ register_local_user(struct Client *client_p, struct Client *source_p)
 
        free_pre_client(source_p);
 
-       introduce_client(client_p, source_p, user, source_p->name, 1);
+       introduce_client(client_p, source_p, source_p->user, source_p->name, 1);
        return 0;
 }
 
@@ -1114,12 +1121,19 @@ user_mode(struct Client *client_p, struct Client *source_p, int parc, const char
                                        }
                                        source_p->flags &= ~OPER_FLAGS;
 
-                                       rb_free(source_p->localClient->opername);
-                                       source_p->localClient->opername = NULL;
-
                                        rb_dlinkFindDestroy(source_p, &local_oper_list);
-                                       privilegeset_unref(source_p->localClient->privset);
-                                       source_p->localClient->privset = NULL;
+                               }
+
+                               if(source_p->user->opername != NULL)
+                               {
+                                       rb_free(source_p->user->opername);
+                                       source_p->user->opername = NULL;
+                               }
+
+                               if(source_p->user->privset != NULL)
+                               {
+                                       privilegeset_unref(source_p->user->privset);
+                                       source_p->user->privset = NULL;
                                }
 
                                rb_dlinkFindDestroy(source_p, &oper_list);
@@ -1406,8 +1420,8 @@ oper_up(struct Client *source_p, struct oper_conf *oper_p)
        SetExemptKline(source_p);
 
        source_p->flags |= oper_p->flags;
-       source_p->localClient->opername = rb_strdup(oper_p->name);
-       source_p->localClient->privset = privilegeset_ref(oper_p->privset);
+       source_p->user->opername = rb_strdup(oper_p->name);
+       source_p->user->privset = privilegeset_ref(oper_p->privset);
 
        rb_dlinkAddAlloc(source_p, &local_oper_list);
        rb_dlinkAddAlloc(source_p, &oper_list);
@@ -1426,6 +1440,8 @@ oper_up(struct Client *source_p, struct oper_conf *oper_p)
        sendto_realops_snomask(SNO_GENERAL, L_ALL,
                             "%s (%s!%s@%s) is now an operator", oper_p->name, source_p->name,
                             source_p->username, source_p->host);
+       sendto_server(NULL, NULL, CAP_TS6, NOCAPS, ":%s OPER %s %s",
+                       use_id(source_p), oper_p->name, oper_p->privset->name);
        if(!(old & UMODE_INVISIBLE) && IsInvisible(source_p))
                ++Count.invisi;
        if((old & UMODE_INVISIBLE) && !IsInvisible(source_p))